Free Support Forum - aspose.com

Document.Metadata - Object Reference Not Set

I’m using the evaluation version of Aspose.Pdf 7.4. (I tried doing this without success using a registered copy of Aspose.Pdf 4.6).


When I attempt to set custom metadata on the server, I’m receiving an Object Reference Not Set error.

The PDFDocument appears to have loaded correctly. I can see the page count is correct, but when I reference pdfDocment.Metadata, I receive the object reference not set error.

[NullReferenceException: Object reference not set to an instance of an object.]
Aspose.Pdf.Metadata.RegisterNamespaceUri(String prefix, String namespaceUri) +24
Aspose.Pdf.Metadata.set_Item(Object key, Object value) +60
DownloadAgenda.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object state) in D:\AppDev\Apps\AgendaMan\AgendamanUI\Public\DownloadAgenda.ashx:159
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8691986
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

? pdfDocument.Metadata
{Aspose.Pdf.Metadata}
Count: {“Object reference not set to an instance of an object.”}
IsFixedSize: False
IsReadOnly: False
IsSynchronized: True
Item: In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user.
Keys: {“Object reference not set to an instance of an object.”}
SyncRoot: {Object}
Values: {“Object reference not set to an instance of an object.”}

Is there any way to diagnose what’s going wrong?

Hi Dan,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for using our product.

Please share your template PDF file with us to help us reproduce the issue at our end. We will look into it and get back to you soon.

Sorry for the inconvenience,

Here’s a test file, but I’m thinking the issue centers more around deployment than around the file itself. I’ve tested this on my local machine and a development server. The pdf is created on-the-fly by identical code. I know that the Aspose.PDF 4.6 libraries deployed fine originally, I’m only trying the 7.4 evaluation version because they don’t seem to write the XMP metadata in a format that’s useable by IFilterShop’s PDF+ IFilter.

Here’s some more information - I’ve written a powershell script to load the assembly and modify the XMP data there. It seems to work in that context.


Here’s what’s happening in ASP.NET while debugging interactively.

After loading the PDF (pdfDocument = new Aspose.Pdf.Document(inputFileName) )
? pdfDocument
{Aspose.Pdf.Document}
Actions: {Aspose.Pdf.InteractiveFeatures.DocumentActionCollection}
Background: “{Name=ffffffff, ARGB=(255, 255, 255, 255)}”
CenterWindow: False
Collection: Nothing
CryptoAlgorithm: Nothing
Direction: L2R {0}
DisplayDocTitle: False
EmbeddedFiles: {Aspose.Pdf.Collection}
FileName: “D:\AppDev\Apps\AgendaMan\AgendamanUI_temp\toPrint\Test_Agenda_3578_723265510.pdfc3891bc3-3656-43ca-8d22-acbea3260656”
FitWindow: False
Form: {Aspose.Pdf.InteractiveFeatures.Forms.Form}
HideMenubar: False
HideToolBar: False
HideWindowUI: False
Id: {Aspose.Pdf.Id}
IgnoreCorruptedObjects: True
Info: Count = 2
IsEncrypted: False
IsLinearized: False
LogicalStructure: {“Object reference not set to an instance of an object.”}
Metadata: {Aspose.Pdf.Metadata}
NonFullScreenPageMode: UseNone {0}
OpenAction: {“Object reference not set to an instance of an object.”}
OptimizeSize: False
Outlines: {Aspose.Pdf.OutlineCollection}
PageLayout: SinglePage {0}
PageMode: UseNone {0}
Pages: {Aspose.Pdf.PageCollection}
Permissions: 3068
Version: “1.5”

Here’s the powershell script I’m using to test the document:

[Reflection.Assembly]::LoadFile(“C:\temp\Aspose.Pdf.dll”)
$doc = New-Object -TypeName Aspose.Pdf.Document -ArgumentList “C:\temp\Test_Agenda_3578_618181876.pdf”

$doc


--------------------------------------------------------------------

This is the output for the above attached file (note: version is the .NET Framework Version - the file details for Aspose.PDF.dll are fileversion: 7.4.0.0 and Product Version: 2012.09.28.0:

PS D:\AppDev\Apps\AgendaMan\AgendamanUI\bin> C:\Users\dshookowsky\PDFXmp.ps1

GAC Version Location
— ------- --------
False v2.0.50727 C:\temp\Aspose.Pdf.dll
Object reference not set to an instance of an object.
+ CategoryInfo : NotSpecified: (:slight_smile: [format-default], NullReferenceException
+ FullyQualifiedErrorId : System.NullReferenceException,Microsoft.PowerShell.Commands.FormatDefaultCommand


Hi Dan,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for sharing the template file and details.

I am able to reproduce your mentioned issue after an initial test using your template file. Your issue has been registered in our issue tracking system as PDFNEWNET-34481. We will notify you via this forum thread regarding any updates against your issue.

Sorry for the inconvenience,

I’ve corrected this problem on my side by writing metadata prior to combining other PDFs and Compressing the document. I still don’t know why it worked correctly on one platform and not another.

Hi Dan,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Please share your system environments i.e. OS, .NET Framework, 32 bit or 64 bit machines on which you are testing the issue. This will help us figure out the cause of the issue soon.

Sorry for the inconvenience,

The issues you have found earlier (filed as PDFNEWNET-34481) have been fixed in Aspose.Pdf for .NET 8.0.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.