Hi,Jason:
I Convert Html file to docx , and convert docx to pdf ,but chinese charcter in pdf files show # , I try to fix it ,but Failure. help please!
It is currently Sun Jan 12, 2025 9:58 pm
blah blah blah ^1
text text text ^2
---------------------------
^1 Source Document
^2 Source Document
blah blah blah ^1
text text text ^1
---------------------------
^1 Source Document
xHTMLImporter.setTableFormatting(FormattingOption.CLASS_PLUS_OTHER);
xHTMLImporter.setParagraphFormatting(FormattingOption.CLASS_TO_STYLE_ONLY);
xHTMLImporter.setRunFormatting(FormattingOption.CLASS_PLUS_OTHER);
org.docx4j.convert.out.pdf.PdfConversion c = new org.docx4j.convert.out.pdf.viaXSLFO.Conversion(wordMLPackage);
OutputStream os = new FileOutputStream(new File(outputfilepath + ".pdf"));
c.output ( os , new PdfSettings() );
NOT IMPLEMENTED: support for w:pict - without v:imagedata
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.HashMap;
import org.docx4j.XmlUtils;
import org.docx4j.convert.out.pdf.viaXSLFO.PdfSettings;
import org.docx4j.fonts.IdentityPlusMapper;
import org.docx4j.fonts.Mapper;
import org.docx4j.fonts.PhysicalFont;
import org.docx4j.fonts.PhysicalFonts;
import org.docx4j.jaxb.Context;
import org.docx4j.openpackaging.io.SaveToZipFile;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart;
import org.docx4j.convert.out.pdf.PdfConversion;
public class DocxEdit {
public static void main(String args) throws Exception {
// 1) Load DOCX into WordprocessingMLPackage
InputStream is = new FileInputStream(new File("Documento.docx"));
WordprocessingMLPackage wordMLPackage2 ...
{ \PAGEREF bookmark }
........
........
wordMLPackage = WordprocessingMLPackage.load(new java.io.File("D:\\Abc.docx"));
Mapper fontMapper = new IdentityPlusMapper();
fontMapper.getFontMappings().put("Times New Roman", PhysicalFonts.getPhysicalFonts().get("Arial Unicode MS"));
wordMLPackage.setFontMapper(fontMapper);
FOSettings foSettings = Docx4J.createFOSettings();
foSettings.setFoDumpFile(new java.io.File("D:\\Abc.fo"));
foSettings.setWmlPackage(wordMLPackage);
foSettings.setApacheFopMime(FOSettings.INTERNAL_FO_MIME);
String pdfOutFileName = "D:\\Abc.pdf";
OutputStream os = new java.io.FileOutputStream(pdfOutFileName);
Docx4J.toFO(foSettings, os, Docx4J.FLAG_NONE);
return pdfOutFileName;
Total posts 10116 • Total topics 2845 • Total members 2076