I'm using spire.office version 5.2.0 (licensed). When I try to convert .docx to .pdf using SaveToStream function, it is throwing a null reference exception for few files.
- Code: Select all
Document doc = new Document();
doc.LoadFromFile(@"D:Dummy.docx");
MemoryStream pdfStream = new MemoryStream();
doc.SaveToStream(pdfStream, FileFormat.PDF);
It generates the following error:
System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=Spire.Doc
StackTrace:
at spr⢾.ᜃ(Paragraph A_0, spr A_1)
at Spire.Doc.Documents.Paragraph.Spire.Doc.Layout.IDocumentBase.Draw(spr⢾ dc, spr ltWidget)
at spr.ᜂ(spr⢾ A_0)
at spr.ᜂ(spr⢾ A_0)
at spr⣋.ᜂ(spr⢾ A_0)
at spr⢶.ᜁ(Int32 A_0, Int32 A_1)
at spr⣡.ᜀ(spr⢶ A_0, Stream A_1)
at spr⣡.ᜀ(Document A_0, Stream A_1, ToPdfParameterList A_2)
at Spire.Doc.Document.ᜁ(Stream A_0, ToPdfParameterList A_1)
at Program.<Main>$(String[] args) in D:\02-SourceCode\ConvertToPdf\ConvertToPdf\Program.cs:line 13
The same issue is reported with converting a .PPTX file to .PDF using SaveToFile function.
Note: When I executed the same code using Spire.Office version 7.7.2, it is working fine.
Thank you in advance.