We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Cannot add metadata to a .pdf document

Dear experts,

I am trying to add metadata to a .pdf document:

        Dim pdfDocument As Document = New Document(destFilePath)
        pdfDocument.Metadata("SomeKey") = Date.Now.ToString
        pdfDocument.Save(destFilePath)

On executing pdfDocument.Metadata(“SomeKey”)… an exception is thrown: Key is not valid.
Could you please explain what is wrong?

Thanks.

@dpreznik

Thank you for contacting support.

Please visit PDF File Metadata for your kind reference and then share your kind feedback with us.

We hope this will be helpful. Please feel free to contact us if you need any further assistance.

@Farhan.Raza

Thank you very much. This works. But the metadata added can be viewed only in Adobe Acrobat Pro. Is it possible to make it visible in simple Adobe Reader?

Thanks again.

@dpreznik

Thank you for contacting support.

We are glad to know that things worked in your environment. About viewing metadata, we are afraid Adobe Reader does not support viewing it. If you are able to add metadata to any PDF file with Adobe Acrobat, and see it with Adobe Reader then please share that PDF file with us, we will investigate further in that case.

I am just surprised that I tried another 3rd party NuGet package (Spire.PDF), and was able to add metadata and view it in File/Properties/Custom in the Reader.

@dpreznik

Thank you for elaborating it further.

We have noticed that you are trying to add custom properties in a PDF document. Please try using below code snippet in your environment and then share your kind feedback with us.

        Document document = new Document(dataDir + "Test.pdf");
        // Specify document information
        DocumentInfo docInfo = new DocumentInfo(document);
        docInfo.Add("Aspose", "Farhan");
        // Save PDF
        document.Save(dataDir + "Test_18.9.1.pdf", SaveFormat.Pdf);

We hope this will be helpful. Please feel free to contact us if you need any further assistance.

Thanks! That does the trick!