I'm using Aspose.Words for converting DOCX files to PDF using this method:
internal static void MakeAsposePdf(FileInfo wordDocumentPath, FileInfo pdfDocumentPath)
{
License licenseWords = new License();
licenseWords.SetLicense("Aspose.Words.lic");
Aspose.Pdf.License licensePdf = new Aspose.Pdf.License();
licensePdf.SetLicense("Aspose.Pdf.lic");
// Open the DOC file using Aspose.Words.
Document doc = new Document(wordDocumentPath.FullName);
// ...You can merge data/manipulate document content here.
// Save the document in Aspose.Pdf.Xml format.
doc.Save(FileLocations.GeneratedFiles + "\\MyDocument.xml", SaveFormat.AsposePdf);
// Read the document in Aspose.Pdf.Xml format into Aspose.Pdf.
Pdf pdf = new Pdf();
pdf.BindXML(FileLocations.GeneratedFiles + "\\MyDocument.xml", null);
// Instruct to delete temporary image files.
pdf.IsImagesInXmlDeleteNeeded = true;
pdf.CompressionLevel = 0;
// Produce the PDF file.
pdf.Save(pdfDocumentPath.FullName);
}
But then I get this error:
Message: Index was outside the bounds of the array.
Stacktrace: at ?.?.?()
at ?.?..ctor(Table tableNode, Boolean resolveInheritedBorders, Boolean populateEmptyPadBorders)
at ?.?.?(Table ?)
at ?.?.VisitTableStart(Table table)
at Aspose.Words.Tables.Table.Accept(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.?(DocumentVisitor ?)
at Aspose.Words.Body.Accept(DocumentVisitor visitor)
at ?.?.?(Section ?)
at ?.?.?(? ?)
at Aspose.Words.Document.?(Stream ?, String ?, SaveFormat ?)
at Aspose.Words.Document.Save(String fileName, SaveFormat fileFormat)
I've attached the DOCX file I'm trying to convert.
Any suggestions?