This is caused by hasSize field in ShapeBase class which is set when decoding the image size. However, when SetWidth and SetHeight methods are called before the size is initialized the value of hasSize is false which causes the issue. Workaround: Call the Size property getter before calling SetWidth/SetHeight method. See the code below: // This line workarounds the issue with SetWidth method which does not get the correct size when locking aspect ratio. Size size = imageInline.Image.Size; imageInline.Image.SetWidth(true, width);
Currently empty paragraphs are exported to HTML with one space inside. Such paragraphs are not rendered by the browser. Such paragraph should be exported to HTML with one non-breaking space (@nbsp;) inside to ensure that they are visible in the browser.
Workaround: manually add nbsp-s in all empty paragraphs:
paragraph.Inlines.AddRun("\u00a0");
Steps to reproduce:
- Create document with empty paragraphs:
var document = new RadFlowDocument();
Section section = document.Sections.AddSection();
section.Blocks.AddParagraph();
section.Blocks.AddParagraph();
section.Blocks.AddParagraph();
section.Blocks.AddParagraph().Inlines.AddRun("test");
- Export it to HTML.
- Load the HTML in a browser.
Expected: The word 'test' is preceded by 3 empty rows.
Actual: The word 'test' is on the first row.
The issue is reproducible only in a specific setup with a specific document. It is related to the calculations of the line spacing when the table row should be split between two pages.
Workaround: Change the line spacing:
foreach (var paragraph in this.document.EnumerateChildrenOfType<Paragraph>())
{
paragraph.Properties.LineSpacingType.LocalValue = HeightType.Auto;
paragraph.Properties.LineSpacing.LocalValue = 1;
}
Some PDF files have an additional content added before the file header (before %PDF-1.4 for example). This additional content makes all byte offsets in the document invalid, which causes the format provider to throw an exception. At this point, to import a similar document it should be pre-processed so the content before the version header is removed before importing it.
Content is moved from the second page to the first after applying styling to the footer and exporting to PDF format
During export operation of a document that contains signature fields the following error occurs:
System.InvalidOperationException: 'The signature was not properly initialized for external signing. The signing delegate is missing.'Resaving a document with Acrobat throws an error due to invalid Info dictionary in document trailer.
<w:sdt>
<w:sdtPr>
<w:text w:multiLine="1"/>
</w:sdtPr>
<w:sdtContent>
<w:r>
<w:t>Line 1</w:t>
</w:r>
<w:r>
<w:br/>
</w:r>
<w:r>
<w:t>Line 2</w:t>
</w:r>
</w:sdtContent>
</w:sdt>This is the code for reproducing the incorrect PDF document. If the step with changing the font is commented, the document is exported properly:
//Step 1: Create an instance of XlsxFormatProvider to import the Excel file
XlsxFormatProvider xlsxFormatProvider = new XlsxFormatProvider();
Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf.PdfFormatProvider pdfFormatProvider = new Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf.PdfFormatProvider();
Workbook workbook;
using (FileStream input = new FileStream("Input.xlsx", FileMode.Open))
{
workbook = xlsxFormatProvider.Import(input, TimeSpan.FromSeconds(10));
}
//Step 2: Export the workbook to PDF RadFixedDocument to modify fonts
Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf.PdfFormatProvider spread_pdf_provider = new Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf.PdfFormatProvider();
RadFixedDocument fixedDocument = spread_pdf_provider.ExportToFixedDocument(workbook, TimeSpan.FromSeconds(10));
foreach (var page in fixedDocument.Pages)
{
foreach (var content in page.Content)
{
if (content is TextFragment text)
{
// Replace the font with Helvetica or HelveticaBold based on the original font style
text.Font = text.Font.Name.ToLower().Contains("bold")
? FontsRepository.HelveticaBold
: FontsRepository.Helvetica;
}
}
}
//Step 3: Save the modified RadFixedDocument back to PDF
string outputFileName = "ExportedWorkbook.pdf";
Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider fixed_pdf_provider = new Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider();
using (FileStream output = new FileStream(outputFileName, FileMode.Create))
{
fixed_pdf_provider.ExportSettings.DocumentUnhandledException += ExportSettings_DocumentUnhandledException;
fixed_pdf_provider.ExportSettings.FontEmbeddingType = Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.FontEmbeddingType.Subset;
fixed_pdf_provider.Export(fixedDocument, output, TimeSpan.FromSeconds(10));
}
Process.Start(new ProcessStartInfo() { FileName = outputFileName, UseShellExecute = true });
When importing a large document (e.g. 2.3GB) , the library fails to parse int value that exceeds the limit which leads to endless importing:
LocalizableException is thrown after removing columns from a workbook with set Print Titles.
Workaround - Remove the PrintTitles before removing the columns:
WorksheetPageSetup pageSetup = workbook.ActiveWorksheet.WorksheetPageSetup;
pageSetup.PrintTitles.RepeatedRows = null;
pageSetup.PrintTitles.RepeatedColumns = null;
HtmlFormatProvider: Styles are not correctly preserved when a <b> tag is applied to the same styled element.
Workaround: Apply bold through CSS instead of using <b>.