Unplanned
Last Updated: 13 Jan 2026 09:07 by ADMIN
Greg
Created on: 17 Jan 2025 17:56
Category: WordsProcessing
Type: Bug Report
1
WordsProcessing: PdfFormatProvider exception width should be greater than or equal to 0

Getting an exception message when trying to view a document as a PDF using the PdfFormatProvider which started happening only after upgrading Telerik to the latest version, 7.1.0 in Telerik UI for Blazor.

Exception Message:

width should be greater or equal than 0. (Parameter 'width')

I have copied the stack trace and source of the exception below:

 

Source: Telerik.Documents.Fixed

Stack Trace:    at Telerik.Windows.Documents.Fixed.Model.Editing.Layout.ContentElementLayoutElementBase`1.DrawHighlights(DrawLayoutElementContext context)
   at Telerik.Windows.Documents.Fixed.Model.Editing.Layout.ContentElementLayoutElementBase`1.Draw(DrawLayoutElementContext context)
   at Telerik.Windows.Documents.Fixed.Model.Editing.Block.Draw(IEnumerable`1 lineElements, DrawLayoutElementContext context)
   at Telerik.Windows.Documents.Fixed.Model.Editing.Block.DrawInternal(FixedContentEditor editor, Rect boundingRect)
   at Telerik.Windows.Documents.Fixed.Model.Editing.Block.Telerik.Windows.Documents.Fixed.Model.Editing.Flow.IDrawArrangedElement.DrawArrangedElement(FixedContentEditor editor, Rect boundingRect)
   at Telerik.Windows.Documents.Fixed.Model.Editing.Flow.SectionInfo.DrawArrangedElement(IBlockElement blockElement, Double horizontalOffset, Double verticalOffset)
   at Telerik.Windows.Documents.Fixed.Model.Editing.Utils.SectionInfoExtensions.DrawArrangedElements(SectionInfo section, IList`1 elements)
   at Telerik.Windows.Documents.Fixed.Model.Editing.RadFixedDocumentEditor.Draw()
   at Telerik.Windows.Documents.Fixed.Model.Editing.RadFixedDocumentEditor.StartNewPage(SectionProperties sectionProperties)
   at Telerik.Windows.Documents.Fixed.Model.Editing.RadFixedDocumentEditor.StartNewPage()
   at Telerik.Windows.Documents.Fixed.Model.Editing.RadFixedDocumentEditor.AddBlock(IBlockElement blockElement, CancellationToken cancellationToken)
   at Telerik.Windows.Documents.Flow.FormatProviders.Pdf.Export.PdfExporter.ExportSection(Section section, RadFixedDocumentEditor editor)
   at Telerik.Windows.Documents.Flow.FormatProviders.Pdf.Export.PdfExporter.ExportDocument(RadFlowDocument document, RadFixedDocumentEditor editor)
   at Telerik.Windows.Documents.Flow.FormatProviders.Pdf.Export.PdfExporter.ExportInternal()
   at Telerik.Windows.Documents.Flow.FormatProviders.Pdf.Export.PdfExporter.Export()
   at Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider.ExportToFixedDocument(RadFlowDocument document, CancellationToken cancellationToken)
   at Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider.ExportOverride(RadFlowDocument document, Stream output, CancellationToken cancellationToken)
   at Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider.ExportOverride(RadFlowDocument document, Stream output)
   at Telerik.Windows.Documents.Common.FormatProviders.FormatProviderBase`1.Export(T document, Stream output)
   at Telerik.Windows.Documents.Common.FormatProviders.BinaryFormatProviderBase`1.Export(T document)

5 comments
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 13 Jan 2026 09:07

Hello, Paul,

Thank you for sharing your workaround and code sample for resolving the "width should be greater or equal than 0" exception during Word to PDF conversion. Adjusting paragraph indentation as shown in your code can indeed resolve the issue for documents where problematic indentation values are present.

However, please note that this solution may not be universally applicable to all documents. The underlying cause of the exception can vary depending on the specific formatting and content in each file. For example, font size, paragraph properties, and layout differences between documents can lead to different results. Managing the font size or indentation may fix one document, but the same settings might not work for another.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Paul
Posted on: 12 Jan 2026 12:02

Hi, I got the same error message and managed to fix it, but I'm not sure if the solution also applies to your situation. In my case, I was converting a Word document to PDF, which resulted in the error message: `width should be greater or equal than 0`.

To fix it, I applied the code sample below to the Word document before converting it. Then I converted it, and everything worked.

byte[] savedDocumentBytes = ReadFileBytes( "sefdsf_v8.docx" );

RadDocument radDocument = RadDocumentDocxFormatProvider.Import( savedDocumentBytes );

var paragraphs = radDocument.EnumerateChildrenOfType<Telerik.Windows.Documents.Model.Paragraph>();

foreach (var paragraph in paragraphs)
{
    var convertedValue = Unit.DipToTwip(paragraph.LeftIndent);
    convertedValue = Math.Round(convertedValue);

    paragraph.LeftIndent = Unit.TwipToDip(convertedValue);

}

savedDocumentBytes = RadDocumentDocxFormatProvider.Export(radDocument);

RadFlowDocument radFlowDocument = FlowDocumentDocxFormatProvider.Import(savedDocumentBytes, null);

 

ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 21 Jan 2025 16:20

Hi, Greg,

The provided sample document is greatly appreciated. I was able to replicate the described error message. Hence, the status of this item is changed accordingly. It seems to be reproducible only when using the .NET Standard version of RadWordsProcessing when exporting to PDF format. It works properly with .NET Framework. 

I have also updated your Telerik points for bringing this to our attention.

Due to the specificity of the issue, I am unable to suggest an appropriate solution. I have increased the priority of this item so we will do our best to address it accordingly. Please excuse us for any inconvenience it may be causing to the overall experience of your project.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Greg
Posted on: 20 Jan 2025 21:24

Hi Dess,

Thank you for your response, please find attached a zip file containing a sample of the file that causes the exception. I have copied below a sample code snippet where the exception would occur at the last line where I would try to process the document which is originally saved as a byte array in a Docx format but would throw this exception when trying to format the document as a PDF to be later used to source the data for the TelerikPdfViewer component used in the Blazor application to display the document. Other documents haven't had any issue and this case only started occurring for this document after upgrading Telerik in the Blazor application. Let me know if there's anything else needed.

 

Telerik.Windows.Documents.Flow.FormatProviders.Docx.DocxFormatProvider docXProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Docx.DocxFormatProvider();
RadFlowDocument document = docXProvider.Import(originalDocBytes);
Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider pdfProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();
TestPDF = pdfProvider.Export(document);
Attached Files:
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 20 Jan 2025 07:11

Hi, Greg,

I am sorry to hear that you are facing any difficulties with our PdfProcessing library. However, according to the provided stack trace, it wouldn't be easy to determine what is reason for this undesired behavior. Could you please elaborate? 

It is hard for us to investigate the issues without actually having the problematic file. Please try and prepare a sample file without the sensitive information since it is a public feedback item.

If you decide you can also send us the original file by submitting a private support ticket from your Telerik account. You can be certain that it will be used only for investigation purposes of this case and your privacy will be respected.  
Looking forward to your reply. 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.