Is it possible to load XMP file in PDF using iTextSharp?

陌路散爱 提交于 2019-12-22 09:20:02

问题


I am having PDF file and XMP file separately by using acrobat I am loading the XMP file in the PDF.

But I want to do this process by automation, so is there is any way to load the XMP file data into PDF file using iTextSharp?

Process I am using in Acrobat to load XMP file.


回答1:


You can set XMP metadata in an existing PDF file using PdfStamper:

PdfReader reader = new PdfReader("in.pdf");
PdfStamper stamper = new PdfStamper(reader, new FileStream("out.pdf", FileMode.Create));
byte[] xmp;
// read xmp file
stamper.XmpMetadata = xmp;
stamper.Close();

I see your screen shot says "Append". Note that the code above overwrites any existing XMP metadata. If that's not what you want, you'd have to get the existing metadata from the PdfReader first, merge the XML with the additional XMP XML and set the merged XMP.

Getting existing XMP metadata:

byte[] xmp = reader.Metadata;


来源:https://stackoverflow.com/questions/20284602/is-it-possible-to-load-xmp-file-in-pdf-using-itextsharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!