When xlsx/docx document is imported, and its main story is with non-default name ('workbook. xml'/'document.xml'), e.g. workbook2.xml/document2.xml, NullReferenceException is thrown and the document is not imported. Note: Such documents are usually produced after conversion from a template dotx/xlsm.
The value of the TextBoxField is not visible until the field is clicked.
Workaround: Force content update:
foreach (var widget in textBoxField.Widgets)
{
widget.RecalculateContent();
}
If the update still doesn't fix the issue, change the font prior to setting the value of the field:
foreach (var widget in textBoxField.Widgets)
{
widget.TextProperties.Font = FontsRepository.Helvetica;
}
Hi there I have a pdf and whenever I try to Import the PDF file into PdfFormatProvider.Import method for flattening purposes, it throws null reference exception.
I have added a sample .net project with PDF added as source. You just need to run the project on your end. I am using version 2023.3.1106 of document processing library.
I am using ASP.NET 4.8 framework.
Thanks
Hi,
We are using HTMLFormatProvider and PDFFormatProvider for converting HTML string to PDF file. The below issues are identified while converting PDF.
1. Text Foreground and Background color is not working in pdf.
HTML:
<p><span style="color: rgb(216, 55, 98); background-color: rgb(28, 122, 144); font-size: 30px;">Test</span></p>
We get the same issue even though we added below code.
foreach (Run run in document.EnumerateChildrenOfType<Run>()) { if (!run.Properties.HighlightColor.HasLocalValue) { run.HighlightColor = run.Shading.BackgroundColor.LocalValue; } }
Attached the PDF file
2. Strikeout is not working in PDF
Sample HTML:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<p><span style="font-size: 24px;"><del>Delete Strike Through line in the paragraph</del></span></p>
</body>
</html>
attached the PDF file .
It would be appreciated , if you provide the solution for those issues
Regards,
Babu
The table styles are not imported correctly from HTML. The back color is not respected. The column width is incorrect. The font size is different.
Font is not in proper case- All the cases are in lower case
When calling a PDF export in a high-concurrency environment the internal state can get corrupted because it uses a non-thread safe collection internally.
Sample code:
void WriteToPdf(RadFlowDocument document, Stream outputStream) {
PdfFormatProvider pdfWriter = new() {};
pdfWriter.Export(document, outputStream);
}
When calling it like this:
Parallel.ForEachAsync(listOfDocuments, (document, _) => { WriteToPdf(document, Stream.Null); });
An exception may occur:
System.InvalidOperationException: Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.
at System.Collections.Generic.Dictionary`2.FindValue(TKey key)
at Telerik.Windows.Documents.Fixed.Model.Fonts.FontsRepository.TryCreateFont(FontFamily fontFamily, FontStyle fontStyle, FontWeight fontWeight, FontBase& font)
at Telerik.Windows.Documents.Flow.FormatProviders.Pdf.Utils.Extensions.CopyPropertiesFrom(CharacterProperties fixedProperties, PdfExportContext context, CharacterProperties properties)
at Telerik.Windows.Documents.Flow.FormatProviders.Pdf.Export.PdfExporter.CreateListLevel(ListLevel flowLevel)
at Telerik.Windows.Documents.Flow.FormatProviders.Pdf.Export.PdfExporter.CreateList(List flowList)
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.Common.FormatProviders.FormatProviderBase`1.Export(T document, Stream output)
at xxxxx.Application.Common.PdfGeneration.PdfWriter.WriteToPdf(RadFlowDocument document, Stream outputStream)
The state is then corrupted forever, until the application is restarted.
Realistic scenario where this is also reproduced: Web application that generates PDFs and is called concurrently.
InvalidCastException 'Unable to cast object of type 'EffectContainerElement' to type 'EffectListElement' is thrown on import.
As a workaround, you can either use the old version of the assemblies (R2 2022) or you can set ImportSettings.SkipShapes of the DocxFormatProvider to true.