Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Thu Nov 16, 2017 8:09 pm

Hi,
I am trying to evaluate the Spire.PDF package, and I seem to be running into an exception when checking to see if the ImagesInfo property of a valid instance of a PdfPageBase is null. Instead of actually returning null, as expected, it throws a null Reference Exception when the PdfPageBase is from a pdf that is new or in memory. For an existing pdf, however, it works fine and returns either a null value or the data present. Please see the code below for an example.

Code: Select all
            foreach (PdfPageBase page in doc.Pages)
            {
                if (page != null)
                {
                    try
                    {
                        //The following line is where the exception is thrown 100% of the time in a new file even when data is added
                        if (page.ImagesInfo != null)
                        {
                            foreach (PdfImageInfo info in page.ImagesInfo)
                            {
                                page.TryCompressImage(info.Index);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        //This is because SpirePDF seems to throw an exception when ImagesInfo is null, instead of just returning null.
                    }
                }
            }


Any help would be greatly appreciated. Thanks!

VBonanni
 
Posts: 1
Joined: Thu Nov 16, 2017 8:02 pm

Fri Nov 17, 2017 2:51 am

Hello,

Thanks for your inquiry. As per my understanding, you want to insert image and then compress the PDF. I am sorry the compressing function doesn't support it, it only support to compress the existing PDF. We apologize for the inconvenience.
On the other hand, I have posted the ArgumentNullException issue to our DEV team. If there is any update, we will inform you.

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Fri Jan 19, 2018 9:51 am

Hello,

Glad to inform you that the issue of ArgumentNullException has been resolved. Welcome to download Spire.PDF Pack(Hot Fix) Version:3.9.604.

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Tue Jan 23, 2018 8:09 am

Hello,

Greeting from E-iceblue.
Has the hotfix resolved your issue?
Your feedback will be greatly appreciated.

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Thu Mar 29, 2018 10:10 am

Hello.

I'm trying to compress a PDF created by Spire.PDF. I'm using the code below with the latest hot fix 4.3.14, I got the exception
ImagesInfo = 'page.ImagesInfo' threw an exception of type 'System.FormatException'.

What I'm doing wrong?

private void CompressImagesInPDF(string FileName)
{
PdfDocument pdfDoc = new PdfDocument(FileName);
pdfDoc.FileInfo.IncrementalUpdate = false;

foreach (PdfPageBase page in pdfDoc.Pages)
{
if (page != null)
{
if (page.ImagesInfo != null)
{
foreach (PdfImageInfo info in page.ImagesInfo)
{
page.TryCompressImage(info.Index);
}
}
}
}
}

hahne
 
Posts: 1
Joined: Thu Feb 15, 2018 9:15 am

Fri Mar 30, 2018 3:34 am

Hello,

Thanks for your post. After an initial test, I was unable to reproduce the issue. To help us investigate it, would you please share us with your input Pdf file? You could zip it and attach here or send to support@e-iceblue.com.

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Mon Apr 02, 2018 8:41 am

Hello,

Greeting from E-iceblue.
How is the issue going?
We will appreciate it if you could give us some feedback.

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Wed Apr 04, 2018 10:12 am

Hello,

I have received your document with your email. After an initial test with the latest version(Spire.PDF Pack(Hot Fix) Version:4.4.0), I was unable to reproduce the issue. Please use the version and try again. If the issue still exists after trying, please share us the OS information and region language setting of your machine.

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Fri Apr 13, 2018 10:03 am

Hello hahne,

Glad to inform you that the issue has been fixed. Welcome to download Spire.PDF Pack(Hot Fix) Version:4.4.6.
You will not encounter the issue even if removing the code of 'InvariantCulture'.

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Return to Spire.PDF