I use the following code:
- Code: Select all
var document = new Document();
document.LoadFromFile(outputFilePath);
document.SaveToFile(Path.ChangeExtension(outputFilePath, ".pdf"), FileFormat.PDF);
When I run this code on the my word document I get the following error (I can't attach the file because your site says docx is not allowed).
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
at System.Collections.Generic.List`1.System.Collections.IList.get_Item(Int32 index)
at Spire.Doc.Collections.CellCollection.get_Item(Int32 index)
at Spire.Doc.Documents.Paragraph.?.?()
at Spire.Doc.Documents.Paragraph.?..ctor(Paragraph A_0)
at Spire.Doc.Documents.Paragraph.CreateLayoutInfo()
at Spire.Doc.DocumentBase.Spire.Doc.Layout.IDocumentBase.get_LayoutInfo()
at spr?.?()
at spr?.?(RectangleF A_0)
at spr?.?(spr? A_0)
at spr?.?(RectangleF A_0)
at spr?.?(spr? A_0, spr? A_1, spr? A_2)
at spr?.?()
at spr?.?(IDocument A_0)
at spr?.?(Document A_0)
at Spire.Doc.Document.?(String A_0)
at Spire.Doc.Document.SaveToFile(String fileName, FileFormat fileFormat)
at WordTemplating.Program.ConvertToPdf(String outputFilePath)
at WordTemplating.Program.Run(String[] args)
at WordTemplating.Program.Main(String[] args)