Arranging headings in bullet form is a very common approach. Aspose.Pdf provides 7 kinds of system defined bullets that can be applied on headings. UserLabel is the property of the Heading class that is used to set the bullet styles for the headings.
Aspose.Pdf allows developers to simply pass
as a string constant to the UserLabel property.
For example, set UserLabel to "Bullet1" if you want to use bullet style 1 and so on.
|
Figure: 7 System defined bullets |
The example below illustrates the use of only 3 system defined bullets, Bullet1, Bullet2 and Bullet3. Rest of the bullets can also be used following the same approach.
Code Snippet
[C#]
//Instntiate the Pdf object by calling its empty constructor
Pdf pdf1 = new Pdf();
//Create the section in the Pdf object
Section sec1 = pdf1.Sections.Add();
/*
* Create 1st heading in the Pdf object's section with level=1. Then create
* a text segment and add it in the heading. Set its UserLabel="Bullet1" to
* use system defined bullet. After setting all properties, add heading into
* the paragraphs collection of the section
*/
Heading heading1 = new Heading(pdf1,sec1,1);
Segment segment1 = new Segment(heading1);
heading1.Segments.Add(segment1);
segment1.Content = "Bullet1";
heading1.UserLabel="Bullet1";
sec1.Paragraphs.Add(heading1);
/*
* Create 2nd heading in the Pdf object's section with level=2. Then create
* a text segment and add it in the heading. Set its UserLabel="Bullet2" to
* use system defined bullet. After setting all properties, add heading into
* the paragraphs collection of the section
*/
Heading heading2 = new Heading(pdf1,sec1,2);
Segment segment2 = new Segment(heading2);
heading2.Segments.Add(segment2);
segment2.Content = "Bullet2";
heading2.UserLabel="Bullet2";
sec1.Paragraphs.Add(heading2);
/*
* Create 3rd heading in the Pdf object's section with level=3. Then create
* a text segment and add it in the heading. Set its UserLabel="Bullet3" to
* use system defined bullet. After setting all properties, add heading into
* the paragraphs collection of the section
*/
Heading heading3 = new Heading(pdf1,sec1,3);
Segment segment3 = new Segment(heading3);
heading3.Segments.Add(segment3);
segment3.Content = "Bullet3";
heading3.UserLabel="Bullet3";
sec1.Paragraphs.Add(heading3);
/*
* Prepare HttpResponse object and save the Pdf to HttpResponse object to open in
* Acrobat reader
*/
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType="application/pdf";
pdf1.Save("headings.pdf",SaveType.OpenInAcrobat,Response);
Response.End();
[VB.NET]
'Instntiate the Pdf object by calling its empty constructor
Dim pdf1 As Pdf = New Pdf()
'Create the section in the Pdf object
Dim sec1 As Section = pdf1.Sections.Add()
'*********************************************************************************
' * Create 1st heading in the Pdf object's section with level=1. Then create
' * a text segment and add it in the heading. Set its UserLabel="Bullet1" to
' * use system defined bullet. After setting all properties, add heading into
' * the paragraphs collection of the section
'*********************************************************************************
Dim heading1 As Heading = New Heading(pdf1,sec1,1)
Dim segment1 As Segment = New Segment(heading1)
heading1.Segments.Add(segment1)
segment1.Content = "Bullet1"
heading1.UserLabel="Bullet1"
sec1.Paragraphs.Add(heading1)
'*********************************************************************************
' * Create 2nd heading in the Pdf object's section with level=2. Then create
' * a text segment and add it in the heading. Set its UserLabel="Bullet2" to
' * use system defined bullet. After setting all properties, add heading into
' * the paragraphs collection of the section
'*********************************************************************************
Dim heading2 As Heading = New Heading(pdf1,sec1,2)
Dim segment2 As Segment = New Segment(heading2)
heading2.Segments.Add(segment2)
segment2.Content = "Bullet2"
heading2.UserLabel="Bullet2"
sec1.Paragraphs.Add(heading2)
'*********************************************************************************
' * Create 3rd heading in the Pdf object's section with level=3. Then create
' * a text segment and add it in the heading. Set its UserLabel="Bullet3" to
' * use system defined bullet. After setting all properties, add heading into
' * the paragraphs collection of the section
'*********************************************************************************
Dim heading3 As Heading = New Heading(pdf1,sec1,3)
Dim segment3 As Segment = New Segment(heading3)
heading3.Segments.Add(segment3)
segment3.Content = "Bullet3"
heading3.UserLabel="Bullet3"
sec1.Paragraphs.Add(heading3)
'*********************************************************************************
' * Prepare HttpResponse object and save the Pdf to HttpResponse object to open in
' * Acrobat reader
'*********************************************************************************
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType="application/pdf"
pdf1.Save("headings.pdf",SaveType.OpenInAcrobat,Response)
Response.End()
[JAVA]
//Instntiate the Pdf object by calling its empty constructor
Pdf pdf1 = new Pdf();
//Create the section in the Pdf object
Section sec1 = pdf1.getSections().add();
/*
* Create 1st heading in the Pdf object's section with level=1. Then create
* a text segment and add it in the heading. Set its UserLabel="Bullet1" to
* use system defined bullet. After setting all properties, add heading into
* the paragraphs collection of the section
*/
Heading heading1 = new Heading(pdf1, sec1, 1);
Segment segment1 = new Segment(heading1);
heading1.getSegments().add(segment1);
segment1.setContent("Bullet1");
heading1.setUserLabel("Bullet1");
sec1.getParagraphs().add(heading1);
/*
* Create 2nd heading in the Pdf object's section with level=2. Then create
* a text segment and add it in the heading. And don't forget to set
* IsAutoSequence=true.If IsAutoSeguence property is set to true then the
* heading's sequence is controlled automatically by Aspose.Pdf. After setting
* all properties, add heading into the paragraphs collection of the section
*/
Heading heading2 = new Heading(pdf1, sec1, 2);
Segment segment2 = new Segment(heading2);
heading2.getSegments().add(segment2);
segment2.setContent("Bullet2");
heading2.setUserLabel("Bullet2");
sec1.getParagraphs().add(heading2);
/*
* Create 3rd heading in the Pdf object's section with level=3. Then create
* a text segment and add it in the heading. And don't forget to set
* IsAutoSequence=true.If IsAutoSeguence property is set to true then the
* heading's sequence is controlled automatically by Aspose.Pdf. After setting
* all properties, add heading into the paragraphs collection of the section
*/
Heading heading3 = new Heading(pdf1, sec1, 3);
Segment segment3 = new Segment(heading3);
heading3.getSegments().add(segment3);
segment3.setContent("Bullet3");
heading3.setUserLabel("Bullet3");
sec1.getParagraphs().add(heading3);
[XML]
<?xml version="1.0" encoding="utf-8" ?>
<Pdf xmlns="Aspose.Pdf">
<Section>
<Heading Level="1" UserLabel="Bullet1">
<Segment>Bullet1</Segment>
</Heading>
<Heading Level="2" UserLabel="Bullet2">
<Segment>Bullet2</Segment>
</Heading>
<Heading Level="3" UserLabel="Bullet3">
<Segment>Bullet3</Segment>
</Heading>
</Section>
</Pdf>