Use SharePoint metadata to create DOCX or PDF using Documentbuilder

Hi,
In our company, we have some standard templates, like CVs or project offers. The only thing that changes within this template are a few fields we’d like to enter in some metadata fields of a SharePoint listitem.
So when I choose the option “print this item”, the metadata is filled into the document and saved as a PDF.
Can I use Aspose.Words.DocumentBuilder for this? And how difficult would this be?
Thanks in advance for your response.

Hi,

Thanks for your inquiry. I think, you can use DocumentBuilder.MoveToMergeField method that moves the cursor to a position just beyond the specified merge field and removes the merge field. You can then write/insert a text/node at that place using DocumentBuilder class. Please see the following code snippet:

Document doc = new Document(@"C:\Temp\in.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToMergeField("fieldName");
builder.Write("this is field's value");
doc.Save(@"C:\Temp\out.pdf");

I hope, this helps.

Best regards,