logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
MikaelJohansson  
#1 Posted : Tuesday, June 4, 2019 7:18:59 AM(UTC)
MikaelJohansson

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 10:11:15 AM(UTC)  | Reason: Not specified

DaLu  
#2 Posted : Tuesday, June 11, 2019 10:32:00 AM(UTC)
DaLu

Rank: Newbie

Groups: Registered
Joined: 6/11/2019(UTC)
Posts: 2
Germany

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
Paul Rayman  
#3 Posted : Friday, June 14, 2019 5:24:54 AM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 743

Thanks: 1 times
Was thanked: 90 time(s) in 89 post(s)
Originally Posted by: MikaelJohansson Go to Quoted Post
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 5:26:45 AM(UTC)  | Reason: Not specified

Users browsing this topic
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.