Q: I have problems finding images in some PDF documents.
I look for images on a given page as follows, but the image is not
found.
while ((element = reader.Next()) != null) { // Read page contents
pdftron.PDF.Element.Type te = element.GetType();
if (element.GetType() == Element.Type.e_image) {
...
}
}
Can you tell me how I should iterate on the pdf content in order to
access the image?
------
A: The problem is that the image is stored in a child Form XObject
(i.e. an element of type e_form). A Form XObject is a collection of
'Elements' that can be referenced from one or more pages. You can
process e_form element as illustrated in ElementReader and
ElementReaderAdv sample projects: http://www.pdftron.com/net/samplecode.html#ElementReader
void ProcessElementList(ElementReader reader) {
while ((element = reader.Next()) != null) { // Read page contents
pdftron.PDF.Element.Type te = element.GetType();
if (element.GetType() == Element.Type.e_image) {
...
}
else if (element.GetType() == Element.Type.e_form) {
reader.FormBegin();
ProcessElementList(reader); ... // this is typically a recursive
call.
reader.End();
}
}
}