Using: Aspose.Words (version 4.2.1.0)
Aspose.Pdf (version 3.3.5.0)
ASP.NET
1.1
Our application imports Word forms and then we convert them to PDF automatically. The source form is filled out by third parties who will use a variety of different versions of Word and different techniques for adding images, pictures, etc.
The attached files are representative of the problem we have.
If I use the following sample code to convert the appendix.doc file to PDF, all of the image files are saved as 1KB “red cross” PNG files, which are subsequently imported into the PDF as scaled up “red crosses”.
string path = txtFile.Value.Trim();
string pdfpath = path.Replace(".doc", ".pdf");
string xmlfile = path.Replace(".doc", ".xml");
try
{
Aspose.Words.Document doc = new Aspose.Words.Document(path);
doc.Save(xmlfile, SaveFormat.AsposePdf);
Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf();
pdf.BindXML(xmlfile, null);
pdf.IsCoreFontUsed = true;
// Commented out to demonstrate problem
// pdf.IsImagesInXmlDeleteNeeded = true;
pdf.IsTruetypeFontMapCached = true;
pdf.TruetypeFontMapPath = Path.GetTempPath();
pdf.Save(pdfpath);
}
catch (Exception ex)
{
string debug = ex.Message;
}
finally
{
File.Delete(xmlfile);
}
However, if you open the source file in Word and make any change (to either text or images) and then save the file from Word, the file increases in size and when you run it through the above code all of the images are saved correctly and the PDF is generated correctly.
I have tried using Aspose.Words to somehow automate this but without success.
Can you shed any light on why this is happening and whether there is anything we can do to change this behaviour.
Regards
David Jack