Background Color:
 
Background Pattern:
Reset
Search
Home Recent Changes Show All Pages

Headings, H1 - H6

Not Rated Yet

Headings add visual structure to a document.
Within scryber headings are container components (just like Div's, Span's and Para's they inherit from PDFPanel) that are by default rendered as blocks, so will always appear on their own line and take on borders, backgrounds, padding and margins. They do have a convenience '@text' property which can be specified or bound to.

Contents

Standard Headings

Out of the box there are 6 headings H1 - H6 that each have their own default style

    <pdf:Page id="MyFirstPage" style:margins="10pt" style:font-size="12pt" >
      <Content>
        <pdf:H1 text="This is H1" />
        <pdf:H2 text="This is H2" />
        <pdf:H3 text="This is H3" />
        <pdf:H4 text="This is H4" />
        <pdf:H5 text="This is H5" />
        <pdf:H6 text="This is H6" />
        And this is just some text
        </Content>
    </pdf:Page>
   PDFDocument doc = new PDFDocument();

            
            PDFPage page = new PDFPage();
            page.FontFamily = "Times";
            page.FontSize = 12;
            page.HorizontalAlignment = HorizontalAlignment.Right;
            page.VerticalAlignment = VerticalAlignment.Middle;
            doc.Pages.Add(page);

            PDFHead1 h1 = new PDFHead1();
            h1.Text = "This is H1";
            page.Contents.Add(h1);

            PDFHead2 h2 = new PDFHead2();
            h2.Text = "This is H2";
            page.Contents.Add(h2);

            PDFHead3 h3 = new PDFHead3();
            h3.Text = "This is H3";
            page.Contents.Add(h3);

            PDFHead4 h4 = new PDFHead4();
            h4.Text = "This is H4";
            page.Contents.Add(h4);

            PDFHead5 h5 = new PDFHead5();
            h5.Text = "This is H5";
            page.Contents.Add(h5);

            PDFHead6 h6 = new PDFHead6();
            h6.Text = "This is H6";
            page.Contents.Add(h6);

            page.Contents.Add(new PDFTextLiteral("And this is just some text"));

Preview Image

Class Hierarchy

All the heading classes derive from the PDFHeadingBase class, which in turn inherits from the PDFPanel class.

Preview Image

 

Applying Styles

So it is possible to apply a global style to the headings, and then individual styles to each of the heading items. The headings are fully qualified block components, so support inline styling options and block level styles The text attribute is also available on the heading for convenience - and injects a text literal in the contents of the heading.

    <style:Style applied-type="pdf:Heading" >
      <style:Font family="Trebuchet MS" />
      <style:Fill color="olive"/>
    </style:Style>

    <style:Style applied-type="pdf:H1" >
      <style:Fill color="red"/>
      <style:Stroke color="olive" width="1pt"/>
    </style:Style>

    <<!-- Document content -->

    <pdf:Page id="MyFirstPage" style:margins="10pt" style:font-size="12pt" >
      <Content>
        <pdf:H1 text="This is H1" />
        <pdf:H2 text="This is H2" />
        <pdf:H3 text="This is H3" />
        <pdf:H4 text="This is H4" />
        <pdf:H5 text="This is H5" />
        <pdf:H6 text="This is H6" />
        And this is just some text
        </Content>
    </pdf:Page>
  </Pages>
   PDFDocument doc = new PDFDocument();

            PDFStyleDefn h = new PDFStyleDefn();
            h.Font.FontFamily = "Trebuchet MS";
            h.Fill.Color = PDFColors.Olive;

            PDFStyleDefn h1s = new PDFStyleDefn();
            h1s.Fill.Color = PDFColors.Red;
            h1s.Stroke.Color = PDFColors.Olive;
            doc.Styles.Add(h1s);

            PDFPage page = new PDFPage();
            page.FontFamily = "Times";
            page.FontSize = 12;
            page.HorizontalAlignment = HorizontalAlignment.Right;
            page.VerticalAlignment = VerticalAlignment.Middle;
            doc.Pages.Add(page);

            PDFHead1 h1 = new PDFHead1();
            h1.Text = "This is H1";
            page.Contents.Add(h1);

            PDFHead2 h2 = new PDFHead2();
            h2.Text = "This is H2";
            page.Contents.Add(h2);

            PDFHead3 h3 = new PDFHead3();
            h3.Text = "This is H3";
            page.Contents.Add(h3);

            PDFHead4 h4 = new PDFHead4();
            h4.Text = "This is H4";
            page.Contents.Add(h4);

            PDFHead5 h5 = new PDFHead5();
            h5.Text = "This is H5";
            page.Contents.Add(h5);

            PDFHead6 h6 = new PDFHead6();
            h6.Text = "This is H6";
            page.Contents.Add(h6);

            page.Contents.Add(new PDFTextLiteral("And this is just some text"));

Preview Image

See Also



  Rating
Rate This Page: Poor Great   |  Rate Content |
Average rating:  No Ratings Yet   
Number of Ratings : 0
  Comments
Add Comment
No Comments Yet