I previously posted a related message (http://www.aspose.com/Community/Forums/43556/ShowPost.aspx) to the PDF forum that I probably should have posted here.
I am creating a simple one page invoice (using mail merge) that by the time it is converted to a PDF (using Aspose.Words and Aspose.PDF) is 75K. As a test, I had my code simulataneously create .pdf.xml output files from the same mail merge using Apsose.Word and Aspose.Words. The Aspose.Word .xml file became a 9K PDF while the Aspose.Words .xml file became a 76K file. Should I just go back to using Aspose.Word instead of Aspose.Words or are there special paramaters in .Words for defining how true type fonts will be handled when creating a .pdf.xml file?
Here are the versions I am using
Aspose.Word (version 126.96.36.199)
Aspose.Words (version 188.8.131.52)
Aspose.PDF (version 184.108.40.206)
In the attached .zip file I have included the mail merge template, the .pdf.xml files created by Words and Word, and the resulting PDF files that were rendered by Aspose.PDF. Thank you for your help.
Thank you for reporting. We are currently discussing the problem with the Aspose.Pdf team. I don't think reverting to the old version is a good idea. Please give us some time to research.
Sorry Aspose.Pdf team states embedding fonts is required to properly display Unicode characters. I would not recommend going back to the old version of Aspose.Word because it handles some things worse than the newer ones including export of fonts. Is that file size difference critical for you?
We will be saving all invoices so size is critical. Twice as big would probably be OK but seven times as big is not going over too well.
I have made a procedure that converts document to PDF file, without including TrueType fonts into it. Please mind that using this procedure on files containing unicode texts will lead to corrupted output. So use it at your own risk.
string filename = Application.StartupPath + @"\test1.doc";
Document doc = new Document(filename);
Doc2PdfWithoutUnicode(doc, Application.StartupPath + @"\result.pdf");
private void Doc2PdfWithoutUnicode(Document doc, string pdfname)
MemoryStream stream = new MemoryStream();
XmlDocument xmlDoc = new XmlDocument();
// The following procedure switches off unicode support in pdf files.
// Use it on your own risk.
System.Xml.XmlNamespaceManager xmlnsManager = new System.Xml.XmlNamespaceManager(xmlDoc.NameTable);
XmlNodeList nodeList = xmlDoc.SelectNodes(@"//pdfns:Segment[@IsUnicode='true']", xmlnsManager);
foreach(XmlNode xnode in nodeList)
xnode.Attributes["IsUnicode"].Value = "false";
Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf();
pdf.IsImagesInXmlDeleteNeeded = true;
pdf.IsTruetypeFontMapCached = true;
pdf.TruetypeFontMapPath = Path.GetTempPath();
That does the trick. Thanks for your help!