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

IBlockElement Split() example

1 Answer 47 Views
PdfProcessing
This is a migrated thread and some comments may be shown as answers.
Sandeep
Top achievements
Rank 1
Sandeep asked on 02 Dec 2014, 10:41 AM
Hi,

Can i get some example of the usage of the IBlockElement Split() function.

Regards,
Sandeep

1 Answer, 1 is accepted

Sort by
0
Deyan
Telerik team
answered on 02 Dec 2014, 04:43 PM
Hello Sandeep,

Thank you for contacting us.

The IBlockElement interface is designed to be used in the following scenario:
  • Measure some block element in a desired size.
  • Draw the element in the desired size and position.
  • Split the element when there is any pending content that needs to be drawn.
The following code snippet shows how to split some long text and draw its parts one below the other. The code uses Block class which implements the IBlockElement interface.
RadFixedDocument document = new RadFixedDocument();
FixedContentEditor editor = new FixedContentEditor(document.Pages.AddPage());
editor.GraphicProperties.IsFilled = false;
editor.GraphicProperties.IsStroked = true;
Block block = new Block();
block.InsertText("Some long text that will be split!");
double splitWidth = 50;
double height = 10;
bool hasPendingContent;
 
do
{
    Size desiredSize = block.Measure(new Size(splitWidth, 0));
    Rect rectangle = new Rect(10, height, splitWidth, desiredSize.Height);
    editor.DrawRectangle(rectangle);
    block.Draw(editor, rectangle);
    height += 10 + rectangle.Height;
 
    hasPendingContent = block.HasPendingContent;
 
    if (hasPendingContent)
    {
        block = block.Split();
    }
}
while (hasPendingContent);

I hope this is helpful.

Regards,
Deyan
the Telerik team
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
PdfProcessing
Asked by
Sandeep
Top achievements
Rank 1
Answers by
Deyan
Telerik team
Share this question
or