Page 1 of 1
PDF Document
Posted: Thu Mar 14, 2024 7:45 pm
by ClueLess
Hi.
How can I create a PDF document? The example on HELP for PdfVectorOutput doesn't work and says it is not supported.
Thank you in advance
Re: PDF Document
Posted: Thu Mar 14, 2024 8:52 pm
by mk-soft
Use right PB version ?
Re: PDF Document
Posted: Fri Mar 15, 2024 12:00 am
by spikey
PDF output for Windows is new for 6.10, it's Mac/Linux only in previous versions. The example shown in the help article for PdfVectorOutput() won't actually work (on Windows). It tries to write to a read only folder and fails with no error message. It needs updating. Try this, it should work properly:
Code: Select all
LoadFont(0, "Times New Roman", 20)
File$ = GetTemporaryDirectory() + "test.pdf"
If StartVectorDrawing(PdfVectorOutput(File$, 595, 842))
VectorFont(FontID(0), 25)
MovePathCursor(20, 20)
DrawVectorText("This is page 1...")
NewVectorPage()
MovePathCursor(20, 20)
DrawVectorText("This is page 2...")
StopVectorDrawing()
EndIf
RunProgram(File$)
(Edit: Removed an extraneous separator).
Re: PDF Document
Posted: Fri Mar 15, 2024 1:28 am
by mk-soft
One #PS$ too much ...
Re: PDF Document
Posted: Fri Mar 15, 2024 10:43 am
by ClueLess
Thank You
Re: PDF Document
Posted: Fri Mar 15, 2024 11:30 am
by spikey
mk-soft wrote: Fri Mar 15, 2024 1:28 am
One #PS$ too much ...
Oops, I missed that. Note to self: Put the
right glasses on when programming,
not the first pair that come to hand...
Re: PDF Document
Posted: Wed Mar 20, 2024 12:12 am
by BarryG
spikey wrote: Fri Mar 15, 2024 12:00 amPDF output for Windows is new for 6.10
Can we use this to convert a loaded image into a PDF document? Would be amazing if so!
Re: PDF Document
Posted: Wed Mar 20, 2024 2:51 am
by TassyJim
BarryG wrote: Wed Mar 20, 2024 12:12 am
Can we use this to convert a loaded image into a PDF document? Would be amazing if so!
Yes
Code: Select all
LoadFont(0, "Lucida Console", 8)
LoadImage(0, #PB_Compiler_Home + "examples/sources/Data/PureBasicLogo.bmp")
If StartVectorDrawing(PdfVectorOutput("c:\\apps\test.pdf", 595, 842))
VectorFont(FontID(0), 8)
rowHt = VectorTextHeight("Wg")+2
MovePathCursor(20, 20)
DrawVectorText("line 1 ; no indent")
MovePathCursor(20, 20+rowHt)
VectorSourceColor(RGBA(255, 0, 0, 255))
DrawVectorText(" line 2 ; indented")
MovePathCursor(50, 50)
DrawVectorImage(ImageID(0), 127)
StopVectorDrawing()
EndIf
Jim
Re: PDF Document
Posted: Wed Mar 20, 2024 3:07 am
by BarryG
Thanks so much, TassyJim!

I shortened it to this for my needs:
Code: Select all
UseJPEGImageDecoder()
LoadImage(0,"d:\image.jpg")
If StartVectorDrawing(PdfVectorOutput("d:\test.pdf",ImageWidth(0),ImageHeight(0)))
DrawVectorImage(ImageID(0))
StopVectorDrawing()
EndIf
Re: PDF Document
Posted: Wed Mar 20, 2024 6:53 am
by Fangbeast
Note to self: Put the right glasses on when programming, not the first pair that come to hand...
You sound a lot like me. 4 different pair of glasses, all necessary and I still put the wrong damned ones on.
Re: PDF Document
Posted: Wed Mar 20, 2024 7:03 am
by idle
Fangbeast wrote: Wed Mar 20, 2024 6:53 am
Note to self: Put the right glasses on when programming, not the first pair that come to hand...
You sound a lot like me. 4 different pair of glasses, all necessary and I still put the wrong damned ones on.
rack and stack em!