开发者

Retrieving the URL properties of an image within a PDF

I am trying to use itext to find an image within a pdf based on its URL. I know that when a pdf is composed in Adobe designer, that you can set its 'URL' from which the image is loaded. When the same pdf is opened again, the URL is preserved on the Image, so I know that that URL is preserved within the pdf. However, I cant seem to see anywhere where the URL is made available to itext.

Even if you iterate through all the objects and find an image object using the code below.

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

then iterate through the 'dictionary' values of the object:

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

You can find the image objects inserted by Adobe Designer, but the objects dont have a URL item/property on th开发者_C百科em, even though the URL is obviously stored in the pdf file.

Can anyone offer insight here?

Thanks. Scott.


I imagine the URL is stored in the XFA somewhere.

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

Oops. That's Java. For C#, it'll be quite similar, only the return type from getDomDocument() would be an XmlDocument.

EDIT: IIRC, LiveCycle Designer will let you look at your form as an XML doc, so you should be able to easily determine an XPath expression to extract the image URL.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜