PDF Document

Just starting out? Need help? Post your questions and find answers here.
ClueLess
Enthusiast
Enthusiast
Posts: 360
Joined: Sun Jan 11, 2009 1:04 am

PDF Document

Post 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
User avatar
mk-soft
Always Here
Always Here
Posts: 6320
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: PDF Document

Post by mk-soft »

Use right PB version ?
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
spikey
Enthusiast
Enthusiast
Posts: 778
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: PDF Document

Post 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).
Last edited by spikey on Fri Mar 15, 2024 11:28 am, edited 1 time in total.
User avatar
mk-soft
Always Here
Always Here
Posts: 6320
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: PDF Document

Post by mk-soft »

One #PS$ too much ...
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
ClueLess
Enthusiast
Enthusiast
Posts: 360
Joined: Sun Jan 11, 2009 1:04 am

Re: PDF Document

Post by ClueLess »

Thank You
User avatar
spikey
Enthusiast
Enthusiast
Posts: 778
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: PDF Document

Post 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...
BarryG
Addict
Addict
Posts: 4219
Joined: Thu Apr 18, 2019 8:17 am

Re: PDF Document

Post 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!
TassyJim
Enthusiast
Enthusiast
Posts: 189
Joined: Sun Jun 16, 2013 6:27 am
Location: Tasmania (Australia)

Re: PDF Document

Post 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
BarryG
Addict
Addict
Posts: 4219
Joined: Thu Apr 18, 2019 8:17 am

Re: PDF Document

Post by BarryG »

Thanks so much, TassyJim! :D 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
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4792
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: PDF Document

Post 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.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
User avatar
idle
Always Here
Always Here
Posts: 6031
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: PDF Document

Post 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!
Post Reply