Patagames Software Support Forum
»
Pdfium.Net SDK
»
Bug Report & Technical Support
»
PdfDocument.Pages.ImportPages does not support ranges beyond page index 65535
Rank: Newbie
Groups: Registered
Joined: 6/11/2019(UTC) Posts: 2 
|
Hello support, I was trying to import pages from a big document into a new one (in C#): Code:
var newDocument = PdfDocument.CreateNew();
// 'pdfDocument' contains more than 70.000 pages.
// This works:
newDocument.Pages.ImportPages(pdfDocument, "65535-65535", 0);
// This does not work:
newDocument.Pages.ImportPages(pdfDocument, "65536-65536", 0);
I'm wondering about this 2^16-1 limit (unsigned short) as the property PdfPageCollection.Count is an integer (2^31-1). This error occurs in the current version 4.7.2704. The callstack given by the second code fragment is: Patagames.Pdf.Net.Exceptions.PdfiumException: Unexpected error code. bei Patagames.Pdf.Pdfium.ProcessLastError() bei Patagames.Pdf.Net.PdfPageCollection.ImportPages(PdfDocument sourceDoc, String pagerange, Int32 index) Is this a known bug and a workaround or fix available? Regards & thanks in advance Daniel Edited by user Tuesday, June 11, 2019 6:17:44 AM(UTC)
| Reason: Not specified
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,138
Thanks: 10 times Was thanked: 133 time(s) in 130 post(s)
|
The Pdfium's import procedure contains a two-byte array where is stored the ordianl numbers of pages labeled to import. So the maximum ordinal number of the page that can be processed by the import procedure is 65535. I can suggest the another way to achieve your goals. You import first 655355 pages, and delete these pages. For example, if you have import the first 65,535 pages, then you can delete them from the original document, and save it as copy. Thus the page with ordinal number 65536 will become the first page of the new document and you will be able to access to the next 65535 pages.
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,138
Thanks: 10 times Was thanked: 133 time(s) in 130 post(s)
|
Here is an example Code:using(var srcDoc = PdfDocument.Load(@"e:\test.pdf"))
{
using(var dstDoc = PdfDocument.CreateNew())
{
int cnt = srcDoc.Pages.Count; //70 000 pages in the test document
for (int i = 0; i < cnt; i++)
{
dstDoc.Pages.ImportPages(srcDoc, "1", i);
srcDoc.Pages.DeleteAt(0);
Console.WriteLine($"Import page {i+1}");
}
dstDoc.Save(@"e:\test_copy.pdf", SaveFlags.NoIncremental);
}
}
Edited by user Tuesday, August 27, 2019 8:40:13 AM(UTC)
| Reason: Not specified
|
|
|
|
|
|
Patagames Software Support Forum
»
Pdfium.Net SDK
»
Bug Report & Technical Support
»
PdfDocument.Pages.ImportPages does not support ranges beyond page index 65535
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close