write content in 2 columns structure

Hi,

Not sure how this can be done. But maybe there's an easy way..

My PDF pages have a 2 columns layout. Imagine this like an article in a newspaper, where you write the text in the left column till it runs out of space and then you continue in the right one.

I imagine this can be achieved using a 2 columns table with a single row that spans across the entire page's height. But that will cause issues, since I need to somehow calculate when I ran out of space on the left and then to break the content and continue on the right column.

Is there a simpler way? Maybe some setting that lets me set the width of those columns and then the text just continues on the right column when needed?

I hope that makes sense..

Thanks!

3 Replies

GM Geetha M Syncfusion Team February 4, 2013 04:41 AM UTC

Hi David,

Thank you for your interest in Syncfusion products.

It is possible to write the data in two columns using the PdfTextElement class and it page layout events. Here is the code snippet:

PdfTextElement element = new PdfTextElement(inputText);

element.BeginPageLayout += new BeginPageLayoutEventHandler(element_BeginPageLayout);

element.EndPageLayout += new EndPageLayoutEventHandler(element_EndPageLayout);

element.Font = new PdfStandardFont(PdfFontFamily.Helvetica, 8f);

static void element_EndPageLayout(object sender, EndPageLayoutEventArgs e)

{

    samePage = !samePage;

    if (samePage)

        e.NextPage = tempPage;

}

 

static void element_BeginPageLayout(object sender, BeginPageLayoutEventArgs e)

{

    tempPage = e.Page;

    if (samePage)

    {

        SizeF size = e.Page.Graphics.ClientSize;

        e.Bounds = new RectangleF(new PointF(size.Width / 2 + 10, 0), new SizeF(size.Width / 2 - 10, size.Height));

    }

}

 

The simple sample showing this is placed in the link below.

Please try this and let us know if you have any questions.

Regards

Geetha



ColumnLayout_39275dc3.zip


MG Matej Grabnar July 11, 2019 10:22 AM UTC

Hi,

the link to sample zip file is not working.

Regards, Matej.


SL Sowmiya Loganathan Syncfusion Team July 12, 2019 12:58 PM UTC

Hi Matej, 

We have created the sample to achieve the requirement for “Write content in two column structure”. Please find the sample for the same from below link, 


Please try the sample in your end and let us know if it solves the issue. 

Regards, 
Sowmiya L 


Loader.
Up arrow icon