【问题标题】:Retrieving the URL properties of an image within a PDF检索 PDF 中图像的 URL 属性
【发布时间】:2011-07-02 13:20:25
【问题描述】:

我正在尝试使用 itext 根据其 URL 在 pdf 中查找图像。 我知道在 Adob​​e 设计器中编写 pdf 时,您可以设置加载图像的“URL”。 当再次打开相同的 pdf 时,URL 会保留在图像上,所以我知道该 URL 会保留在 pdf 中。但是,我似乎无法在任何地方看到该 URL 可用于 itext。

即使您遍历所有对象并使用以下代码找到图像对象。

iTextSharp.text.pdf.PdfReader reader = new iTextSharp.text.pdf.PdfReader(path);
iTextSharp.text.pdf.PdfObject pdfObject = reader.GetPdfObject(objectIndex);

然后遍历对象的“字典”值:

PdfDictionary pdx=(PdfDictionary)pdfObject;
foreach(PdfName name in pdx.Keys)
{
    string value = pdx.Get(name).ToString();
    Debug.WriteLine("Object at index " + objectIndex + " has dict item " + name + " of value " + value);
}

您可以找到 Adob​​e Designer 插入的图像对象,但对象上没有 URL 项/属性,即使 URL 显然存储在 pdf 文件中。

谁能在这里提供见解?

谢谢。 斯科特。

【问题讨论】:

    标签: c# image url itextsharp


    【解决方案1】:

    我想 URL 存储在 XFA 的某个地方。

    org.w3c.dom.Document xfaDOM = myReader.getAcroFields().getXfa().getDomDocument();
    String imgURL = magicallyExtractImageUrlfromDOM( xfaDOM );
    

    哎呀。那是Java。对于 C#,它会非常相似,只是 getDomDocument() 的返回类型是 XmlDocument

    编辑:IIRC,LiveCycle Designer 将让您将表单视为 XML 文档,因此您应该能够轻松确定 XPath 表达式以提取图像 URL。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-13
      • 2016-03-22
      • 1970-01-01
      • 1970-01-01
      • 2011-09-19
      相关资源
      最近更新 更多