PurePDF crashes with pdf_AliasNbPages()
Posted: Mon May 31, 2010 10:29 pm
Hi everyone!
I've got a problem with PurePDF, I wish to create a PDF with a dynamic number of pages and use pdf_AliasNbPages() in it.
Here's the code:
This is a very rudimentary piece of code, but still, it should work, but it doesn't. When I run the programme, it crashes once it hits the pdf_Save() command. PureBasic gives me an error like: Invalid memory access. (read error at address xyz)
Using PB 4.41 with PurePDF 2.15 here (Feb 26th, the version from April 5th doesn't work for me at all...)). I reckon the problem is with the pdf_AliasNbPages(), because when I put a comment on that line, the code works fine. Also, when I remove the {nb} from the pdf_Cell() command, the code doesn't crash, but it also doesn't show the total number of pages in the final PDF file...
Anyone got any clues as to what the heck is going wrong here?? Thanks for any help!!
I've got a problem with PurePDF, I wish to create a PDF with a dynamic number of pages and use pdf_AliasNbPages() in it.
Here's the code:
Code: Select all
Procedure Header()
pdf_SetFontSize(14)
pdf_Cell(90,15,"Company",0,0,#PDF_ALIGN_CENTER)
pdf_Cell(90,15,"Name",0,0,#PDF_ALIGN_RIGHT)
pdf_Ln(7)
pdf_SetFontSize(10)
pdf_Cell(90,11,"Title",0,0,#PDF_ALIGN_CENTER)
pdf_Cell(90,11,"Title",0,0,#PDF_ALIGN_RIGHT)
pdf_Ln(5)
pdf_Cell(90,11,"")
pdf_Cell(90,11,"Adress",0,0,#PDF_ALIGN_RIGHT)
pdf_Ln()
pdf_Ln()
EndProcedure
Procedure Footer()
pdf_SetY(-20)
pdf_SetFontSize(8)
pdf_Ln()
pdf_Cell(180,9,"Footline containing some legal information",0,0,#PDF_ALIGN_CENTER)
EndProcedure
If pdf_Create("P","mm",#PDF_PAGE_FORMAT_A4)
pdf_AliasNbPages()
pdf_SetCreator("Creator")
pdf_SetTitle("File created "+FormatDate("%dd.%mm.%yyyy", Date()))
pdf_SetFont("Helvetica","", 8)
pdf_SetProcHeader(@Header())
pdf_SetProcFooter(@Footer())
pdf_AddPage("P",#PDF_PAGE_FORMAT_A4)
pdf_Cell(190,9,"Page "+Str(pdf_GetPageNo())+" / {nb}",0,1,"R")
pdf_Cell(15,6,"Item",#PDF_CELL_TOPBORDER)
pdf_Cell(15,6,"Amount",#PDF_CELL_TOPBORDER)
pdf_Cell(120,6,"Description",#PDF_CELL_TOPBORDER)
pdf_Cell(20,6,"Unit price €",#PDF_CELL_TOPBORDER)
pdf_Cell(20,6,"Total price €",#PDF_CELL_TOPBORDER,1,"R")
pdf_Cell(190,6,"",#PDF_CELL_TOPBORDER)
file$ = SaveFileRequester("Save PDF file...","","Portable Document Format (*.pdf)|*.pdf",0)
pdf_Save(file$)
RunProgram(file$)
EndIf
Using PB 4.41 with PurePDF 2.15 here (Feb 26th, the version from April 5th doesn't work for me at all...)). I reckon the problem is with the pdf_AliasNbPages(), because when I put a comment on that line, the code works fine. Also, when I remove the {nb} from the pdf_Cell() command, the code doesn't crash, but it also doesn't show the total number of pages in the final PDF file...
Anyone got any clues as to what the heck is going wrong here?? Thanks for any help!!