Invalid Page Number when merging single pages

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for .NET (v7)  /  Invalid Page Number when merging page

DynamicPDF CoreSuite for .NET (v7) Forum

Hi,

my application works with a PDF-file with e.g. 20 pages, every page with different form fields in it.
The application has to extract 1 or more of these pages (depending on various parameters) and puts them together to a new PDF-file.

Simple example:

Dim mySource As MergeDocument = New MergeDocument("c:\temp\mySource.pdf") ' a lot of empty pages and 1 formfield on page 4
Dim myDest As MergeDocument = New MergeDocument
Dim myPage As New Page
myPage = mySource.Pages(3) ' 3 gives error "invalid page number" - the only page with form field on it, all other pages are OK
myDest.Pages.Add(myPage)
myDest.Draw("C:\temp\myDest.pdf")

Where is the mistake?

In the example, the form field is on page 4 in the source file but on page 1 in the destination.
Page 4 doesn't exist in the destination, so I think that's the error. You only get an error with pages having form fields.
But why doesn't the .Add-method rewrite the form field's page number?


Posted by a ceTe Software moderator
Hello,

Can you please send over the following details to our support team so that they can look into it further?

1.Input PDF (mySource.pdf) using which we can recreate the error.
2.Full error message along with stack trace.
3.Exact build number of the DynamicPDF DLL file. You can get this information in Visual Studio References properties (Description) of the DynamicPDF DLL file.

Thanks,
ceTe Software Support Team.
 Oct 12 2017 11:16 AM
Hello there,

Our system works with PDF package eg. 10 pages, and try to extract 1 or more of these pages based on business rule and puts them together to a new PDF-file.

Since remove() method is no longer supported,
In my application I create a new MergeDocument - mDocNew, and add only the necessary pages from the original MergeDocument - mDocOriginal. I get the "Invalid Page Number" errors when I try to run the statement "mDocNew.Draw(stream);";

Simple example:

                MergeDocument mDocNew = new MergeDocument();
                foreach (Page item in mDocOriginal.Pages)
                {
                    if (isNecessaryPage)
                    {
                        mDocNew.Pages.Add(item);
                    }
                }

                mDocNew.Draw(stream); //"Invalid Page Number"

Where is the mistake?
the stack trace is shown as below:
ceTe.DynamicPDF.GeneratorException: Invalid page number.
   at zz93.dd.GetPageObject(Int32 pageNumber)
   at zz93.d3.DrawDictionary(DocumentWriter writer)
   at ceTe.DynamicPDF.Forms.FormField.Draw(DocumentWriter writer)
   at ceTe.DynamicPDF.IO.DocumentResourceList.b(DocumentWriter A_0)
   at zz93.dd.Draw()
   at ceTe.DynamicPDF.Document.Draw(Stream stream)
   at EnfoTech.BizModule.EP.Engine.PDFGenerator.GeneratePDF(Stream stream, XmlNode mapper, XmlNode node, Hashtable ht)
   at EnSuite.Permit.UI.Util.AppUtil.GeneratePDF(SubmissionForm subFormObj, Form formObj, Hashtable imageHT)



Posted by a ceTe Software moderator
Hello,

Can you please send over the following details to support@cete.com so we can look into it further?

1. Input PDF (Source.pdf) using which we can recreate the error.
2. Exact version and build number of the DynamicPDF DLL file. You can get this information in project references properties (Version and Description fields) in Visual Studio..

Thanks,
ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 4:54 AM.