Hi,
We are using the latest Aspose Words to render a document to Pdf rendition.
Pdf generated is exactly same as office rendition. But customer is using an extra addon in office i.e. Acrobat PDFMaker.
Customer is able to create the proper rendition with Acrobat PDFMaker.
@rnara The problem occurs because both MS Word and Aspose.Words update REF fields before saving to PDF. You can disable field updating in Aspose.Words to get the expected result:
Document doc = new Document(@"C:\Temp\in.docx");
PdfSaveOptions opt = new PdfSaveOptions();
opt.UpdateFields = false;
doc.Save(@"C:\Temp\out.pdf", opt);
Alternatively, you can unlink or lock REF fields in your document to prevent updating them:
Document doc = new Document(@"C:\Temp\in.docx");
foreach (Field f in doc.Range.Fields)
{
if (f.Start.FieldType == FieldType.FieldRef)
f.IsLocked = true;
}
doc.Save(@"C:\Temp\out.pdf");
@rnara No, there are no OLE objects in your document. On the 51st page of your document there is a REF field { REF _Ref530570301 \r \h \* MERGEFORMAT }:
If you update this REF field, its value will be zero, just like in the PDF produced by Aspose.Words or MS Word, because by default they update fields upon rendering it to PDF.
You can right click on the field and select “Toggle Field Codes” to see field code:
Hi Alexy,
My question is regarding the value it picks, in this case 0 when it doesn’t update the field?
So you mean the REF Field default value is 0?
Is there any such concept?
Sorry for asking so many queries but I have to explain the same to customer.
How can the customer fix this issue? Is this REF thing internal to Office or this is added by use while creating a document?
@rnara The value of REF field is calculated according to the switches specified in the field. You can learn more about REF field code and switches in MS Word documentation: https://support.microsoft.com/en-us/office/field-codes-ref-field-b2531c23-05d6-4e3b-b54f-aee24447ceb2
In your case you have the following Field code: { REF _Ref530570301 \r \h \* MERGEFORMAT }. _Ref530570301 is name of bookmark the REF field refers to. \r - Inserts the entire paragraph number of the bookmarked paragraph in relative context — or relative to its position in the numbering scheme — without trailing periods \h - Creates a hyperlink to the bookmarked paragraph.
Since the referenced paragraph does not have number (means ordered list number), zero value is inserted when \r switch is used.