Patagames Software Support Forum
»
Pdfium.Net SDK
»
Bug Report & Technical Support
»
ImportPages fails with PdfFileNotFoundException (and sometimes unexpected error code)
Rank: Newbie
Groups: Registered
Joined: 6/4/2019(UTC) Posts: 1
|
Hello, I am trying to split a specific page to its own pdf file. When doing this I get an exception from Pdfium that tells me that the pdf file is not found and sometimes I get an exception that tells me that its an unexpected error code (same code running multiple time through a unit test and always the exception is on ImportPages) I did come to the conclusion that the problem occures when I try to split a page that is empty (but still there). So for example I have a PDF with two pages and the first page have objects but the second page is empty. (It works if I take the first page, but not the last page that is empty) The code I am using for the split are looking like this: Code:
public void RenderPageAsPdf(Stream targetStream, int pageNumber)
{
var zeroIndexedPageNumber = pageNumber - 1;
using (var page = _document.Pages[zeroIndexedPageNumber])
{
using (var document = Patagames.Pdf.Net.PdfDocument.CreateNew())
{
document.Pages.ImportPages(_document, pageNumber.ToString(), 0);
document.Save(targetStream, SaveFlags.Incremental);
}
}
}
Does anyone have any suggestion on how I can solve this issue? Thanks in advance! Edited by user Tuesday, June 4, 2019 7:11:15 AM(UTC)
| Reason: Not specified
|
|
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 6/11/2019(UTC) Posts: 2 
|
Hello MikaelJohansson,
if your page number is beyond 65535 (2^16-1), you will get the error message "unexpected error code". I suspect that this is only one of several possible reasons for this error message.
But it's the case I'm currently running into with my big document.
Regards
Daniel
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,138
Thanks: 10 times Was thanked: 133 time(s) in 130 post(s)
|
Originally Posted by: MikaelJohansson  I did come to the conclusion that the problem occures when I try to split a page that is empty (but still there). Could you please try it on the latest version of SDK? If the problem is still there, could you provide your PDF file and code for analysis. Edited by user Friday, June 14, 2019 2:26:45 AM(UTC)
| Reason: Not specified
|
|
|
|
|
|
Patagames Software Support Forum
»
Pdfium.Net SDK
»
Bug Report & Technical Support
»
ImportPages fails with PdfFileNotFoundException (and sometimes unexpected error code)
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