是否可以使用iTextSharp以PDF格式加载XMP文件? [英] Is it possible to load XMP file in PDF using iTextSharp?

查看:167
本文介绍了是否可以使用iTextSharp以PDF格式加载XMP文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用acrobat分别拥有PDF文件和XMP文件我在PDF中加载XMP文件。

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

但是我想通过自动化来完成这个过程,那么有没有办法使用iTextSharp将XMP文件数据加载到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?

我在Acrobat中使用的进程加载XMP文件。

Process I am using in Acrobat to load XMP file.

< img src =https://i.stack.imgur.com/tNMi6.jpgalt =在此处输入图像说明>

推荐答案

你可以使用PdfStamper在现有PDF文件中设置XMP元数据:

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();

我看到你的屏幕截图显示附加。请注意,上面的代码会覆盖任何现有的XMP元数据。如果这不是你想要的,你必须首先从PdfReader获取现有元数据,将XML与其他XMP XML合并并设置合并的XMP。

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.

获取现有的XMP元数据:

Getting existing XMP metadata:

byte[] xmp = reader.Metadata;

这篇关于是否可以使用iTextSharp以PDF格式加载XMP文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆