Hi
I working with Aspose.Words and Aspose.PDF, because I’m seeking to convert a word document to PDF, but before conversion, I want to update the Quick Parts in the word document to ensure correct PDF content.
My problem is that the quick part values does not get updated.
I do that by using the following snippet:
Aspose.Words.Document doc = new Aspose.Words.Document(@"C:\Users\jhas\Desktop\docAfter\docAfter.docx");
doc.UpdateFields();
doc.Save(@"C:\Users\jhas\Desktop\doc2.pdf", SaveFormat.Pdf);
The source and result file is attached.
Could anyone please advise, if I can achive this another way, is it a bug, or is it not possible?
Thanks for your inquiry. I have tested the scenario and have found that Aspose.Word does not load all items of Drop Down List in Aspose.Words DOM. I have logged this issue as WORDSNET-8828 in our issue tracking system. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.
If you want to select a specific item from Drop down list and convert the final document to Pdf, please use the following code snippet. If your requirement is different, please share some more detail about your query. We will then provide you more information on this along with code.
Document doc = new Document(MyDir + "in.docx");
StructuredDocumentTag sdt = (StructuredDocumentTag) doc.GetChild(NodeType.StructuredDocumentTag, 0, true);
if (sdt.SdtType == SdtType.DropDownList)
{
// set the StructuredDocumentTag's SelectedValue with second list item
SdtListItem secondItem = sdt.ListItems[2];
sdt.ListItems.SelectedValue = secondItem;
}
doc.Save(MyDir + "out.pdf");
Hi Tahir,
Thank you for your quick reply.
My main concern in this issue is the PDF Converstion.
If you take a look at the docx file and the PDF file, you will notice that the values are different. In the Word document the quick part has value “3 - Approved” but in the PDF it has value “7 - Draft”. This is due to that the “UpdateFields” does not ensure the correct values in the XML of the docx file, which I would expect.
Can this be done in another way or fixed?
Best regards
Joao
Thanks for your inquiry. Please execute the following code snippet at your end. The StructuredDocumentTag.ListItems.Count returns incorrect value. That is the reason you are getting incorrect output. I have logged this issue as WORDSNET-8828 in our issue tracking system.
Are you facing this issue with all documents or with a specific document?