String inputfilepath = "test.docx";
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new java.io.File(inputfilepath));
// the PdfConversion object
org.docx4j.convert.out.pdf.PdfConversion c = new org.docx4j.convert.out.pdf.viaXSLFO.Conversion(wordMLPackage);
// for demo/debugging purposes, save the intermediate XSL FO
((org.docx4j.convert.out.pdf.viaXSLFO.Conversion) c).setSaveFO(new java.io.File(inputfilepath + ".fo"));
// PdfConversion writes to an output stream
String outputfilepath = System.getProperty("user.dir") + "/OUT_FontContent.pdf";
OutputStream os = new java.io.FileOutputStream(outputfilepath);
// OK, do it...
c.output(os, new PdfSettings());
jason wrote:https://github.com/plutext/docx4j/commit/08ec3f1ce7d9fa7b75fb8d40118d443705634ba2 adds basic support.
With that, I can see the SimSun font in PDF output.
Note, the code won't detect a Chinese font which is used only in the styles. That remains a TODO.
SEVERE: Error while rendering page 2. Reason: java.lang.RuntimeException: Int or float buffers require 32-bit data.
java.lang.RuntimeException: Int or float buffers require 32-bit data.
at org.apache.xmlgraphics.image.codec.tiff.TIFFImageEncoder.encode(TIFFImageEncoder.java:250)
at org.apache.xmlgraphics.image.codec.tiff.TIFFImageEncoder.encodeMultiple(TIFFImageEncoder.java:166)
at org.apache.xmlgraphics.image.writer.internal.TIFFImageWriter$TIFFMultiImageWriter.writeImage(TIFFImageWriter.java:130)
at org.apache.fop.render.bitmap.AbstractBitmapDocumentHandler.endPageContent(AbstractBitmapDocumentHandler.java:321)
at org.apache.fop.render.intermediate.util.IFDocumentHandlerProxy.endPageContent(IFDocumentHandlerProxy.java:157)
at org.apache.fop.render.intermediate.IFRenderer.renderPage(IFRenderer.java:599)
at org.apache.fop.area.RenderPagesModel.renderPage(RenderPagesModel.java:193)
at org.apache.fop.area.RenderPagesModel.checkPreparedPages(RenderPagesModel.java:174)
at org.apache.fop.area.RenderPagesModel.addPage(RenderPagesModel.java:146)
at org.apache.fop.layoutmgr.AbstractPageSequenceLayoutManager.finishPage(AbstractPageSequenceLayoutManager.java:312)
at org.apache.fop.layoutmgr.PageSequenceLayoutManager.finishPage(PageSequenceLayoutManager.java:191)
at org.apache.fop.layoutmgr.AbstractPageSequenceLayoutManager.makeNewPage(AbstractPageSequenceLayoutManager.java:283)
at org.apache.fop.layoutmgr.PageSequenceLayoutManager.makeNewPage(PageSequenceLayoutManager.java:151)
at org.apache.fop.layoutmgr.PageBreaker.handleBreakTrait(PageBreaker.java:545)
at org.apache.fop.layoutmgr.PageBreaker.startPart(PageBreaker.java:444)
at org.apache.fop.layoutmgr.AbstractBreaker.addAreas(AbstractBreaker.java:530)
at org.apache.fop.layoutmgr.AbstractBreaker.addAreas(AbstractBreaker.java:481)
at org.apache.fop.layoutmgr.PageBreaker.doPhase3(PageBreaker.java:313)
at org.apache.fop.layoutmgr.AbstractBreaker.doLayout(AbstractBreaker.java:436)
at org.apache.fop.layoutmgr.PageBreaker.doLayout(PageBreaker.java:90)
at org.apache.fop.layoutmgr.PageSequenceLayoutManager.activateLayout(PageSequenceLayoutManager.java:113)
at org.apache.fop.area.AreaTreeHandler.endPageSequence(AreaTreeHandler.java:267)
at org.apache.fop.fo.pagination.PageSequence.endOfNode(PageSequence.java:128)
at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.endElement(FOTreeBuilder.java:347)
at org.apache.fop.fo.FOTreeBuilder.endElement(FOTreeBuilder.java:181)
at org.apache.xalan.transformer.TransformerIdentityImpl.endElement(TransformerIdentityImpl.java:1102)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:485)
at org.docx4j.convert.out.fo.renderers.FORendererApacheFOP.render(FORendererApacheFOP.java:204)
at org.docx4j.convert.out.fo.renderers.FORendererApacheFOP.render(FORendererApacheFOP.java:153)
at org.docx4j.convert.out.fo.AbstractFOExporter.postprocess(AbstractFOExporter.java:135)
at org.docx4j.convert.out.fo.AbstractFOExporter.postprocess(AbstractFOExporter.java:45)
at org.docx4j.convert.out.common.AbstractExporter.export(AbstractExporter.java:82)
at org.docx4j.Docx4J.toFO(Docx4J.java:475)
at Drivers.docx4jConverter.main(docx4jConverter.java:50)
Jul 31, 2014 5:43:49 PM org.docx4j.convert.out.common.AbstractExporter export
SEVERE: Exception exporting package
java.lang.RuntimeException: Int or float buffers require 32-bit data.
at org.apache.xmlgraphics.image.codec.tiff.TIFFImageEncoder.encode(TIFFImageEncoder.java:250)
at org.apache.xmlgraphics.image.codec.tiff.TIFFImageEncoder.encodeMultiple(TIFFImageEncoder.java:166)
at org.apache.xmlgraphics.image.writer.internal.TIFFImageWriter$TIFFMultiImageWriter.writeImage(TIFFImageWriter.java:130)
at org.apache.fop.render.bitmap.AbstractBitmapDocumentHandler.endPageContent(AbstractBitmapDocumentHandler.java:321)
at org.apache.fop.render.intermediate.util.IFDocumentHandlerProxy.endPageContent(IFDocumentHandlerProxy.java:157)
at org.apache.fop.render.intermediate.IFRenderer.renderPage(IFRenderer.java:599)
at org.apache.fop.area.RenderPagesModel.renderPage(RenderPagesModel.java:193)
at org.apache.fop.area.RenderPagesModel.checkPreparedPages(RenderPagesModel.java:174)
at org.apache.fop.area.RenderPagesModel.addPage(RenderPagesModel.java:146)
at org.apache.fop.layoutmgr.AbstractPageSequenceLayoutManager.finishPage(AbstractPageSequenceLayoutManager.java:312)
at org.apache.fop.layoutmgr.PageSequenceLayoutManager.finishPage(PageSequenceLayoutManager.java:191)
at org.apache.fop.layoutmgr.AbstractPageSequenceLayoutManager.makeNewPage(AbstractPageSequenceLayoutManager.java:283)
at org.apache.fop.layoutmgr.PageSequenceLayoutManager.makeNewPage(PageSequenceLayoutManager.java:151)
at org.apache.fop.layoutmgr.PageBreaker.handleBreakTrait(PageBreaker.java:545)
at org.apache.fop.layoutmgr.PageBreaker.startPart(PageBreaker.java:444)
at org.apache.fop.layoutmgr.AbstractBreaker.addAreas(AbstractBreaker.java:530)
at org.apache.fop.layoutmgr.AbstractBreaker.addAreas(AbstractBreaker.java:481)
at org.apache.fop.layoutmgr.PageBreaker.doPhase3(PageBreaker.java:313)
at org.apache.fop.layoutmgr.AbstractBreaker.doLayout(AbstractBreaker.java:436)
at org.apache.fop.layoutmgr.PageBreaker.doLayout(PageBreaker.java:90)
at org.apache.fop.layoutmgr.PageSequenceLayoutManager.activateLayout(PageSequenceLayoutManager.java:113)
at org.apache.fop.area.AreaTreeHandler.endPageSequence(AreaTreeHandler.java:267)
at org.apache.fop.fo.pagination.PageSequence.endOfNode(PageSequence.java:128)
at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.endElement(FOTreeBuilder.java:347)
at org.apache.fop.fo.FOTreeBuilder.endElement(FOTreeBuilder.java:181)
at org.apache.xalan.transformer.TransformerIdentityImpl.endElement(TransformerIdentityImpl.java:1102)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:485)
at org.docx4j.convert.out.fo.renderers.FORendererApacheFOP.render(FORendererApacheFOP.java:204)
at org.docx4j.convert.out.fo.renderers.FORendererApacheFOP.render(FORendererApacheFOP.java:153)
at org.docx4j.convert.out.fo.AbstractFOExporter.postprocess(AbstractFOExporter.java:135)
at org.docx4j.convert.out.fo.AbstractFOExporter.postprocess(AbstractFOExporter.java:45)
at org.docx4j.convert.out.common.AbstractExporter.export(AbstractExporter.java:82)
at org.docx4j.Docx4J.toFO(Docx4J.java:475)
at Drivers.docx4jConverter.main(docx4jConverter.java:50)
String inputfilepath = "D:\\Office Conversion Test\\sample.docx";
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new java.io.File(inputfilepath));
String outputfilepath = "D:\\Office Conversion Test\\sample.tif";
OutputStream os = new java.io.FileOutputStream(outputfilepath);
FOSettings settings = Docx4J.createFOSettings();
settings.setWmlPackage(wordMLPackage);
settings.setApacheFopMime("image/tiff");
Docx4J.toFO(settings, os, Docx4J.FLAG_NONE);
Users browsing this forum: Google [Bot] and 28 guests