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.

Sun Oct 01, 2023 11:35 am

Hello!

Please advise if it's possible to edit XMP metadata in an existing PDF file? I've found a solution for Spire.PDF for .NET but what about Java?
We are using Spire.PDF for Java v9.2.5

Thank you.

IvanTovbin
 
Posts: 4
Joined: Thu Feb 16, 2023 11:30 pm

Mon Oct 02, 2023 5:34 am

Hello,

Thank you for your inquiry.
Please use the following code to implement your requirements.
Code: Select all
PdfDocument doc = new PdfDocument();
doc.loadFromFile("test.pdf");
doc.getDocumentInformation().setAuthor("E-iceblue");
doc.getDocumentInformation().setCreator("Spire.PDF");
doc.getDocumentInformation().setCustomProperty("Field", "NewValue");
doc.getDocumentInformation().setKeywords("XMP");
doc.getDocumentInformation().setProducer("E-icenlue Co,.Ltd");
doc.getDocumentInformation().setSubject("XMP Metadata");
doc.getDocumentInformation().setTitle("Set XMP Metadata in PDF");
doc.saveToFile("result.pdf");

Best regards,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Mon Oct 02, 2023 7:21 am

Annika.Zhou wrote:Hello,

Thank you for your inquiry.
Please use the following code to implement your requirements.
Code: Select all
PdfDocument doc = new PdfDocument();
doc.loadFromFile("test.pdf");
doc.getDocumentInformation().setAuthor("E-iceblue");
doc.getDocumentInformation().setCreator("Spire.PDF");
doc.getDocumentInformation().setCustomProperty("Field", "NewValue");
doc.getDocumentInformation().setKeywords("XMP");
doc.getDocumentInformation().setProducer("E-icenlue Co,.Ltd");
doc.getDocumentInformation().setSubject("XMP Metadata");
doc.getDocumentInformation().setTitle("Set XMP Metadata in PDF");
doc.saveToFile("result.pdf");

Best regards,
Annika
E-iceblue support team


Dear Annika,

Will the above also update XMP schema inside a PDF? Thank you.

IvanTovbin
 
Posts: 4
Joined: Thu Feb 16, 2023 11:30 pm

Mon Oct 02, 2023 7:33 am

Hello,

Thank you for your feedback.
Yes, it will be updated.
If you have any other questions or concerns, please feel free to contact us anytime.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.PDF