title: how to generate pdf with header and footer from html
body: <p>Tried to generate pdf along with header and footer for every page from HTML, but finally got header at starting first page and footer at the last page.</p>
  
  <p>How to add for all pages,
  find the following c# code which i used,</p>
  
  <pre><code>string outputHTML;// here it contains HTML as string and im passing this
  IPechkin sc = Factory.Create(new GlobalConfig());
  byte[] buf = sc.Convert(new ObjectConfig(), outputHTML);
  try
  {
    string fn;
    fn = @"D:\NewFolder\Test.pdf";
    FileStream fs = new FileStream(fn, FileMode.Create);
    fs.Write(buf, 0, buf.Length);
    fs.Close();
  }
  catch
  {
    //
  }
  MessageBox.Show("PDF Generated.");
  </code></pre>
  
  <p>Here i am using "IPechkin " DLL for creating pdf.</p>
  
  <p>please find the XSL-FO file, this file working fine and getting header and footer for all pages in Online pdf generation, but cant get for every pages while performing in C# application.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"&gt;
      &lt;xsl:template match='/'&gt;
          &lt;fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"&gt;
              &lt;fo:layout-master-set&gt;
                  &lt;fo:simple-page-master master-name="my-page"
                                     page-height="29.7cm"
                        page-width="21cm"
                        margin-top="1cm"
                        margin-bottom="0.1cm"
                        margin-left="0.8cm"
                        margin-right="1.0cm" &gt;
                      &lt;fo:region-body region-name="xsl-region-body" margin-top="2.5cm" margin-bottom="2.5cm"/&gt;
                      &lt;fo:region-before region-name="xsl-region-before" extent="2.0cm"/&gt;
                      &lt;fo:region-after region-name="xsl-region-after" extent="2.0cm"/&gt;
                  &lt;/fo:simple-page-master&gt;
              &lt;/fo:layout-master-set&gt;
              &lt;fo:page-sequence master-reference="my-page"&gt;
                  &lt;fo:static-content flow-name="xsl-region-before"&gt;
                      &lt;fo:block&gt;
                          Page header
                      &lt;/fo:block&gt;
                  &lt;/fo:static-content&gt;
                  &lt;fo:static-content flow-name="xsl-region-after"&gt;
                      &lt;fo:block&gt;footer&lt;/fo:block&gt;
                  &lt;/fo:static-content&gt;
                  &lt;fo:flow flow-name="xsl-region-body"&gt;
                      &lt;fo:block break-after="xsl-region-before"&gt;
                          Body
                      &lt;/fo:block&gt;
                      &lt;table align="right" border="1" bordercolor="#ccc" cellpadding="5" cellspacing="0" style="border-collapse:collapse"&gt;
                          &lt;caption&gt;
                              &lt;strong&gt;Mission crew&lt;/strong&gt;
                          &lt;/caption&gt;
                          &lt;thead&gt;
                              &lt;tr&gt;
                                  &lt;th scope="col"&gt;Position&lt;/th&gt;
                                  &lt;th scope="col"&gt;Astronaut&lt;/th&gt;
                              &lt;/tr&gt;
                          &lt;/thead&gt;
                          &lt;tbody&gt;
                              &lt;tr&gt;
                                  &lt;td&gt;First Name&lt;/td&gt;
                                  &lt;td&gt;
                                      &lt;xsl:value-of disable-output-escaping="yes" select="string(firstName)" /&gt;
                                  &lt;/td&gt;
                              &lt;/tr&gt;
                              &lt;tr&gt;
                                  &lt;td&gt;Treatment ID&lt;/td&gt;
                                  &lt;td&gt;
                                      &lt;xsl:value-of disable-output-escaping="yes" select="string(treatmentID)" /&gt;
                                  &lt;/td&gt;
                              &lt;/tr&gt;
                              &lt;tr&gt;
                                  &lt;td&gt;Key Name&lt;/td&gt;
                                  &lt;td&gt;
                                      &lt;xsl:value-of disable-output-escaping="yes" select="string(keyName)" /&gt;
                                  &lt;/td&gt;
                              &lt;/tr&gt;
                          &lt;/tbody&gt;
                      &lt;/table&gt;
  
                      &lt;p&gt;
                          Launched by a &lt;strong&gt;Saturn V&lt;/strong&gt; rocket from &lt;a href="http://en.wikipedia.org/wiki/Kennedy_Space_Center"&gt;Kennedy Space Center&lt;/a&gt; in Merritt Island, Florida on July 16, Apollo 11 was the fifth manned mission of &lt;a href="http://en.wikipedia.org/wiki/NASA"&gt;NASA&lt;/a&gt;&amp;#39;s Apollo program. The Apollo spacecraft had three parts:
                      &lt;/p&gt;
  
                      &lt;ol&gt;
                          &lt;li&gt;
                              &lt;strong&gt;Command Module&lt;/strong&gt; with a cabin for the three astronauts which was the only part which landed back on Earth
                          &lt;/li&gt;
                          &lt;li&gt;
                              &lt;strong&gt;Service Module&lt;/strong&gt; which supported the Command Module with propulsion, electrical power, oxygen and water
                          &lt;/li&gt;
                          &lt;li&gt;
                              &lt;strong&gt;Lunar Module&lt;/strong&gt; for landing on the Moon.
                          &lt;/li&gt;
                      &lt;/ol&gt;
  
                      &lt;p&gt;
                          After being sent to the Moon by the Saturn V&amp;#39;s upper stage, the astronauts separated the spacecraft from it and travelled for three days until they entered into lunar orbit. Armstrong and Aldrin then moved into the Lunar Module and landed in the &lt;a href="http://en.wikipedia.org/wiki/Mare_Tranquillitatis"&gt;Sea of Tranquility&lt;/a&gt;. They stayed a total of about 21 and a half hours on the lunar surface. After lifting off in the upper part of the Lunar Module and rejoining Collins in the Command Module, they returned to Earth and landed in the &lt;a href="http://en.wikipedia.org/wiki/Pacific_Ocean"&gt;Pacific Ocean&lt;/a&gt; on July 24.
                      &lt;/p&gt;
  
                      &lt;hr /&gt;
                      &lt;p&gt;
                          &lt;small&gt;
                              Source: &lt;a href="http://en.wikipedia.org/wiki/Apollo_11"&gt;Wikipedia.org&lt;/a&gt;
                          &lt;/small&gt;
                      &lt;/p&gt;
                  &lt;/fo:flow&gt;
              &lt;/fo:page-sequence&gt;
          &lt;/fo:root&gt;
      &lt;/xsl:template&gt;
      &lt;xsl:template name="replace-returns"&gt;
          &lt;xsl:param name="text"/&gt;
          &lt;xsl:choose&gt;
              &lt;xsl:when test="contains($text, '&amp;#xa;')"&gt;
                  &lt;xsl:value-of select="substring-before($text, '&amp;#xa;')"/&gt;
                  &lt;xsl:value-of select="'&amp;lt;br /&amp;gt;'" disable-output-escaping="yes"/&gt;
                  &lt;xsl:call-template name="replace-returns"&gt;
                      &lt;xsl:with-param name="text" select="substring-after($text, '&amp;#xa;')"/&gt;
                  &lt;/xsl:call-template&gt;
              &lt;/xsl:when&gt;
              &lt;xsl:otherwise&gt;
                  &lt;xsl:value-of select="$text"/&gt;
              &lt;/xsl:otherwise&gt;
          &lt;/xsl:choose&gt;
      &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>but unable to get header and footer for every page. </p>