Hi,
We are currently working on a document system. The users can send emails from the application based on templates with mergefields etc.
Eventually the output is a string with wordml code in it.
I convert that string with Aspose.Words to a PDF without problems with the following code:
The document variable in the method is my string containing wordml code.
public byte[] ConvertTemplateToPdf(string document)
{
var stream = new MemoryStream();
var encoding = new UTF8Encoding();
Document doc;
var newStream = new MemoryStream(encoding.GetBytes(document));
using (newStream)
{
doc = new Document(newStream);
}
foreach (Section section in doc.Sections)
{
// Set PaperSize to A4
section.PageSetup.PaperSize = PaperSize.A4;
}
try
{
var pdfoptions = new PdfSaveOptions { Compliance = PdfCompliance.PdfA1b, SaveFormat = SaveFormat.Pdf, TextCompression = PdfTextCompression.None };
doc.Save(stream, pdfoptions);
}
catch (Exception ex)
{
throw new ApplicationException("ERROR conversie : " + ex.Message);
}
byte[] convertedDocument;
using (stream)
{
convertedDocument = stream.GetBuffer();
}
return convertedDocument;
}
Now the users are asking to add the email from, to and subject at the top of this document.
I found something about adding headers in the documentation pages from aspose.Words but i’m not sure how to do this or if it will work.
Is it possible to add a header to my wordml string before converting to total to pdf?
thx in advance.