Can someone help me figure out what is wrong here? I'm getting ad horribly vague Null exception.
var docxProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Docx.DocxFormatProvider();
var pdfProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();
RadFlowDocument document = new RadFlowDocument();
byte[] docBytes = File.ReadAllBytes(path);
document = docxProvider.Import(docBytes); ERROR HERE
var resultBytes = pdfProvider.Export(document);
File.WriteAllBytes(resultPath, resultBytes);
The document i'm trying to load contains tables and images within the tables (jpeg barcodes)
I have verified that pretty much every other tool i use can read the file without issue.
The goal is ultimately to export the file as a PDF.
Error details:
{"Object reference not set to an instance of an object."}
at Telerik.Windows.Documents.Flow.FormatProviders.Docx.Model.Elements.Document.ParagraphPropertiesElement.OnAfterRead(IDocxImportContext context)at Telerik.Windows.Documents.FormatProviders.OpenXml.Model.Elements.OpenXmlElementBase`3.OnAfterRead(IOpenXmlImportContext context)
at Telerik.Windows.Documents.FormatProviders.OpenXml.Model.Elements.OpenXmlElementBase.Read(IOpenXmlReader reader, IOpenXmlImportContext context)
at Telerik.Windows.Documents.FormatProviders.OpenXml.Model.Elements.OpenXmlElementBase.ReadChildElements(IOpenXmlReader reader, IOpenXmlImportContext context)
at Telerik.Windows.Documents.FormatProviders.OpenXml.Model.Elements.OpenXmlElementBase.Read(IOpenXmlReader reader, IOpenXmlImportContext context)
at Telerik.Windows.Documents.FormatProviders.OpenXml.Model.Elements.OpenXmlElementBase.ReadChildElements(IOpenXmlReader reader, IOpenXmlImportContext context)
at Telerik.Windows.Documents.FormatProviders.OpenXml.Model.Elements.OpenXmlElementBase.Read(IOpenXmlReader reader, IOpenXmlImportContext context)
at Telerik.Windows.Documents.FormatProviders.OpenXml.Model.Elements.OpenXmlElementBase.ReadChildElements(IOpenXmlReader reader, IOpenXmlImportContext context)
at Telerik.Windows.Documents.FormatProviders.OpenXml.Model.Elements.OpenXmlElementBase.Read(IOpenXmlReader reader, IOpenXmlImportContext context)
at Telerik.Windows.Documents.FormatProviders.OpenXml.Model.Elements.OpenXmlElementBase.ReadChildElements(IOpenXmlReader reader, IOpenXmlImportContext context)
at Telerik.Windows.Documents.FormatProviders.OpenXml.Model.Elements.OpenXmlElementBase.Read(IOpenXmlReader reader, IOpenXmlImportContext context)
at Telerik.Windows.Documents.FormatProviders.OpenXml.Model.Elements.OpenXmlElementBase.ReadChildElements(IOpenXmlReader reader, IOpenXmlImportContext context)
at Telerik.Windows.Documents.FormatProviders.OpenXml.Model.Elements.OpenXmlElementBase.Read(IOpenXmlReader reader, IOpenXmlImportContext context)
at Telerik.Windows.Documents.FormatProviders.OpenXml.Model.Parts.OpenXmlPartBase.Import(IOpenXmlReader reader, IOpenXmlImportContext context)
at Telerik.Windows.Documents.FormatProviders.OpenXml.Model.Parts.OpenXmlPartBase.Import(Stream stream, IOpenXmlImportContext context)
at Telerik.Windows.Documents.FormatProviders.OpenXml.OpenXmlImporter`1.ImportPartFromArchive(ZipArchiveEntry zipEntry, PartBase part, IOpenXmlImportContext context)
at Telerik.Windows.Documents.FormatProviders.OpenXml.OpenXmlImporter`1.Import(Stream input, IOpenXmlImportContext context)
at Telerik.Windows.Documents.Flow.FormatProviders.Docx.DocxFormatProvider.ImportOverride(Stream input)
at Telerik.Windows.Documents.Common.FormatProviders.FormatProviderBase`1.Import(Stream input)
at Telerik.Windows.Documents.Common.FormatProviders.BinaryFormatProviderBase`1.Import(Byte[] input)
at IVC_BIPS_Desktop.rfrmMain.ConverDocxToPdf(String path, String resultPath) in C:\Source\IVC Batch Instructions Printing\IVC_BIPS_Desktop\rfrmMain.cs:line 499
Hello Jamie,
Thank you for reaching out.
I am sorry to hear you are experiencing unexpected results. I would gladly like to help you with this case however without having reproduced and examine the same results on my end, my assistance is very limited.
With that in mind, in order for me to get a better context and understanding of the scenario you are experiencing, would you be able to share with us a sample document and project you are using to reproduce this behavior? This way I can try to achieve the same results on my end, investigate the issue further, try to identify the cause, and get back to you with details and feedback.
NOTE: Please keep in mind that this is a Q&A Forum thread and anything shared here will be publicly available. If you have any concerns, make sure you remove any sensitive data or replace it with a dummy one.
Thank you in advance for your cooperation. I am looking forward to your reply.
Regards,
Yoan
i use overrload of Inport that take Stream as an argument
private RadFlowDocument ConvertDocxToRadFlowDocument(Stream contentStream)
{
var docxProvider = new DocxFormatProvider();
MemoryStream destination = new MemoryStream();
RadFlowDocument document;
contentStream.CopyTo(destination);
document = docxProvider.Import(destination);
return document;
}
you should get RadFlowDocument that you can then convert to PDF
Hello Velijko,
Thank you for taking the time to share your feedback! We truly appreciate your insights and your willingness to help other users by sharing your experience. Such efforts do not go unnoticed and are truly appreciated. I hope your insights prove helpful to others who may benefit from your experience.
Regards,
Yoan