configurator.configure(graphics, effCfg);
} else {
graphics.setupDefaultFontInfo();
}
} catch (Exception e) {
throw new TranscoderException(
"Error while setting up PDFDocumentGraphics2D", e);
}
super.transcode(document, uri, output);
if (getLogger().isTraceEnabled()) {
getLogger().trace("document size: " + width + " x " + height);
}
// prepare the image to be painted
UnitProcessor.Context uctx = UnitProcessor.createContext(ctx,
document.getDocumentElement());
float widthInPt = UnitProcessor.userSpaceToSVG(width, SVGLength.SVG_LENGTHTYPE_PT,
UnitProcessor.HORIZONTAL_LENGTH, uctx);
int w = (int)(widthInPt + 0.5);
float heightInPt = UnitProcessor.userSpaceToSVG(height, SVGLength.SVG_LENGTHTYPE_PT,
UnitProcessor.HORIZONTAL_LENGTH, uctx);
int h = (int)(heightInPt + 0.5);
if (getLogger().isTraceEnabled()) {
getLogger().trace("document size: " + w + "pt x " + h + "pt");
}
// prepare the image to be painted
//int w = (int)(width + 0.5);
//int h = (int)(height + 0.5);
try {
OutputStream out = output.getOutputStream();
if (!(out instanceof BufferedOutputStream)) {
out = new BufferedOutputStream(out);
}
graphics.setupDocument(out, w, h);
graphics.setSVGDimension(width, height);
if (hints.containsKey(ImageTranscoder.KEY_BACKGROUND_COLOR)) {
graphics.setBackgroundColor
((Color)hints.get(ImageTranscoder.KEY_BACKGROUND_COLOR));
}
graphics.setGraphicContext
(new org.apache.xmlgraphics.java2d.GraphicContext());
graphics.preparePainting();
graphics.transform(curTxf);
graphics.setRenderingHint
(RenderingHintsKeyExt.KEY_TRANSCODING,
RenderingHintsKeyExt.VALUE_TRANSCODING_VECTOR);
this.root.paint(graphics);
graphics.finish();
} catch (IOException ex) {
throw new TranscoderException(ex);
}
}