opensagres / xdocreport

XDocReport means XML Document reporting. It's Java API to merge XML document created with MS Office (docx) or OpenOffice (odt), LibreOffice (odt) with a Java model to generate report and convert it if you need to another format (PDF, XHTML...).
https://github.com/opensagres/xdocreport
1.23k stars 373 forks source link

docx to pdf chinese but unreadable #199

Open hucheng91 opened 7 years ago

hucheng91 commented 7 years ago

jdk 1.8,xdocreport 1.0.5;

i was want to make docx to pdf in chinese the pdf can create but the font unreadable; if the docx is English not the problem

java code


    public  static  void makePdfByXcode(){
        long startTime=System.currentTimeMillis();
        try {
            XWPFDocument document=new XWPFDocument(new FileInputStream(new File("D:/cache/qqChace/T1/ceshi.docx")));
            File outFile=new File("D:/cache/qqChace/T1/ceshiEnglish.pdf");
            outFile.getParentFile().mkdirs();
            OutputStream out=new FileOutputStream(outFile);
            PdfOptions options= PdfOptions.create().fontEncoding("utf-8");
            PdfConverter.getInstance().convert(document,out,options);
        }
        catch (  Throwable e) {
            e.printStackTrace();
        }
        System.out.println("Generate ooxml.pdf with " + (System.currentTimeMillis() - startTime) + " ms.");
    }

my docx [docx](http://ojefm7q7h.bkt.clouddn.com/test.docx)
create pdf [pdf](http://ojefm7q7h.bkt.clouddn.com/test.pdf)
chenbihao commented 5 years ago

同问