* Extract all PSSetPageDevice instances from the
* attachment list on the s-p-m and add all
* dictionary entries to our internal representation
* of the the page device dictionary.
*/
PSSetPageDevice setPageDevice = (PSSetPageDevice)attachment;
String content = setPageDevice.getContent();
if (content != null) {
try {
pageDeviceDictionary.putAll(PSDictionary.valueOf(content));
} catch (PSDictionaryFormatException e) {
PSEventProducer eventProducer = PSEventProducer.Provider.get(
getUserAgent().getEventBroadcaster());
eventProducer.postscriptDictionaryParseError(this, content, e);
}
}
}
}
}
try {
if (setupCodeList != null) {
PSRenderingUtil.writeEnclosedExtensionAttachments(gen, setupCodeList);
setupCodeList.clear();
}
} catch (IOException e) {
log.error(e.getMessage());
}
final Integer zero = new Integer(0);
Rectangle2D pageBoundingBox = new Rectangle2D.Double();
if (rotate) {
pageBoundingBox.setRect(0, 0, pageHeight, pageWidth);
gen.writeDSCComment(DSCConstants.PAGE_BBOX, new Object[] {
zero, zero, new Long(Math.round(pageHeight)),
new Long(Math.round(pageWidth)) });
gen.writeDSCComment(DSCConstants.PAGE_HIRES_BBOX, new Object[] {
zero, zero, new Double(pageHeight),
new Double(pageWidth) });
gen.writeDSCComment(DSCConstants.PAGE_ORIENTATION, "Landscape");
} else {
pageBoundingBox.setRect(0, 0, pageWidth, pageHeight);
gen.writeDSCComment(DSCConstants.PAGE_BBOX, new Object[] {
zero, zero, new Long(Math.round(pageWidth)),
new Long(Math.round(pageHeight)) });
gen.writeDSCComment(DSCConstants.PAGE_HIRES_BBOX, new Object[] {
zero, zero, new Double(pageWidth),
new Double(pageHeight) });
if (getPSUtil().isAutoRotateLandscape()) {
gen.writeDSCComment(DSCConstants.PAGE_ORIENTATION,
"Portrait");
}
}
this.documentBoundingBox.add(pageBoundingBox);
gen.writeDSCComment(DSCConstants.PAGE_RESOURCES,
new Object[] {DSCConstants.ATEND});
gen.commentln("%FOPSimplePageMaster: " + page.getSimplePageMasterName());
gen.writeDSCComment(DSCConstants.BEGIN_PAGE_SETUP);
if (page.hasExtensionAttachments()) {
List extensionAttachments = page.getExtensionAttachments();
for (int i = 0; i < extensionAttachments.size(); i++) {
Object attObj = extensionAttachments.get(i);
if (attObj instanceof PSExtensionAttachment) {
PSExtensionAttachment attachment = (PSExtensionAttachment)attObj;
if (attachment instanceof PSCommentBefore) {
gen.commentln("%" + attachment.getContent());
} else if (attachment instanceof PSSetupCode) {
gen.writeln(attachment.getContent());
}
}
}
}
// Write any unwritten changes to page device dictionary
if (!pageDeviceDictionary.isEmpty()) {
String content = pageDeviceDictionary.getContent();
if (getPSUtil().isSafeSetPageDevice()) {
content += " SSPD";
} else {
content += " setpagedevice";
}
PSRenderingUtil.writeEnclosedExtensionAttachment(gen, new PSSetPageDevice(content));
}
if (rotate) {
gen.writeln(Math.round(pageHeight) + " 0 translate");
gen.writeln("90 rotate");