We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Multiple sections on a page?

We need to have pages with mixed sections, i.e. 1-column layout for half the page, with a 2-column layout beneath that. Unfortunately creating a new section automatically starts a new page.

How can we get both types of layout on one page?

Hello Mark,

Thanks for using our products.

In order to accomplish your requirement, set the value of IsNewPage property of second Section object to False. In order to have multiple columns in a section, you need to use ColunInfo class. Please take a look over the following code snippet and the resultant PDF that I have generated using Aspose.Pdf for .NET 4.6.0.

[C#]

//Instantiate Pdf instance by calling its empty constructor
Pdf pdf1 = new Pdf();
//Create a new section in the Pdf object
Aspose.Pdf.Section Section1 = pdf1.Sections.Add();
Text sampletext = new Text("Sample text in section 1 which is Single Column");
sampletext.TextInfo.FontSize = 20;
sampletext.TextInfo.Color = new Aspose.Pdf.Color("Blue");
Section1.Paragraphs.Add(sampletext);

// Create a new section and add it to Pdf object
Aspose.Pdf.Section Section2 = pdf1.Sections.Add();
//Set the number of columns in the section to 2
Section2.ColumnInfo.ColumnCount = 2;
//Set the widths of the columns
Section2.ColumnInfo.ColumnWidths = "180 180";
//Set the spacing between the columns
Section2.ColumnInfo.ColumnSpacing = "5";
// Set the property value so that section is not displayed over second page
Section2.IsNewPage = false;
// Create a text object to be placed inside First column of second section
Text FirstColumnText = new Text("In magazines and newspapers, we mostly see that news are displayed in multiple columns on the single pages instead of the books where text paragraphs are mostly printed on the whole pages from left to right position. Many document processing applications like Microsoft Word and Adobe Acrobat Writer allow users to create multiple columns on a single page and then add data to them. Using Aspose.Pdf for .NET , developers can also add multiple columns to the pages of their PDF documents. As we know that we always add Paragraphs to Sections of our PDF documents using Aspose.Pdf for .NET . So, it is necessary to divide a Section into multiple columns and this is achieved by Section.ColumnInfo property, which is used to specify the column related information for each Section . This column information would include the width and spacing of columns etc. In magazines and newspapers, we mostly see that news are displayed in multiple columns on the single pages instead of the books where text paragraphs are mostly printed on the whole pages from left to right position. Many document processing applications like Microsoft Word and Adobe Acrobat Writer allow users to create multiple columns on a single page and then add data to them. Using Aspose.Pdf for .NET , developers can also add multiple columns to the pages of their PDF documents. As we know that we always add Paragraphs to Sections of our PDF documents using Aspose.Pdf for .NET . So, it is necessary to divide a Section into multiple columns and this is achieved by Section.ColumnInfo property, which is used to specify the column related information for each Section . This column information would include the width and spacing of columns etc. In magazines and newspapers, we mostly see that news are displayed in multiple columns on the single pages instead of the books where text paragraphs are mostly printed on the whole pages from left to right position. Many document processing applications like Microsoft Word and Adobe Acrobat Writer allow users to create multiple columns on a single page and then add data to them. Using Aspose.Pdf for .NET , developers can also add multiple columns to the pages of their PDF documents. As we know that we always add Paragraphs to Sections of our PDF documents using Aspose.Pdf for .NET . So, it is necessary to divide a Section into multiple columns and this is achieved by Section.ColumnInfo property, which is used to specify the column related information for each Section . This column information would include the width and spacing of columns etc.");

Section2.Paragraphs.Add(FirstColumnText);
//save the document
pdf1.Save(@"d:/pdftest/MultipleSections_SinglePage.pdf");

For more related information, please visit Manipulating Multiple Columns

I would also recommend you to visit the following thread to see the discussion over related topic. 188578

In case I have not properly understood your requirement or you have any further query, please feel free to contact.

hey Nayyer, thanks for the prompt and informative reply. I must have overlooked that property!

We are evaluating Aspose PDF, having found our previous tool wasn’t up to the job for this project. So far we like what we see - just what we need.

I will have a few more questions over the next week or so :slight_smile:

Thanks again
Mark

Hello Mark,

I am glad to hear that your problem is resolved. However, if you have any further query, please feel free to contact and we would be more than happy to assist you in that regard.

works like a charm, thanks again.

further to this, how would you suggest we get some whitespace between sections? If I use page margins it works on the first page, but if the section spills into another page, the margins are all wrong.

I also tried adding HTML (i.e.

) to to the bottom of the section which works - just wondering if that is the best way?

thanks :slight_smile:
Mark

Hello Mark,

Thanks for using our products.

Please visit the following links for information on how to Set Page Size and Margins

In order to have a line break or page break, you can use the special replaceable characters of Aspose.Pdf. For more related information, please visit Replaceable Symbols

In case of any further query, please feel free to contact.