Multiple sections on a page?

Last post 09-02-2010, 1:28 AM by codewarior. 5 replies.
Sort Posts: Previous Next
  •  08-31-2010, 9:15 PM 256471

    Multiple sections on a page? .NET

    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?

     
  •  09-01-2010, 1:43 AM 256493 in reply to 256471

    Re: Multiple sections on a page?

    Attachment: Present (inaccessible)

    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.


    Nayyer Shahbaz
    Support Developer, Aspose Sialkot Team
    About Us
    Contact Us

    Keep in touch! We're on Twitter and Facebook
     
  •  09-01-2010, 4:41 AM 256530 in reply to 256493

    Re: Multiple sections on a page?

    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 :)

    Thanks again
    Mark

     
  •  09-01-2010, 6:19 AM 256560 in reply to 256530

    Re: Multiple sections on a page?

    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.


    Nayyer Shahbaz
    Support Developer, Aspose Sialkot Team
    About Us
    Contact Us

    Keep in touch! We're on Twitter and Facebook
     
  •  09-01-2010, 8:37 PM 256704 in reply to 256560

    Re: Multiple sections on a page?

    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. <br /><br />) to to the bottom of the section which works - just wondering if that is the best way?

    thanks :)
    Mark

     
  •  09-02-2010, 1:28 AM 256729 in reply to 256704

    Re: Multiple sections on a page?

    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.


    Nayyer Shahbaz
    Support Developer, Aspose Sialkot Team
    About Us
    Contact Us

    Keep in touch! We're on Twitter and Facebook
     
View as RSS news feed in XML