We're sorry Aspose doesn't work properply without JavaScript enabled.

# The layout changes when convert word to pdf

Hi,
We use the com.aspose.words.Document doc to convert doc document to PDF, and find the layout is changed in PDF.
image.png (279.9 KB)

## My code:

com.aspose.words.Document doc;
try {
File file1 = new File(newWordPath);
String wordName=file1.getName();
if(wordName!=null && !"".equals(wordName)){
wordName=wordName.substring(0, wordName.lastIndexOf("."));
String path = pdfPath + "\\"+wordName+ ".pdf";
File file = new File(path);
doc = new com.aspose.words.Document(newWordPath);
com.aspose.words.Document doc1 = new com.aspose.words.Document();
doc1.removeAllChildren();
doc1.appendDocument(doc, ImportFormatMode.USE_DESTINATION_STYLES);
try (FileOutputStream os = new FileOutputStream(file)) {
doc1.save(os, SaveFormat.PDF);

}
}


The attached is the original doc document and the result PDF.

Best
Wish,
word+PDF.zip (399.9 KB)

@linjiale Thank you for reporting this problem to us. For a sake of correction it has been logged as WORDSNET-23749. We will keep you informed and let you know once it is resolved.
Partially, the problem can be resolved by setting the following option upon conversion:

Document doc = new Document("C:\\Temp\\in.doc");
doc.getCompatibilityOptions().setUseFELayout(true);
doc.getStyles().getDefaultFont().setLocaleIdFarEast(2052);
doc.save("C:\\Temp\\out.pdf");


Setting these options makes Aspose.Words to render Chinese document closer to MS Word with preferred language set to Chinese.

Hi, alexeey,

There is another problem when converts to PDF from doc:
The footnote marks on the context have been changed to be a block in PDF, which are correct on doc document.EN-9-19.zip (1.7 MB)

image.png (109.7 KB)

Best wish,

LIN Jiale

@linjiale Thank you for additional information. I have managed to reproduce the problem. For a sake of correction it has been logged as WORDSNET-23755. We will keep you informed and let you know once it is resolved.

@linjiale for further investigation of WORDSNET-23749 could you please attach the following fonts:

• 方正书宋_GBK
• 方正黑体_GBK
• 方正仿宋_GBK
• 方正楷体_GBK
• 方正黑体简体
• 楷体_GB2312

Hi,

1. We attach the fonts in the Office Word, but the problem still exists:
The marks of footnote on PDF are still a blank box.

The converting PDF code is:

com.aspose.words.Document doc;
try {
File file1 = new File(newWordPath);
String wordName=file1.getName();
if(wordName!=null && !"".equals(wordName)){
wordName=wordName.substring(0, wordName.lastIndexOf("."));
String path = pdfPath + "\\"+wordName+ ".pdf";
File file = new File(path);
doc = new com.aspose.words.Document(newWordPath);
com.aspose.words.Document doc1 = new com.aspose.words.Document();
doc1.removeAllChildren();
doc1.appendDocument(doc, ImportFormatMode.USE_DESTINATION_STYLES);
doc1.getCompatibilityOptions().setUseFELayout(true);
doc1.getStyles().getDefaultFont().setLocaleIdFarEast(2052);
doc1.getStyles().getDefaultFont().setName("楷体_GB2312");
doc1.getStyles().getDefaultFont().setNameFarEast("楷体_GB2312");
try (FileOutputStream os = new FileOutputStream(file)) {
doc1.save(os, SaveFormat.PDF);
return path;
}
}


2. The footnote marks are still missing

The code of inserting footnote

Paragraph paragraph= new Paragraph(docx);
Run runp = new Run(document);
runp.setText("accounting for about 75% of membranous nephropathy (MN) cases");
paragraph.appendChild(runp);

Footnote footnote = new Footnote(docx, FootnoteType.FOOTNOTE);
footnote.getFont().setBold(false);
footnote.getFont().setSuperscript(true);
footnote.getFont().setName("楷体_GB2312");
footnote.getFont().setNameFarEast("楷体_GB2312");
footnote.isAuto(true);
paragraph.appendChild(footnote);

Paragraph para = new Paragraph(docx);
Run run = new Run(document);
run.setText("Renal functions were stable.");
para.appendChild(run);
footnote.appendChild(para);

Paragraph para1 = new Paragraph(docx);
Run run1 = new Run(document);
run1.setText("Ddddddd");
para1.appendChild(run1);
footnote.appendChild(para1);

Run runp1 = new Run(document);
paragraph.appendChild(runp1);


@linjiale The problem with footnote is logged as WORDSNET-23755 and currently it is waiting for analysis.
The issue I was talking about was the defect WORDSNET-23749 you have reported in your first post. To continue analysis of this issue we need the following fonts:

• 方正书宋_GBK
• 方正黑体_GBK
• 方正仿宋_GBK
• 方正楷体_GBK
• 方正黑体简体
• 楷体_GB2312

Please attach them here in the forum, so we can reproduce your environment on our side.