Graphics.rotate doesn't work for PDFs?

I’m totally confused. I saw that PDFgraphics now supports the new graphics.rotate and other commands, but whenever I try and use them I get an unsupportedOperation error that says I can’t use graphics outside of its paint event.

Like this very simple example project doesn’t work:

dim pdf as new pdfDocument
dim g as graphics = pdf.graphics

// Rotate square in center of graphics area
const pi = 3.14159
g.translate(g.width / 2, g.height / 2)
g.rotate(pi / 4) // 45 degrees or 1/8 of a circle
g.drawingColor = color.blue
g.fillRectangle(10, 10, 50, 50)

dim f as folderItem = specialFolder.desktop.child("test.pdf")
pdf.save(f)

Am I doing something wrong or does this new feature not actually work?

@Marc_Zeedar what version of xojo are you using?

This is a documentation error. Rotate/Scale/Translate are currently not available in PDFGraphics. There is a Feedback case for this with state “Scheduled”. Hopefully soon.

1 Like

:man_facepalming:

Thanks, Martin! I hadn’t checked Feedback as I wasn’t thinking of this as a bug, but my own implementation error…

2 Likes