Converted out of the PDF document, the content of some of the wrong, please see the contents of the attachmentDownloads.zip (243.9 KB)
@yjsdfsdf This is an expected behavior. There are REF fields in your document with a missed target. If convert the document to PDF using MS Word, the result will be the same. If you need to keep the fields not updated, you can disable updating fields in PdfSaveOptions
:
Document doc = new Document("C:\\Temp\\in.docx");
PdfSaveOptions opt = new PdfSaveOptions();
opt.setUpdateFields(false);
doc.save("C:\\Temp\\out.pdf", opt);
Alternatively, if it is required to skip updating only REF fields, you can lock them before converting document to PDF:
Document doc = new Document("C:\\Temp\\in.docx");
for (Field f : doc.getRange().getFields())
{
if (f.getType() == FieldType.FIELD_REF)
f.isLocked(true);
}
doc.save("C:\\Temp\\out.pdf");