Below a code to make a simple pdf file… just put it under a button … it makes the file test.pdf and launches it…
The code is free to use/modify/spread.
Remark that each line extra the ‘-10’ asks… good luck.
This code is easily to port to other ide’s/software…
Note … this will NOT work if the text exceeds what you entered in your example.
Trust me
PDF is very picky about its pointer, their location, and size… Add more text, and your XREF table becomes invalid
The code below works fine and comes from the docs (one of the examples from PrinterSetup):
Dim g As Graphics
Dim p As PrinterSetup
p = New PrinterSetup
If p.PageSetupDialog Then
g = OpenPrinterDialog(p)
If g <> Nil Then
g.DrawString("Greetings to Frederik Pot from Emile Schwarz.", 50, 50)
End If
End If
I only changed the string.
To get a pdf, on OS X, click in the OK button (Printer Setup window), then in the PDF popup, choose the first or the second option.
On Windows, install a virtual printer (as said earlier) and do nearly the same (watch carefully what youre doing 'cause there is a lot of available options).
The generated pdf have vectorial text.
You can change the font name, size, etc. before the DrawString line,using Graphics commands (g.TextFont, g.TextSize) the orientation: g.Landscape = True
OK, this is far different than what the op says, but I make PDF (and paper) reports using this way (the user tried to print in A3 instead of A4: I never tested that and THIS WORKED !)
Enjoy.
PS: you can even pass graphics (images, photos, Object2D ) if you need (Ive done that in the front page).
I nearly forgot: I prefer a Xojo made Export to PDF feature (that can create vector pdf)
BTW: if youre talking about the example above, can you expand your answer (I do not understand the point: the result is the same; one code = two features).
PDF is “kinda” forgiving… but not too much. All those numbers MEAN something, and if the pointers don’t match the contents, then PDF readers say “So sorry, too bad”… So while you code might work for “simple” (ie. short) examples, it will begin to fail if you add more that a few lines or code, and WILL fail if you attempt more pages.
gPDF (source code available) handles all of that and much much more, in the same syntax as you are familiar with using the Xojo Canvas
You should include a link to it when you mention it Dave
People might not know where to locate it and may not scroll back through a long forum thread to find such a link
And if you haven’t you should ask Paul to list it on the Third Party products lists
Maybe Dana as well to list it in the store
Well, when i did some tests , i found out that the ‘rgb color’ is not working… more a 1 for red(1 0 0) , a 1 for green (0 1 0) and a 1 for blue (0 0 1)… have no solution for it till now… Goodluck…
PDF format is somewhat complex… and for the most part unforgiving… As I have said many times… you cannot just cobble it together, because once you get past a certain point, the PDF will become corrupt, and the pointers, indexes, lengths etc MUST line up… and just adding “stuff” doesn’t allow that…
which what programs like gPDF and DynaPDF do… all those calculations