ilanocf says:
"header { height: auto; position: fixed; top: 0; left: 0; width: 100%; }"
& vbCrLf &
Remove position: fixed and place content inside section tag.
Refer below example.
HTML
<asp:Label ID="LbConteudo" runat="server"></asp:Label>
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
PovoaDocumentos();
}
private void PovoaDocumentos()
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[] {
new DataColumn("TIPO_DOCUMENTO"),
new DataColumn("USUORIGEM"),
new DataColumn("SETOR_ORIGEM"),
new DataColumn("USUDESTINO"),
new DataColumn("SETOR_DESTINO"),
new DataColumn("ASSUNTO"),
new DataColumn("TEXTO")
});
dt.Rows.Add("COMUNICACAO INTERNA", "Fulano de Tal", "ASTIC - Assesoria em Technologia da Informacao e comunicacao", "Beltrano de Tal", "PR - Presidencia", "Teste", "Redigir textos longos");
DataSet Ds = new DataSet();
Ds.Tables.Add(dt);
string pHeader = "";
string pConteudo = "";
if (Ds.Tables[0].Rows.Count > 0)
{
pHeader = "<table width='100%' border='1' cellpadding='0' cellspacing='0'>"
+ " <tr>"
+ " <td colspan = '2' style='font-size:14pt; text-align:center; font-weight:bold; padding:10px; font-family: Roboto, -apple-system, BlinkMacSystemFont, Arial, sans-serif;' >" + Ds.Tables[0].Rows[0]["TIPO_DOCUMENTO"].ToString().ToUpper() + "</td>"
+ " </tr>"
+ " <tr>"
+ " <td valign='top' width='50%' style='font-size:11pt; text-align:left; padding:0px 5px 0px 5px; border:1px solid #000; font-family: Roboto, -apple-system, BlinkMacSystemFont, Arial, sans-serif;' ><b>De:</b> " + Ds.Tables[0].Rows[0]["USUORIGEM"] + "<br />" + Ds.Tables[0].Rows[0]["SETOR_ORIGEM"] + "</td>"
+ " <td valign='top' width='50%' style='font-size:11pt; text-align:left; padding:0px 5px 0px 5px; border:1px solid #000; font-family: Roboto, -apple-system, BlinkMacSystemFont, Arial, sans-serif;' ><b>Para:</b> " + Ds.Tables[0].Rows[0]["USUDESTINO"] + "<br />" + Ds.Tables[0].Rows[0]["SETOR_DESTINO"] + "</td>"
+ " </tr>"
+ " <tr>"
+ " <td valign='top' colspan='2' style='font-size:11pt; text-align:left; border:1px solid #000; font-family: Roboto, -apple-system, BlinkMacSystemFont, Arial, sans-serif;' ><b>Assunto:</b> " + Ds.Tables[0].Rows[0]["ASSUNTO"] + "</td>"
+ " </tr>"
+ "</table>";
pConteudo = "<br /><br />" + Server.HtmlDecode(Ds.Tables[0].Rows[0]["TEXTO"].ToString());
string htmlContent = "<html>"
+ "<head>"
+ " <style>"
+ " header { height: auto; top: 0; left: 0; width: 100%; }"
+ " footer { height: 50px; position: fixed; bottom: 0; left: 0; width: 100%; }"
+ " footer .page:after { content: counter(page); }"
+ " </style>"
+ "</head>"
+ "<body>"
+ " <header>" + pHeader + "</header>"
+ " <section>"
+ " <div>" + pConteudo + "</div>"
+ " </section>"
+ " <footer><div class='page'>Page</div></footer>"
+ "</body>"
+ "</html>";
LbConteudo.Text += htmlContent;
}
}
VB.Net
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
PovoaDocumentos()
End Sub
Private Sub PovoaDocumentos()
Dim dt As DataTable = New DataTable()
dt.Columns.AddRange(New DataColumn() {
New DataColumn("TIPO_DOCUMENTO"),
New DataColumn("USUORIGEM"),
New DataColumn("SETOR_ORIGEM"),
New DataColumn("USUDESTINO"),
New DataColumn("SETOR_DESTINO"),
New DataColumn("ASSUNTO"),
New DataColumn("TEXTO")})
dt.Rows.Add("COMUNICACAO INTERNA", "Fulano de Tal", "ASTIC - Assesoria em Technologia da Informacao e comunicacao", "Beltrano de Tal", "PR - Presidencia", "Teste", "Redigir textos longos")
Dim Ds As DataSet = New DataSet()
Ds.Tables.Add(dt)
Dim pHeader As String = ""
Dim pConteudo As String = ""
If Ds.Tables(0).Rows.Count > 0 Then
pHeader = "<table width='100%' border='1' cellpadding='0' cellspacing='0'>" & " <tr>" & " <td colspan = '2' style='font-size:14pt; text-align:center; font-weight:bold; padding:10px; font-family: Roboto, -apple-system, BlinkMacSystemFont, Arial, sans-serif;' >" & Ds.Tables(0).Rows(0)("TIPO_DOCUMENTO").ToString().ToUpper() & "</td>" & " </tr>" & " <tr>" & " <td valign='top' width='50%' style='font-size:11pt; text-align:left; padding:0px 5px 0px 5px; border:1px solid #000; font-family: Roboto, -apple-system, BlinkMacSystemFont, Arial, sans-serif;' ><b>De:</b> " + Ds.Tables(0).Rows(0)("USUORIGEM") & "<br />" + Ds.Tables(0).Rows(0)("SETOR_ORIGEM") & "</td>" & " <td valign='top' width='50%' style='font-size:11pt; text-align:left; padding:0px 5px 0px 5px; border:1px solid #000; font-family: Roboto, -apple-system, BlinkMacSystemFont, Arial, sans-serif;' ><b>Para:</b> " + Ds.Tables(0).Rows(0)("USUDESTINO") & "<br />" + Ds.Tables(0).Rows(0)("SETOR_DESTINO") & "</td>" & " </tr>" & " <tr>" & " <td valign='top' colspan='2' style='font-size:11pt; text-align:left; border:1px solid #000; font-family: Roboto, -apple-system, BlinkMacSystemFont, Arial, sans-serif;' ><b>Assunto:</b> " + Ds.Tables(0).Rows(0)("ASSUNTO") & "</td>" & " </tr>" & "</table>"
pConteudo = "<br /><br />" & Server.HtmlDecode(Ds.Tables(0).Rows(0)("TEXTO").ToString())
Dim htmlContent As String = "<html>" & "<head>" & " <style>" & " header { height: auto; top: 0; left: 0; width: 100%; }" & " footer { height: 50px; position: fixed; bottom: 0; left: 0; width: 100%; }" & " footer .page:after { content: counter(page); }" & " </style>" & "</head>" & "<body>" & " <header>" & pHeader & "</header>" & " <section>" & " <div>" & pConteudo & "</div>" & " </section>" & " <footer><div class='page'>Page</div></footer>" & "</body>" & "</html>"
LbConteudo.Text += htmlContent
End If
End Sub
Screenshot