How to convert window to PDF

I want to have a several windows that have different drawings(art) on the screen. There will also be text boxes so I can input dimensions and info for the client to view and know how to build something based on the drawings I provide. Once filled out, the screen will show an installer/client a drawing of some artwork and dimensions of how to construct a wall and door framing. I want to be able to Save To PDF my screen after populating the screen with dimensions. There could be multiple screens, so I want to be able to capture to pdf the current screen, ideally saving the PDF AS to a clients folder on my local drive. This is sort of a screen capture but more of an elegant version of that.

Any suggestions on a way to do this?

http://developer.xojo.com/userguide/printing
https://forum.xojo.com/5773-print-window-help/0
https://forum.xojo.com/36895-printing-the-contents-of-a-window/0
https://forum.xojo.com/12818-printing-in-windows-drawstring-gives-incorrect-character-spacin/0

you can print the window content to a virtual pdf printer like “microsoft print to pdf” or “pdf creator”

There are also addons that allow you to create PDFs.
MBS DynaPDF is a plugin that allows you to create PDFs using the DynaPDF library.
gPDF is written in Xojo-code and creates PDFs as if you were drawing on a Graphics object.

if you’re on macos, you can use the built-in pdf printing services and this method :

[code]’ prints the window content

dim g as Graphics
g = OpenPrinterDialog( mPrinterSetup, mParent)
if g<>nil then
’ draws a picture of the complete window
dim p as new Picture( mParent.Width, mParent.Height, 32)
mParent.DrawInto p.Graphics, 0, 0
dim gheight as Integer = g.Width/p.Width*p.Height

g.DrawPicture p, 0, 0, g.Width, gheight, 0, 0, p.Width, p.Height

end if
[/code]

Yes Mac OS. Thanks I will check that out

DrawInto is limited.

I would write code to go over list of controls and draw each one like you want to have it.

[quote=350302:@Jean-Yves Pochez]if you’re on macos, you can use the built-in pdf printing services and this method :

[code]’ prints the window content

dim g as Graphics
g = OpenPrinterDialog( mPrinterSetup, mParent)
if g<>nil then
’ draws a picture of the complete window
dim p as new Picture( mParent.Width, mParent.Height, 32)
mParent.DrawInto p.Graphics, 0, 0
dim gheight as Integer = g.Width/p.Width*p.Height

g.DrawPicture p, 0, 0, g.Width, gheight, 0, 0, p.Width, p.Height

end if
[/code][/quote]
which requires user intervention… that same code can be used with gPDF to write the PDF file directly to any folderitem without needing the OpenPrinterDialog… by the same token, you can take Christians suggestion to create the picture, and send THAT to gPDF

Don’t create a picture. Draw vector graphics to make your users happy.

fine, gPDF can do that too

as well as DynaPDF…

Remember that OpenPrinterDialog is not mandatory: it is possible to print to pdf directly.

Issue a quest on this forum to get the details.

Also, WIndows 10 have a pdf virtual printer (and I still not had time to check that).

please illustrate how to send a “print” document directly to a PDF file under macOS/Xojo without the dialog… I would be very interested to see that

for mac see:
https://www.mbsplugins.de/archive/2014-09-30/Tip_of_the_day_Print_to_PDF_wi
https://www.mbsplugins.de/archive/2015-04-30/Tip_of_day_Save_Xojo_report_to
https://www.mbsplugins.de/archive/2014-02-24/Print_to_PDF_File_on_Mac_OS_X_

I get the trick from the forum (this one or the previous one).

I do not recall the link and do not know where on my external hard disks archives that example resides.

Of course, if I found it… (I have to find something else, so…)