import org.apache.fop.afp.modca.PresentationTextObject;
import org.apache.fop.afp.ptoca.PtocaBuilder;
import org.apache.fop.afp.ptoca.PtocaProducer;
-import org.apache.fop.afp.util.DefaultFOPResourceAccessor;
-import org.apache.fop.afp.util.ResourceAccessor;
+import org.apache.fop.afp.util.AFPResourceAccessor;
import org.apache.fop.fonts.Font;
- import org.apache.fop.fonts.FontInfo;
import org.apache.fop.fonts.FontTriplet;
import org.apache.fop.fonts.Typeface;
import org.apache.fop.render.RenderingContext;
//Do we need to embed an external page segment?
if (pageSegment.getURI() != null) {
- ResourceAccessor accessor = new DefaultFOPResourceAccessor (
- getUserAgent(), null, null);
+ AFPResourceAccessor accessor = new AFPResourceAccessor(
- documentHandler.getUserAgent().getResourceResolver());
++ getDocumentHandler().getUserAgent().getResourceResolver());
try {
URI resourceUri = new URI(pageSegment.getURI());
- documentHandler.getResourceManager().createIncludedResourceFromExternal(
+ getDocumentHandler().getResourceManager().createIncludedResourceFromExternal(
pageSegment.getName(), resourceUri, accessor);
} catch (URISyntaxException urie) {
import org.apache.fop.ResourceEventProducer;
import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.apps.FopFactory;
import org.apache.fop.fo.Constants;
+ import org.apache.fop.fonts.FontInfo;
+ import org.apache.fop.fonts.FontTriplet;
import org.apache.fop.render.ImageHandler;
import org.apache.fop.render.ImageHandlerRegistry;
import org.apache.fop.render.ImageHandlerUtil;
final int letterSpacing, final int wordSpacing, final int[][] dp,
final String text, FontTriplet triplet) throws IFException {
//Use Java2D to paint different fonts via bitmap
- final Font font = parent.getFontInfo().getFontInstance(triplet, state.getFontSize());
+ final Font font = getFontInfo().getFontInstance(triplet, state.getFontSize());
//for cursive fonts, so the text isn't clipped
- final FontMetricsMapper mapper = (FontMetricsMapper) getFontInfo().getMetricsFor(
- font.getFontName());
+ FontMetricsMapper mapper;
+ try {
- mapper = (FontMetricsMapper)parent.getFontInfo().getMetricsFor(
- font.getFontName());
++ mapper = (FontMetricsMapper) getFontInfo().getMetricsFor(font.getFontName());
+ } catch (Exception t) {
+ throw new RuntimeException(t);
+ }
final int maxAscent = mapper.getMaxAscent(font.getFontSize()) / 1000;
final int ascent = mapper.getAscender(font.getFontSize()) / 1000;
final int descent = mapper.getDescender(font.getFontSize()) / 1000;
* Utility class which enables all sorts of features that are not directly connected to the
* normal rendering process.
*/
- protected final PDFRenderingUtil pdfUtil;
- private PDFRenderingUtil pdfUtil;
++ private final PDFRenderingUtil pdfUtil;
/** the /Resources object of the PDF document being created */
- protected PDFResources pdfResources;
+ private PDFResources pdfResources;
/** The current content generator */
- protected PDFContentGenerator generator;
-
- /** the current annotation list to add annotations to */
- protected PDFResourceContext currentContext;
+ private PDFContentGenerator generator;
/** the current page to add annotations to */
- protected PDFPage currentPage;
+ private PDFPage currentPage;
/** the current page's PDF reference */
- protected PageReference currentPageRef;
+ private PageReference currentPageRef;
/** Used for bookmarks/outlines. */
- protected Map<Integer, PageReference> pageReferences = new HashMap<Integer, PageReference>();
+ private Map<Integer, PageReference> pageReferences = new HashMap<Integer, PageReference>();
private final PDFDocumentNavigationHandler documentNavigationHandler
= new PDFDocumentNavigationHandler(this);
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentBoundingBox;
import org.apache.xmlgraphics.ps.dsc.events.DSCCommentHiResBoundingBox;
-import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.MimeConstants;
+import org.apache.fop.apps.io.TempResourceURIGenerator;
import org.apache.fop.render.intermediate.AbstractBinaryWritingIFDocumentHandler;
import org.apache.fop.render.intermediate.IFContext;
+ import org.apache.fop.render.intermediate.IFDocumentHandler;
import org.apache.fop.render.intermediate.IFDocumentHandlerConfigurator;
import org.apache.fop.render.intermediate.IFException;
import org.apache.fop.render.intermediate.IFPainter;
* Utility class which enables all sorts of features that are not directly connected to the
* normal rendering process.
*/
- protected PSRenderingUtil psUtil;
+ private PSRenderingUtil psUtil;
/** The PostScript generator used to output the PostScript */
- protected PSGenerator gen;
+ PSGenerator gen;
/** the temporary file in case of two-pass processing */
- private File tempFile;
+ private URI tempURI;
+ private static final TempResourceURIGenerator TEMP_URI_GENERATOR
+ = new TempResourceURIGenerator("ps-optimize");
private int currentPageNumber = 0;
private PageDefinition currentPageDefinition;
return MimeConstants.MIME_POSTSCRIPT;
}
- /** {@inheritDoc} */
- public void setContext(IFContext context) {
- super.setContext(context);
- FOUserAgent userAgent = context.getUserAgent();
- this.psUtil = new PSRenderingUtil(userAgent);
- eventProducer = PSEventProducer.Provider.get(userAgent.getEventBroadcaster());
- }
-
+ PSGenerator getGenerator() {
+ return gen;
+ }
+
/** {@inheritDoc} */
public IFDocumentHandlerConfigurator getConfigurator() {
- return new PSRendererConfigurator(getUserAgent());
+ return new PSRendererConfigurator(getUserAgent(), new PSRendererConfigParser());
}
PSRenderingUtil getPSUtil() {