This is a migrated thread and some comments may be shown as answers.

How to insert a List using FixedContentEditor

2 Answers 44 Views
PdfProcessing
This is a migrated thread and some comments may be shown as answers.
Giorgio
Top achievements
Rank 1
Giorgio asked on 21 Mar 2017, 02:47 PM

Hi,
I'm trying to insert a bullet list in a RadFixedPage using the FixedContentEditor object.

I understood how to do using the RadFixecDocumentEditor object. Please find a very small example here below:
List list = editor.Lists.AddList(ListTemplateType.BulletDefault);
editor.ParagraphProperties.ListId = list.Id;
editor.ParagraphProperties.ListLevel = 0;
editor.InsertParagraph();
editor.InsertLine("Item 1");
editor.InsertParagraph();
editor.InsertLine("Item 2");
editor.InsertParagraph();
...

But I tried in all ways that I could but I didn't understand in the documentation how to do the same using the FixedContentEditor class.

Could you please give me a short example that shows how to insert a List in a RadFixedPage using the FixedContentEditor class?

Thanks in advance

Giorgio

2 Answers, 1 is accepted

Sort by
0
Tanya
Telerik team
answered on 24 Mar 2017, 11:33 AM
Hi Giorgio,

You can insert a paragraph with a list applied using the Block class and then draw this block with the methods of FixedContentEditor. This should be repeated for each list level you would like to insert:
FixedContentEditor editor = new FixedContentEditor(this.pdfDocument.Pages.AddPage());
List list = new List(ListTemplateType.BulletDefault);
 
double currentOffsetY = 0;
for (int i = 0; i < 3; i++)
{
    Block block = new Block();
    block.SetBullet(list, i);
    block.InsertText("Sample block text " + i);
 
    editor.DrawBlock(block);
    block.Measure();
    currentOffsetY += block.ActualSize.Height;
    editor.Position.Translate(0, currentOffsetY);
}

The tricky part here is that the list style is applied to the Block instance and inserting different list items should be done using different Block instances. I updated the related information in our documentation and added some Telerik points to your account as a token of appreciation for bringing this to our attention.

I hope this is helpful.

Regards,
Tanya
Telerik by Progress

0
Giorgio
Top achievements
Rank 1
answered on 24 Mar 2017, 04:47 PM

Hi Tanya,

Many thanks for your help.

Best regards,

Giorgio

Tags
PdfProcessing
Asked by
Giorgio
Top achievements
Rank 1
Answers by
Tanya
Telerik team
Giorgio
Top achievements
Rank 1
Share this question
or