Converting Word to PDF generates this error when opening the PDF in IE
"Adobe Acrobat, File does not begin with ‘%PDF-’,
and this error when opening directly with Acrobat
“Adobe Reader could not open ‘437.1.pdf’ because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn’t correctly decoded).”
I was using the XML method which worked OK but took a long time to process.
My code: (less the license lines)
private static void SaveWordAsPdf(string baseFilePath, string filePath)
{
// string xmlFilePath = String.Format( CultureInfo.CurrentCulture, @"{0}.{1}", baseFilePath, "xml" );
string pdfFilePath = String.Format(CultureInfo.CurrentCulture, @"{0}.{1}", baseFilePath, "pdf");
Aspose.Words.Document doc;
try
{
doc = new Aspose.Words.Document(filePath);
doc.Save(pdfFilePath/*xmlFilePath*/, Aspose.Words.SaveFormat.AsposePdf);
}
finally
{
doc = null;
}
// CreatePdfFile( xmlFilePath, pdfFilePath );
}