PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 10:13 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Sun Dec 05, 2021 8:59 pm 
Offline

Joined: Sun Dec 05, 2021 8:43 pm
Posts: 1
I am using PDFsharp version 1.50.4740.0 (copyrighted 2005-2017 in the DLL file).

The simple C# code below is supposed to load a PDF, copy it (one page at a time), and save the result. It has worked well in the past; I use a more complex version to shorten PDFs by removing some pages.

However, with one particular PDF file (attached), it fails with an assertion failure, saying "Should not come here". You can see the error text screenshotted here (it's very long and I don't know how to copy text from that message box):
https://github.com/empira/PDFsharp/issues/152

Does this assertion failure indicate a bug in PDFsharp?
What is the real problem and how can I resolve it? Thanks.

Code:
using System;
using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;

namespace PdfTest
{
    static class Program
    {
        [STAThread]
        static void Main()
        {
            string inFile = @"C:\Users\home\Desktop\2304.pdf";
            string outFile = @"C:\Users\home\Desktop\output.pdf";

            int start = 1, end = 2; // we know it has exactly 2 pages

            using (PdfDocument src = PdfReader.Open(inFile, PdfDocumentOpenMode.Import))
            {
                using (PdfDocument dst = new PdfDocument())
                {
                    for (int i = start; i <= end; i++)
                    {
                        dst.Pages.Add(src.Pages[i - 1]);
                    }

                    dst.Save(outFile);
                }
            }
        }
    }
}


Top
 Profile  
Reply with quote  
PostPosted: Tue Dec 21, 2021 1:09 am 
Offline

Joined: Thu Apr 23, 2015 2:08 am
Posts: 6
I just started seeing this same message recently when I run my application that performs a similar type of function.
It seems like the PDF is still being compiled properly even with the error messages (I just kept clicking "Ignore").

I updated my PDFSharp library to 1.51.5185 (3/4/2019) and now it runs without errors.

Hope that helps.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 47 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group