的我這是違背XML內容和XSL標記Apache防和給我的apache的中間格式輸出代碼:FOP渲染成PDF的一頁了許多
StreamSource contentSource = new StreamSource(xmlContentStream);
StreamSource transformSource = new StreamSource(xslMarkupStream);
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
Transformer xslfoTransformer = getTransformer(transformSource);
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
IFDocumentHandler targetHandler = foUserAgent.getRendererFactory().createDocumentHandler(
foUserAgent, MimeConstants.MIME_PDF);
FPSIFSerializer fpsSerializer = new FPSIFSerializer();
fpsSerializer.setContext(new IFContext(foUserAgent));
fpsSerializer.mimicDocumentHandler(targetHandler);
foUserAgent.setDocumentHandlerOverride(fpsSerializer);
Fop fop = fopFactory.newFop("application/X-fop-intermediate-format", foUserAgent, outStream);
DefaultHandler defaultHandler = fop.getDefaultHandler();
Result res = new SAXResult(defaultHandler);
xslfoTransformer.transform(contentSource, res);
然後我用的中間格式文件渲染pdf和PNG文件。 我可以在這裏設置我自己的序列化器(FPSIFSerializer())。
我有幾頁報告,但我不需要處理所有這些報告。有沒有辦法跳過一些頁面或從IntermediateFormat中提取它們,這樣我就可以只呈現第一頁爲PNG,然後第二至PDF等? There http://svn.apache.org/viewvc/xmlgraphics/fop/branches/archive/fop-1_1/examples/embedding/java/embedding/intermediate/ExampleConcat.java?view=markup 是如何通過IFConcatenator連接文件的示例,所以我想知道分割多頁文件的最佳方法嗎?
Thank_you!