PdfVectorOutput() request/problem
Posted: Tue Nov 18, 2025 2:24 am
I tried PdfVectorOutput() with pb 6.30 beta 4.
When a PDF cannot be opened for writing, the error is not handled and the compiled program just stops running.
It seems that the PDF library returns a 1 if there is an error creating the PDF file for output otherwise it returns a pointer.
StartVectorDrawing() should be able to inspect the return of PdfVectorOutput() and return an error. In the mean time checking for 1 is a workaround:
I saw T4r4ntul4's request to be able to change pdf page size like so: NewVectorPage(x,y). NewVectorPage() is also used for printer output, but we have other commands that ignore the extra parameters, like AddGadgetItem(), so it seems like a reasonable request.
c code, hopefully is as simple as this:
Anyway, I only tried it with PB 6.30 beta 4 x64
Norm.
When a PDF cannot be opened for writing, the error is not handled and the compiled program just stops running.
It seems that the PDF library returns a 1 if there is an error creating the PDF file for output otherwise it returns a pointer.
StartVectorDrawing() should be able to inspect the return of PdfVectorOutput() and return an error. In the mean time checking for 1 is a workaround:
Code: Select all
LoadFont(0, "Times New Roman", 20)
pdfpointer=PdfVectorOutput("d:\test.pdf", 595, 842 )
If pdfpointer=1
MessageRequester("NO OUTPUT CREATED","PDF File Could not be created")
Else
If StartVectorDrawing(pdfpointer)
VectorFont(FontID(0), 25)
MovePathCursor(20, 20)
DrawVectorText("This is page 1...")
NewVectorPage()
MovePathCursor(25, 25)
DrawVectorText("This is page 2...")
StopVectorDrawing()
Else
Debug "PDF File could not be created"
EndIf
EndIf
c code, hopefully is as simple as this:
Code: Select all
/ * if PdfVectorOutput */
/* add a new page object. */
page = HPDF_AddPage (pdf);
/* if x change width, and if y change height */
if ( y > 0 ){
HPDF_Page_SetHeight (page, y);
}
if ( x > 0 ){
HPDF_Page_SetWidth (page, x);
}
Norm.