private List<PDFDictionary> attributes;
+ /**
+ * Creates PDFStructElem with no entries.
+ */
+ public PDFStructElem() {
+ }
+
/**
* Creates a new structure element.
*
}
}
+ public void addKidInSpecificOrder(int position, PDFStructElem kid) {
+ if (kids == null) {
+ addKid(kid);
+ } else {
+ if ((kids.size() - 1) < position) {
+ kids.add(kid);
+ } else if (kids.get(position) == null) {
+ kids.set(position, kid);
+ } else {
+ if (!kids.contains(kid)) {
+ kids.add(position, kid);
+ }
+ }
+ }
+ }
+
/**
* Attaches all valid kids to the kids array.
*
attributes.add(attribute);
}
+ public List<PDFObject> getKids() {
+ return this.kids;
+ }
+
/**
* Class representing a placeholder for a PDF Structure Element.
*/
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.AffineTransform;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashSet;
import java.util.Locale;
import org.w3c.dom.Document;
+import org.apache.xmlgraphics.image.loader.ImageException;
+import org.apache.xmlgraphics.image.loader.ImageInfo;
+import org.apache.xmlgraphics.image.loader.ImageManager;
+import org.apache.xmlgraphics.image.loader.ImageSessionContext;
+
+import org.apache.fop.ResourceEventProducer;
import org.apache.fop.fonts.Font;
import org.apache.fop.fonts.FontTriplet;
import org.apache.fop.fonts.LazyFont;
placeImage(rect, xobject);
}
} else {
- if (accessEnabled) {
- PDFStructElem structElem = (PDFStructElem) getContext().getStructureTreeElement();
- prepareImageMCID(structElem);
- }
drawImageUsingURI(uri, rect);
if (!getDocumentHandler().getPDFDocument().isLinearizationEnabled()) {
flushPDFDoc();
}
}
+ @Override
+ protected void drawImageUsingURI(String uri, Rectangle rect) {
+ ImageManager manager = getUserAgent().getImageManager();
+ ImageInfo info = null;
+ try {
+ ImageSessionContext sessionContext = getUserAgent().getImageSessionContext();
+ info = manager.getImageInfo(uri, sessionContext);
+ if (accessEnabled) {
+ PDFStructElem structElem = (PDFStructElem) getContext().getStructureTreeElement();
+ String mimeType = info.getMimeType();
+ if (!mimeType.equalsIgnoreCase("application/pdf")) {
+ prepareImageMCID(structElem);
+ }
+ }
+ drawImageUsingImageHandler(info, rect);
+ } catch (ImageException ie) {
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.imageError(this, (info != null ? info.toString() : uri), ie, null);
+ } catch (FileNotFoundException fe) {
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.imageNotFound(this, (info != null ? info.toString() : uri), fe, null);
+ } catch (IOException ioe) {
+ ResourceEventProducer eventProducer = ResourceEventProducer.Provider.get(
+ getUserAgent().getEventBroadcaster());
+ eventProducer.imageIOError(this, (info != null ? info.toString() : uri), ioe, null);
+ }
+ }
+
private void prepareImageMCID(PDFStructElem structElem) {
imageMCI = logicalStructureHandler.addImageContentItem(structElem);
if (structElem != null) {
getUserAgent(), generator, getDocumentHandler().getCurrentPage(), getFontInfo());
pdfContext.setMarkedContentInfo(imageMCI);
pdfContext.setPageNumbers(getDocumentHandler().getPageNumbers());
+ pdfContext.setPdfLogicalStructureHandler(logicalStructureHandler);
+ pdfContext.setCurrentSessionStructElem((PDFStructElem) getContext().getStructureTreeElement());
return pdfContext;
}
import org.apache.fop.fonts.FontInfo;
import org.apache.fop.pdf.PDFArray;
import org.apache.fop.pdf.PDFPage;
+import org.apache.fop.pdf.PDFStructElem;
import org.apache.fop.render.AbstractRenderingContext;
import org.apache.fop.render.pdf.PDFLogicalStructureHandler.MarkedContentInfo;
private PDFPage page;
private MarkedContentInfo mci;
private Map<Integer, PDFArray> pageNumbers;
+ private PDFLogicalStructureHandler pdfLogicalStructureHandler;
+ private PDFStructElem currentSessionStructElem;
/**
* Main constructor.
public void setPageNumbers(Map<Integer, PDFArray> pageNumbers) {
this.pageNumbers = pageNumbers;
}
+
+ public PDFLogicalStructureHandler getPdfLogicalStructureHandler() {
+ return pdfLogicalStructureHandler;
+ }
+
+ public void setPdfLogicalStructureHandler(PDFLogicalStructureHandler pdfLogicalStructureHandler) {
+ this.pdfLogicalStructureHandler = pdfLogicalStructureHandler;
+ }
+
+ public PDFStructElem getCurrentSessionStructElem() {
+ return currentSessionStructElem;
+ }
+
+ public void setCurrentSessionStructElem(PDFStructElem currentSessionStructElem) {
+ this.currentSessionStructElem = currentSessionStructElem;
+ }
}