We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

write content in 2 columns structure

Thread ID:

Created:

Updated:

Platform:

Replies:

106851 Jan 29,2013 01:04 AM Feb 3,2013 11:41 PM ASP.NET MVC (Classic) 1
loading
Tags: PDF
David Treves
Asked On January 29, 2013 01:04 AM

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!

Geetha M [Syncfusion]
Replied On February 3, 2013 11:41 PM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;