Page 6 of 10
Re: [Module] pbPDF-Module
Posted: Tue Oct 20, 2020 1:55 pm
by captain_skank
Hi,
In the PageFormat example
Code: Select all
XIncludeFile "..\pbPDFModule.pbi"
Define File$="pbPDF-PageFormat.pdf"
#PDF = 1
Procedure Header()
PDF::SetFont(#PDF, "Arial","B", 15)
PDF::SetPosX(#PDF, PDF::GetPageWidth(#PDF) / 2 - 15)
PDF::Cell(#PDF, "Title", 30, 10, 1, 0, PDF::#CenterAlign)
PDF::Ln(#PDF, 20)
EndProcedure
Procedure Footer()
PDF::SetFont(#PDF, "Arial", "I", 8)
PDF::SetPosY(#PDF, -15)
PDF::Cell(#PDF, "Page {p} / {t}", #False, 10, #False, PDF::#Right, PDF::#CenterAlign)
EndProcedure
If PDF::Create(#PDF)
PDF::SetAliasTotalPages(#PDF, "{t}")
PDF::SetHeaderProcedure(#PDF, @Header())
PDF::SetFooterProcedure(#PDF, @Footer())
PDF::AddPage(#PDF)
PDF::SetFont(#PDF, "Arial", "B", 16)
PDF::Cell(#PDF, StrF(PDF::GetPageWidth(#PDF), 0) + "x" + StrF(PDF::GetPageHeight(#PDF), 0) + " mm", 40, 10, #True)
PDF::AddPage(#PDF, "L", PDF::#Format_A4)
PDF::SetFont(#PDF, "Arial", "B", 16)
PDF::Cell(#PDF, StrF(PDF::GetPageWidth(#PDF), 0) + "x" + StrF(PDF::GetPageHeight(#PDF), 0) + " mm", 40, 10, #True)
PDF::AddPage(#PDF, "L", PDF::#Format_A5)
PDF::SetFont(#PDF, "Arial","B", 16)
PDF::Cell(#PDF, StrF(PDF::GetPageWidth(#PDF), 0) + "x" + StrF(PDF::GetPageHeight(#PDF), 0) + " mm", 40, 10, #True)
PDF::AddPage(#PDF, "P", PDF::#Format_A6)
PDF::SetFont(#PDF, "Arial", "B", 16)
PDF::Cell(#PDF, StrF(PDF::GetPageWidth(#PDF), 0) + "x" + StrF(PDF::GetPageHeight(#PDF), 0) + " mm", 40, 10, #True)
PDF::Close(#PDF, File$)
EndIf
RunProgram(File$)
Yuo have the procedures for header and footer which i presume should automaticaly be applied to each page after using
Code: Select all
PDF::SetHeaderProcedure(#PDF, @Header())
PDF::SetFooterProcedure(#PDF, @Footer())
However I get neither a header or footer on any page when i run the example.
Is this an error or am i doing something wrong ?
I'm using Win10 PRO x64 and Adobe Reader DC.
Cheers
Re: Moving inside the PDF File ; How to ?
Posted: Tue Oct 20, 2020 9:35 pm
by normeus
loulou2522 wrote:I don't know how to do the following:
I'm on page 2 of my PDF and would like to go back to Page One to add text at a defined position and then go back to Page Two and continue processing. Is this possible?
once you create a new page the previous page is finalized. I set up my pages with a structure, and when I have all data then I create the final PDF.
This does sound interesting since the PDF page is just saved in memory, you'll have to reserve some space for the object, just like footer works. ( When I have time I'll take a look, but don't hold your breath)
@captain_skank
The PageFormat example is missing some code just after you set the procedures:
Code: Select all
PDF::SetHeaderProcedure(#PDF, @Header())
PDF::SetFooterProcedure(#PDF, @Footer())
PDF::EnableFooter(#PDF, #True) :ADD
PDF::EnableHeader(#PDF, #True) ;ADD
PDF::SetPageNumbering(#PDF, #True) ;ADD
Norm.
Re: [Module] pbPDF-Module
Posted: Wed Oct 21, 2020 9:25 am
by captain_skank
Thanks Norm.
Re: [Module] pbPDF-Module
Posted: Wed Oct 21, 2020 10:31 am
by captain_skank
Right another PDF dumba$$ question.
When using
how do you force a line break manualy ??
The help doc doesn't mention it and the original purePDF help states a linebreak can be explicitly made but doesn't say how.
Tried adding #CRLF$ or #LF$ to the string also tried including /r \r /n \n into the string but no joy.
Anybody got a clue ?
Cheers
Re: [Module] pbPDF-Module
Posted: Wed Oct 21, 2020 8:02 pm
by normeus
That's odd, #LF$ should work, here's an example
pbPDF-Multiline.pb
Code: Select all
XIncludeFile "..\pbPDFModule.pbi"
Define File$="pbPDF-Multiline.pdf"
Define Text$, i.i
;{ These constants are defined in the module, but they did not work on my example, and I wanted a border
#Border = #True
#LeftBorder = -1
#TopBorder = -2
#RightBorder = -4
#BottomBorder = -8
;}
#PDF = 1
If PDF::Create(#PDF)
PDF::AddPage(#PDF)
PDF::SetFont(#PDF, "Arial", "", 12)
Text$ = "PureBasic:"+#LF$+ "Is a programming language based on established BASIC rules. The key features of PureBasic are portability "
Text$ + "(Windows, AmigaOS and Linux are currently fully supported), "+#LF$+#LF$+ "the production of very fast and highly optimized executables "
Text$ + "and, of course, the very simple BASIC syntax. PureBasic has been created for the beginner and expert alike. We have put "
Text$ + "a lot of effort into its realization to produce a fast, reliable and system friendly language."
PDF::Cell(#PDF,"JUST A CELL"+#LF$+ " WITH NO BREAK",70,15,#Border)
PDF::ln(#PDF)
PDF::MultiCell(#PDF,Text$,100,5,#Border)
PDF::ln(#PDF)
PDF::Write(#PDF,"It also works"+#LF$+ " with write!!!")
PDF::Close(#PDF, File$)
EndIf
RunProgram(File$)
I hope that helps.
Norm.
Re: [Module] pbPDF-Module
Posted: Wed Oct 21, 2020 9:27 pm
by captain_skank
Again thanks Norm, not sure why it didn't work when i tried it.
Although I may have misunderstood the height property so set it at 20, so when I tried it using #LF$ I just got a one line cell

making me think it didn't work.
Re: [Module] pbPDF-Module
Posted: Thu Dec 03, 2020 8:47 am
by loulou2522
Would it be possible to have a programming example with two form text fields A1 and A2 with javascript copying from field A1 to A2 when field A1 changes content. Thank you in advance
Re: [Module] pbPDF-Module
Posted: Wed Dec 16, 2020 12:25 am
by totorcalais
Hello,
Its possible to make a pdf with Digital Signature Timestamping (TSA) ?
Re: [Module] pbPDF-Module
Posted: Tue May 18, 2021 7:27 am
by Little_man
Very nice Module.
Would you be able to give a small example of how to properly use PDF::ImageMemory with PNG image
Little_man
Re: [Module] pbPDF-Module
Posted: Tue May 18, 2021 1:49 pm
by Paul
Little_man wrote: Tue May 18, 2021 7:27 am
Very nice Module.
Would you be able to give a small example of how to properly use
PDF::ImageMemory with PNG image
Little_man
Apparently doesn't work
https://www.purebasic.fr/english/viewto ... 81#p540281
Re: [Module] pbPDF-Module
Posted: Tue May 18, 2021 9:25 pm
by normeus
Save this file in pdf/examples folder.
It loads "PureBasic.png" into memory encodes image and adds it to page. I used format "pdf::#Image_PNG".
it works with PB 5.73LTSx64 win10x64
Code: Select all
XIncludeFile "..\pbPDFModule.pbi"
Define LinkID.i, File$ = "pbPDF-imageMemory.pdf"
Define *pdf_1_mem,pdf_1_img,pdf_1_size
#PDF = 1
If PDF::Create(#PDF)
PDF::AddPage(#PDF)
LinkID = PDF::AddLinkURL(#PDF, "https://www.purebasic.com/")
pdf_1_img = LoadImage(#PB_Any,"PureBasic.png");#PB_Any
If pdf_1_img ; if there was an image in that location
*pdf_1_mem=EncodeImage(pdf_1_img,#PB_ImagePlugin_PNG);
If *pdf_1_mem
pdf_1_size= MemorySize(*pdf_1_mem)
;pdf::ImageMemory(ID.i, ImageName.s, *Memory, Size.i, Format.i, X.f=#PB_Default, Y.f=#PB_Default, Width.f=#PB_Default, Height.f=#PB_Default, Link.i=#NoLink)
pdf::imagememory(#pdf,"PureBasic.png",*pdf_1_mem,pdf_1_size,pdf::#Image_PNG,20,20,60,20,LinkID)
; PDF::Image(#PDF, "PureBasic.png", 10, 20, 30, 10, LinkID)
EndIf
FreeMemory(*pdf_1_mem)
FreeImage(pdf_1_img)
EndIf
PDF::Close(#PDF, File$)
EndIf
RunProgram(File$)
Norm
Re: [Module] pbPDF-Module
Posted: Tue May 18, 2021 10:15 pm
by Paul
Thanks Norm !!
That would have been really handy a year and a half ago

Re: [Module] pbPDF-Module
Posted: Tue May 18, 2021 10:39 pm
by normeus
Paul,
The "Notify when reply is posted" never worked for me. hopefully it has been fixed with the new board. I was just lucky that I saw @Little_man's post and your reply today. ( actually, I got an email notice about your reply to my post, so it does work )
Norm.
Re: [Module] pbPDF-Module
Posted: Wed May 19, 2021 6:10 am
by Little_man
Thanks for the information, 'Norm'' !!
Little_man
Re: [Module] pbPDF-Module
Posted: Sat May 29, 2021 6:31 pm
by Kwai chang caine
Hello at all
Excuse by advance this stupid question

, but is it possible to simply open and show an existing PDF ? with this splendid module
