PdfVectorOutput() request/problem

Just starting out? Need help? Post your questions and find answers here.
normeus
Enthusiast
Enthusiast
Posts: 485
Joined: Fri Apr 20, 2012 8:09 pm
Contact:

PdfVectorOutput() request/problem

Post by normeus »

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:

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


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:

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);
    }
Anyway, I only tried it with PB 6.30 beta 4 x64

Norm.
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari
Fred
Administrator
Administrator
Posts: 18453
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PdfVectorOutput() request/problem

Post by Fred »

It should not crash, can you open a bug report for this ?
Post Reply