Quantcast
Viewing all articles
Browse latest Browse all 3131

Null Object Exception when Clearing PDF Info

Hi there,

I've come across what appears to be a fundamental issue with the PDF library, unless I am using it wrong, but the documentation on this seems lacking so I'm not too sure.

I'm attempting to clear the document properties of a PDF file before applying my own at a later time, the issue at present is that I am getting a NULL Object exception when I try and call the ClearInfo() method from the PdfFileInfo variable.

After taking a look through what little documentation I can find, there is nothing to show how I can check for the presence of this metadata so there seems to be little I can do to prevent this error from being thrown, that being said, I would have imagined this should be better handled within the PDF library itself?

I've attached the document in question and my sample code is below for replicating, can someone take a look into this and let me know if there is a way to resolve this.

Many thanks

----------

namespace PDFNullException
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                var lic = new License();
                lic.SetLicense("Aspose.Total.lic");

                Document pdf = new Document(@"C:\Users\Jak\Documents\DocumentClassifier\test.pdf");

                PdfFileInfo fi = new PdfFileInfo();
                fi.BindPdf(pdf);
                fi.ClearInfo();
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.ReadKey();
            }
        }
    }
}

Viewing all articles
Browse latest Browse all 3131

Trending Articles