PXC_AddPage does not increment page count

This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-Tools SDK of Library DLL functions(only) - Please use the PDF-XChange Drivers API SDK Forum for assistance with all PDF Print Driver related topics or PDF-XChange Viewer SDK if appropriate.

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan

Post Reply
pmazurk
User
Posts: 27
Joined: Tue Feb 22, 2011 10:25 pm

PXC_AddPage does not increment page count

Post by pmazurk »

Using VB.Net -

Assuming I properly create a new document object with
Dim res As Integer = PDFXC_Funcs.PXC_NewDocument(m_doc, DevKey, DevCode)

and then add a page with
res = PDFXC_Funcs.PXC_AddPage(m_doc, dblWidth, dblHeight, intThisPg)

shouldn't m_PagesCount increment? m_doc and intThisPage are both integers, and after their function calls both are greater than zero. m_doc in the AddPage function is non-zero and is the same value set in the NewDocument call. The TIF file names are correct, and the function calls do not return errors before I try to save the document.

I'm trying to create a new PDF document, and add multiple single-page TIF file contents to it, one PDF page per TIF file. I have an object (XPProDoc) that wraps the XCPro40 methods, PDFXC_Funcs, etc. This object contains the two calls noted above and a CopyTIFFileToPDF method. It is instantiated on a form and then manipulated in that form's code. The form's code loops through a list of TIF files amd metadata. It creates a new document object, goes through the TIF files that apply to a value in the metadata, and then tries to save the document. It then repeats the process for the next metadata value.

When the list of TIF files is exhausted I try to save the document, but the famous Error []: message comes up. The error code is -2113394928, which according to the DSErrorLookup tool translates to "Document is not read".

By monitoring the page count as each TIF file is processed I notice it never goes above 0.

Here is the CopyTIFFileToPDF method:

' the object is already open, and m_doc has a value > 0

res = PDFXC_Funcs.PXC_AddPage(m_doc, dblWidth, dblHeight, intThisPg)
If PXCV_Errors.IS_DS_FAILED(res) = -1 Then
MsgBox(PXCV_Errors.DSErrorMessage(res))
End If
' intThisPage is a non-zero value after the above call

res = PDFXC_Funcs.PXC_AddImageW(m_doc, strTIF, p)
If PXCV_Errors.IS_DS_FAILED(res) = -1 Then
MsgBox(PXCV_Errors.DSErrorMessage(res))
End If
' p is initialized to -99 but is 0 after the above call

' get the image dimensions
PDFXC_Funcs.PXC_GetImageDimension(m_doc, p, iw, ih)
If PXCV_Errors.IS_DS_FAILED(res) = -1 Then
MsgBox(PXCV_Errors.DSErrorMessage(res))
End If
' iw and ih are reasonable values (for an 8.5 x 11 inch page) after the above call

' place the image on the new page
res = PDFXC_Funcs.PXC_PlaceImage(intThisPg, p, 0, dblHeight, dblWidth, dblHeight)
If PXCV_Errors.IS_DS_FAILED(res) = -1 Then
MsgBox(PXCV_Errors.DSErrorMessage(res))
End If

res = PDFXC_Funcs.PXC_EndPage(intThisPg)
If PXCV_Errors.IS_DS_FAILED(res) = -1 Then
MsgBox(PXCV_Errors.DSErrorMessage(res))
End If

No error messages are generated by any of the above code. However, the page count does not increment.

Before we get too far into trading more code etc, is there something simple I'm missing that would cause this error?

Thanks -
Paul
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17823
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: PXC_AddPage does not increment page count

Post by Tracker Supp-Stefan »

Hi Paul,

We will need a full compilable sample project which demonstrates the problem.
Please make sure to remove any license keys if you will be uploading the project here in the forums, or send it to support@pdf-xchange.com with a link to this topic.

Best,
Stefan
Walter-Tracker Supp
User
Posts: 381
Joined: Mon Jun 13, 2011 5:10 pm

Re: PXC_AddPage does not increment page count

Post by Walter-Tracker Supp »

I believe you will need to use PXC_GetPagesCount() to determine the number of pages. This function does not return a pointer to some internal page count, so you need to call it to refresh the page count as needed (e.g. after every new page is added).

As for your error message (document not read), I would want to see a more complete sample of the code before making an assessment. You can send it to support@pdf-xchange.com if you don't want to post it here.

-Walter
Walter-Tracker Supp
User
Posts: 381
Joined: Mon Jun 13, 2011 5:10 pm

Re: PXC_AddPage does not increment page count

Post by Walter-Tracker Supp »

The problem here is that you are using PXCp_WriteDocumentW() to save the document where you should be using the equivalent PXC function, which is PXC_WriteDocumentW(). This is because you have been using PXC functions for creation of the document (PXC_Init(), PXC_AddImageW(), etc). The document types are not equivalent; in our libraries, the "PDF" document pointer that you pass around is not a pointer to PDF data in memory but rather a pointer to an internal class, so PXC documents are not equivalent to PXCV documents or PXCp documents. There are sensible reasons for this scheme (memory usage, compartmentalization of different libraries and licensing, etc) but it can lead to some confusion.

What happens in this case is that you are passing a PXC library's internal PDF class to the PXCp library, and it is testing the memory location and determining that there is no valid PXCp document class there, so it returns "Document not read.".
pmazurk
User
Posts: 27
Joined: Tue Feb 22, 2011 10:25 pm

Re: PXC_AddPage does not increment page count

Post by pmazurk »

Walter - you hit the nail on the head! That was the problem and now things are humming along. I knew it was some little thing I overlooked.

Thanks for your help --
Walter-Tracker Supp
User
Posts: 381
Joined: Mon Jun 13, 2011 5:10 pm

Re: PXC_AddPage does not increment page count

Post by Walter-Tracker Supp »

pmazurk wrote:Walter - you hit the nail on the head! That was the problem and now things are humming along. I knew it was some little thing I overlooked.

Thanks for your help --
Happy to have helped. Any other problems, don't hesitate to contact us.

-Walter
Post Reply