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.

