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)
When you have indented and justified text, it is wrongly exported to PDF:
<w:pPr>
<w:spacing w:after="0" w:line="360" w:lineRule="auto"/>
<w:ind w:left="567" w:right="567" w:firstLine="708"/>
<w:jc w:val="both"/>
<w:rPr>
<w:rFonts w:ascii="Calibri Light" w:hAnsi="Calibri Light"/>
</w:rPr>
</w:pPr>
<w:r w:rsidRPr="00CB6D35">
<w:rPr>
<w:rFonts w:ascii="Calibri Light" w:hAnsi="Calibri Light"/>
<w:b/>
<w:u w:val="double"/>
</w:rPr>
<w:t>DETTAGLIO SINISTRO</w:t>
</w:r>
(DIPs) is a unit type used in RadWordsProcessing when setting the FontSize of a Run. If you load a document with font size in WordPad set to 20 points and load it to RadFlowDocument, its value is converted by using the following method. If the RTF content stored from WordPad is saved to HTML format with WordPad, the font size is preserved with the same unit: style='font-size:20.0pt;'. We should add the option to control the font size unit when exporting to HTML format.
Generate a document with the following approach: https://docs.telerik.com/devtools/document-processing/knowledge-base/populate-table-data-mail-merge
Before calling MailMerge, add two document variables with the editor: https://docs.telerik.com/devtools/document-processing/libraries/radwordsprocessing/concepts/fields/document-variables
Replace cannot match whole word with special characters (e.g. "#", "@", "&") at the start/end.
Workaround (RegEx):
editor.ReplaceText(new Regex($"(?<=\\s|^|[\\c_]){placeholder}(?=\\s|$|[\\c_])"),"new content");