Declined
Last Updated: 19 Jul 2021 07:19 by ADMIN
Rakesh
Created on: 14 Jul 2021 06:16
Category: PdfProcessing
Type: Bug Report
0
Telerik pdfprovider export html spacing issue

Hello Support,

I am generating pdf using PdfFormatProvider. In this i am passing html data which should be converted into pdf. For that I have written below code.

 

HtmlFormatProvider htmlFormatProvider = new HtmlFormatProvider();

RadFlowDocument htmlDocument = htmlFormatProvider.Import(htmlContentValue);

 var anotherpara = sectionBody.Blocks.AddParagraph();

editor.MoveToParagraphStart(anotherpara);

editor.InsertDocument(htmlDocument, options);

This works fine and also get pdf with expected value. But I would like to set spacing between two lines which I could not set or its not working. For that I have added below code.

I have also attached screenshot for it. like how its showing on pdf

editor.ParagraphFormatting.AutomaticSpacingAfter.LocalValue = false;
editor.ParagraphFormatting.AutomaticSpacingBefore.LocalValue = false;
editor.ParagraphFormatting.SpacingAfter.LocalValue = 0;
editor.ParagraphFormatting.SpacingBefore.LocalValue = 0;

 

So could you please let me know fix for it.

Attached Files:
1 comment
ADMIN
Martin
Posted on: 19 Jul 2021 07:19

Hi Rakesh,

Thank you for sharing the feedback and the code snippets with us. This helped me to reproduce the described behavior.

When inserting a whole document the editor`s ParagraphFormatting properties are not taken into account because they are already set in the imported document. An option to set this spacing is to iterate the RadFlowDocument's content and change these properties before inserting it into the target document. Check the following code snippet:

RadFlowDocument htmlDocument = htmlFormatProvider.Import(htmlContentValue);

IEnumerable<Paragraph> paragraphs = htmlDocument.EnumerateChildrenOfType<Paragraph>();
foreach (Paragraph paragraph in paragraphs)
{
	paragraph.Spacing.AutomaticSpacingBefore = false;
	paragraph.Spacing.AutomaticSpacingAfter = false;
	paragraph.Spacing.SpacingBefore = 0;
	paragraph.Spacing.SpacingAfter = 0;
}

RadFlowDocument targetDocument = new RadFlowDocument();
Section sectionBody = targetDocument.Sections.AddSection();
Paragraph anotherpara = sectionBody.Blocks.AddParagraph();

InsertDocumentOptions options = new InsertDocumentOptions();
RadFlowDocumentEditor editor = new RadFlowDocumentEditor(targetDocument);
editor.MoveToParagraphStart(anotherpara);
editor.InsertDocument(htmlDocument, options);

I am attaching the sample project I created to test this functionality as well. Please, feel free to modify it in a way closer to your scenario.

I hope this helps. I am rejecting this bug report but if the suggested approach doesn't satisfy your scenario, please, do not hesitate to write us back.

Regards,
Martin
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Attached Files: