Aspose.Pdf

Render the Paragraph in a New Page

Aspose.Pdf provides the flexibility for the developers to render a Paragraph into a new page. Every Paragraph has an IsFirstParagraph property that us used to force the Paragraph to be rendered in a new page.

 

All you have to do, is to set the IsFirstParagraph property of a specified Paragraph to true and that Paragraph will be rendered in a new page.

 

Example:

 

[C#]

 

//Instantiate Pdf instance by calling its empty constructor

Pdf pdf1 = new Pdf();

 

//Create a section in the Pdf document

Section sec1 = pdf1.Sections.Add();

 

//Add a text paragraph in the section

sec1.Paragraphs.Add(new Text("page 1"));

 

//Create another text paragraph that has to be rendered

Text t2 = new Text("page2");

 

//Set the IsFirstParagraph property of the text paragraph to true

//to render it to a new page

t2.IsFirstParagraph = true;

 

//Add the text paragraph to be rendered to the section

sec1.Paragraphs.Add(t2);

 

//Save the Pdf document

pdf1.Save("HelloWorld.pdf");

 

[VB.NET]

 

'Instantiate Pdf instance by calling its empty constructor

Dim pdf1 As Pdf = New Pdf()

 

'Create a section in the Pdf document

Dim sec1 As Section = pdf1.Sections.Add()

 

'Add a text paragraph in the section

sec1.Paragraphs.Add(New Aspose.Pdf.Text("page 1"))

 

'Create another text paragraph that has to be rendered

Dim t2 As Aspose.Pdf.Text = New Aspose.Pdf.Text("page2")

 

'Set the IsFirstParagraph property of the text paragraph to true

'to render it to a new page

t2.IsFirstParagraph = True

 

'Add the text paragraph to be rendered to the section

sec1.Paragraphs.Add(t2)

 

'Save the Pdf document

pdf1.Save("HelloWorld.pdf")

 

[XML]

 

<Pdf xmlns="Aspose.Pdf">

     <Section>

         <Text>

             <Segment>page 1</Segment>

         </Text>

         <Text IsFirstParagraph="true">

             <Segment>page 2</Segment>

         </Text>

     </Section>

</Pdf>