- Code: Select all
File inFile = new File("D:/TestDocstoPDF/NEWFILE/QuoteSignatureTemplate.docx");
OutputStream os = new java.io.FileOutputStream("D:/TestDocstoPDF/NEWFILE/New103mysytemfile.pdf");
InputStream inputStream = new FileInputStream(inFile);
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(inputStream);
Mapper fontMapper = new IdentityPlusMapper();
wordMLPackage.setFontMapper(fontMapper);
FOSettings foSettings = Docx4J.createFOSettings();
foSettings.setWmlPackage(wordMLPackage);
foSettings.setFoDumpFile(new File("D:/TestDocstoPDF/NEWFILE/New103mysytemfile.pdfreport.fo"));
Docx4J.toFO(foSettings, os, Docx4J.FLAG_EXPORT_PREFER_XSL);
I am trying to convert docx file to PDF which contains multiple image but I am getting this Exception
- Code: Select all
java.lang.ClassCastException: org.docx4j.openpackaging.parts.WordprocessingML.BinaryPart cannot be cast to org.docx4j.openpackaging.parts.WordprocessingML.ObfuscatedFontPart
at org.docx4j.openpackaging.parts.WordprocessingML.FontTablePart.getObfuscatedFontFromRelationship(FontTablePart.java:142)
at org.docx4j.openpackaging.parts.WordprocessingML.FontTablePart.processEmbeddings(FontTablePart.java:118)
at org.docx4j.openpackaging.packages.WordprocessingMLPackage.setFontMapper(WordprocessingMLPackage.java:360)
at org.docx4j.openpackaging.packages.WordprocessingMLPackage.setFontMapper(WordprocessingMLPackage.java:309)
at org.docx4j.openpackaging.packages.WordprocessingMLPackage.getFontMapper(WordprocessingMLPackage.java:376)
at org.docx4j.convert.out.common.preprocess.PartialDeepCopy.process(PartialDeepCopy.java:95) ...