Page 1 of 1

problem in converting docx to pdf

PostPosted: Sat Jul 24, 2010 2:18 am
by joyy
Hi.

When I am trying to convert docx file to pdf I got this type of exception.


Exception in thread "main" java.lang.AbstractMethodError: org.apache.fop.fonts.Typeface.getEncodingName()Ljava/lang/String;
at org.apache.fop.pdf.PDFResources.addFonts(PDFResources.java:117)
at org.apache.fop.render.pdf.PDFRenderer.stopRenderer(PDFRenderer.java:275)
at org.apache.fop.area.RenderPagesModel.endDocument(RenderPagesModel.java:256)
at org.apache.fop.area.AreaTreeHandler.endDocument(AreaTreeHandler.java:309)
at org.apache.fop.fo.FOTreeBuilder.endDocument(FOTreeBuilder.java:164)
at org.apache.xalan.transformer.TransformerIdentityImpl.endDocument(TransformerIdentityImpl.java:962)
at org.apache.xerces.parsers.AbstractSAXParser.endDocument(AbstractSAXParser.java:726)
at org.apache.xerces.impl.XMLDocumentScannerImpl.endEntity(XMLDocumentScannerImpl.java:525)
at org.apache.xerces.impl.XMLEntityManager.endEntity(XMLEntityManager.java:1938)
at org.apache.xerces.impl.XMLEntityScanner.load(XMLEntityScanner.java:1773)
at org.apache.xerces.impl.XMLEntityScanner.skipSpaces(XMLEntityScanner.java:1258)
at org.apache.xerces.impl.XMLDocumentScannerImpl$TrailingMiscDispatcher.dispatch(XMLDocumentScannerImpl.java:1239)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:324)
at org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:875)
at org.apache.xerces.parsers.XML11Configuration.parse(XML11Configuration.java:798)
at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:108)
at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1190)
at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:484)
at org.docx4j.convert.out.pdf.viaXSLFO.Conversion.output(Conversion.java:335)
at org.docx4j.samples.CreatePdf.main(CreatePdf.java:132)

I think exception cause in org.apache.fop.pdf.PDFResources.java file

encoding = font.getEncodingName();

I don't know what happening?

Thanx in advance.

Re: problem in converting docx to pdf

PostPosted: Sat Jul 24, 2010 5:46 pm
by jason
I suspect I may have introduced the problem you are reporting in 2.5.0, when I commented out the following in the PhysicalFonts class:

Code: Select all
//                    // We're only interested if this font supports UTF-8 encoding
//                    // since otherwise iText can't use it (at least on a
//                    // UTF8 encoded XHTML document)
//                    try {
//                       BaseFont bf = BaseFont.createFont(afm,
//                             BaseFont.IDENTITY_H,
//                           BaseFont.NOT_EMBEDDED);
//                  } catch (java.io.UnsupportedEncodingException uee) {
//                     log.error(afm + " does not support UTF encoding, so ignoring");
//                     continue;
//                  } catch (Exception e) {
//                     log.error(e);
//                     continue;
//                  }


Can you post a test case docx (make sure you first save it in Word with fonts embedded: Word Options > Save > Embed Fonts in File)?

Re: problem in converting docx to pdf

PostPosted: Mon Jul 26, 2010 5:09 pm
by joyy
Thnx for your reply,

I attached TestDocument file with this reply.

I tried some other files also but they all given same exception.

Thnx.

Re: problem in converting docx to pdf

PostPosted: Mon Jul 26, 2010 7:13 pm
by jason
Your document works for me (as expected, since it doesn't use any unusual fonts)

With log4j logging configured, when I run the CreatePdf sample, FOP is being configured with the following fonts:

Code: Select all
26.07.2010 17:44:25 *INFO * Conversion:
Using config:
<fop version="1.0"><strict-configuration>true</strict-configuration><renderers><renderer mime="application/pdf"><fonts><font embed-url="file:/C:/Windows/FONTS/calibri.ttf"><font-triplet name="Calibri" style="normal" weight="normal"/></font><font embed-url="file:/C:/Windows/FONTS/calibrib.ttf"><font-triplet name="Calibri" style="normal" weight="bold"/></font><font embed-url="file:/C:/Windows/FONTS/calibriz.ttf"><font-triplet name="Calibri" style="italic" weight="bold"/></font><font embed-url="file:/C:/Windows/FONTS/calibrii.ttf"><font-triplet name="Calibri" style="italic" weight="normal"/></font><font embed-url="file:/C:/Windows/FONTS/ariblk.ttf"><font-triplet name="Arial Black" style="normal" weight="normal"/></font></fonts></renderer></renderers></fop>
(Conversion.java, line 250)


Can you post the corresponding line from your logs?

How are you configuring your PDF conversion - is it any different from the CreatePdf sample?

Re: problem in converting docx to pdf

PostPosted: Mon Jul 26, 2010 11:27 pm
by joyy
OK. Thnx for reply,

Using docx4j2.5.0 I solved this error.

Problem were in the build configuration of project.

Sorry for that.

Now I am trying to converting doc file into docx file using Doc.java but it gives the following exception..

##SummaryInformation
##DocumentSummaryInformation
##WordDocument
##CompObj
##ObjectPool
##1Table
Exception in thread "main" java.io.IOException: block[ 10 ] already removed - does your POIFS have circular or duplicate block references?
at org.apache.poi.poifs.storage.BlockListImpl.remove(BlockListImpl.java:97)
at org.apache.poi.poifs.storage.RawDataBlockList.remove(RawDataBlockList.java:32)
at org.apache.poi.poifs.storage.BlockAllocationTableReader.fetchBlocks(BlockAllocationTableReader.java:196)
at org.apache.poi.poifs.storage.BlockListImpl.fetchBlocks(BlockListImpl.java:132)
at org.apache.poi.poifs.storage.RawDataBlockList.fetchBlocks(RawDataBlockList.java:32)
at org.apache.poi.poifs.filesystem.POIFSFileSystem.processProperties(POIFSFileSystem.java:542)
at org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(POIFSFileSystem.java:176)
at org.apache.poi.hwpf.HWPFDocument.verifyAndBuildPOIFS(HWPFDocument.java:133)
at org.apache.poi.hwpf.HWPFDocument.<init>(HWPFDocument.java:146)
at org.docx4j.convert.in.Doc.convert(Doc.java:58)
at org.docx4j.convert.in.Doc.main(Doc.java:396)

I think this line gives error

HWPFDocument doc = new HWPFDocument(in);

Re: problem in converting docx to pdf

PostPosted: Tue Jul 27, 2010 7:31 pm
by jason
Split into new topic