Hey guys,
I have an HTML page being incremented in an aspx page. The issue is that the HTML should only return two pages but it is returning 3 with the first one being completely blank. How can I fix this? Here are the codes:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="certificadoAluno.aspx.vb" Inherits="testeCertificado" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
@page {
size: A4 landscape;
margin: 0;
padding: 0;
}
@media print {
.print {
display: block;
}
.no-print {
display: none;
}
}
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
font-size: 12pt;
}
.page {
display: block;
page-break-before: always;
}
.content1 {
width: 100%;
height: 100%;
padding: 1cm;
box-sizing: border-box;
background-image:url(../imagens/Cedula_Certificado_01.jpg);
background-position:top left;
background-repeat:no-repeat;
background-size:100%;
}
.content2 {
width: 100%;
height: 100%;
padding: 1cm;
box-sizing: border-box;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="LbHtml" runat="server" ></asp:Label>
</div>
</form>
</body>
</html>
Partial Class testeCertificado
Inherits System.Web.UI.Page
Private Filial As New DETI.objFiliais
Private Certificado As New DETI.objMatriculaCertificado
Private Secreto As New Criptografia.ClassEncriptaDecripta
Private Sub RecebeParametros()
If Not Secreto.Decriptografa(Request("p1")) Is Nothing Then ViewState("vl1") = Secreto.Decriptografa(Request("p1")) Else ViewState("vl1") = 0
If Not Secreto.Decriptografa(Request("p2")) Is Nothing Then ViewState("vl2") = Secreto.Decriptografa(Request("p2")) Else ViewState("vl2") = 0
ConsultaCertificado(ViewState("vl1"), ViewState("vl2"))
End Sub
Function PegarDominio() As String
Dim Ds As Data.DataSet
Dim pRetorno As String = "https://web.centec.org.br/sisgeti"
Ds = Filial.ConsultaGenerica(" SELECT CAMINHOPRINCIPAL " &
" FROM FILIAL " &
" WHERE ID = " & Session("sFilial"))
If Not Ds Is Nothing Then
If Ds.Tables(0).Rows.Count > 0 Then
pRetorno = Ds.Tables(0).Rows(0)("CAMINHOPRINCIPAL")
If Right(pRetorno, 1) = "/" Then pRetorno = Left(pRetorno, Len(Ds.Tables(0).Rows(0)("CAMINHOPRINCIPAL")) - 1)
End If
End If
Return pRetorno
End Function
Private Sub ConsultaCertificado(ByVal pEditalItem As Integer, ByVal pPessoa As Integer)
Dim Ds As Data.DataSet
'Dim pParametro As String = Secreto.Criptografa(pEditalItem & "," & pPessoa & ",1")
Dim pDominio = PegarDominio()
Dim pLink As String = pDominio & "/pesquisa/validaAluno.aspx?p1=" '& pParametro
Dim pSQL As String = " SELECT ID, EDITALITEMID, MATRICULAID, INSCRICAOID, PESSOAID, VIA, " &
" CEDULA = REPLICATE ('0', 3 - LEN(CAST(CEDULA AS VARCHAR))) + CAST(CEDULA AS VARCHAR), " &
" LIVRO = ISNULL(LIVRO, ''), FOLHA = ISNULL(FOLHA, ''), " &
" DATACERTIFICACAO, DATA_CERTIFICACAO, CODIGOCERTIFICADO, USUARIOCRIA, ATIVO, MOTIVOID, " &
" DTCRIACAO, USUARIOALTERA, DTALTERACAO, CPF_ALUNO, ALUNO, " &
" CURSO, PROFESSOR, CARGAHORARIA, EMENTA, CONTEUDO_PROGRAMATICO, SENHA = '010203040506', " &
" FILIAL, CIDADE, ESTADO, PERIODO, PRESIDENTE = 'Nome do Presidente', LINKASSINATURA = ISNULL(LINKASSINATURA, ''), " &
" COORDENADOR = 'Mome do Coordenador', LINKASSCOORDENADOR = ISNULL(LINKASSCOORDENADOR, ''), SECRETARIO, " &
" EMISSAO_CERTIFICADO = 'Fortaleza (CE), ' + LOWER(dbo.fnDataExtenso(GETDATE())) " &
" FROM V_CERTIFICADO " &
" WHERE EDITALITEMID = " & pEditalItem & " AND PESSOAID = " & pPessoa
Ds = Certificado.ConsultaGenerica(pSQL)
If Not Ds Is Nothing Then
If Ds.Tables(0).Rows.Count > 0 Then
GeraHtml(Ds.Tables(0).Rows(0)("ALUNO"),
Ds.Tables(0).Rows(0)("CURSO"),
Ds.Tables(0).Rows(0)("PROFESSOR"),
Ds.Tables(0).Rows(0)("FILIAL"),
Ds.Tables(0).Rows(0)("PERIODO"),
Ds.Tables(0).Rows(0)("CARGAHORARIA"),
Ds.Tables(0).Rows(0)("EMISSAO_CERTIFICADO"),
Ds.Tables(0).Rows(0)("LINKASSINATURA"),
Ds.Tables(0).Rows(0)("LINKASSCOORDENADOR"),
Ds.Tables(0).Rows(0)("CONTEUDO_PROGRAMATICO"),
pLink & Ds.Tables(0).Rows(0)("CODIGOCERTIFICADO"),
Ds.Tables(0).Rows(0)("CEDULA"),
Ds.Tables(0).Rows(0)("LIVRO"),
Ds.Tables(0).Rows(0)("FOLHA"))
Else
If Ds.Tables(0).Rows.Count = 0 Then
LbHtml.Text = "<div style='font-size:20px; text-align:center;'>Não foi possível acessar seus dados.</div>"
End If
End If
Else
If Ds Is Nothing Then
LbHtml.Text = "<div style='font-size:20px; text-align:center;'>Não foi possível acessar seus dados.</div>"
End If
End If
End Sub
Private Sub GeraHtml(ByVal pAluno As String, ByVal pCurso As String, ByVal pProfessor As String, ByVal pFilial As String,
ByVal pPeriodo As String, ByVal pCH As Integer, ByVal pDataEmissao As String, ByVal pImgDiretor As String,
ByVal pImgCoordenador As String, ByVal pConteudoProgramatico As String, ByVal pLinkQrCode As String,
ByVal pCedula As String, ByVal pLivro As String, ByVal pFolha As String)
Dim pHtml As String
Dim pSrc As String = "https://chart.googleapis.com/chart?chs=130x130&cht=qr&chl=" & Server.UrlEncode(pLinkQrCode)
'<!-- Content of page 1 goes here -->
pHtml = " <div class='page print'> " &
" <div class='content1'> " &
" " &
" <div style='height:400px; padding:300px 130px 10px 130px;'> " &
" <div style='height:200px;'> " &
" <div style='line-height:20px;'>Certificamos que <b>" & pAluno & "</b>, concluiu o curso de " & pCurso & " realizado pelo " & pFilial & ", no período de " & pPeriodo & ", com carga horária de " & pCH & " horas.</div> " &
" <div style='line-height:20px; text-align:center; margin-top:30px;'>" & pDataEmissao & "</div> " &
" </div> " &
" <div> " &
" <table style='width:100%; border:0px none; color:#000; font-size:14px;'> " &
" <tr> " &
" <td style='width:40%; height:50px; background-position:top center; background-size:100%;'> </td> " &
" <td style='width:20%; height:50px; background-position:top center; background-size:100%;'> </td> " &
" <td style='width:40%; height:50px; background-position:top center; background-size:100%;'> </td> " &
" </tr> " &
" <tr> " &
" <td style='width:40%; text-align:center; border-top:1px solid #000;'>Nome do Presidente<br />Diretor Presidente</td> " &
" <td style='width:20%; text-align:center;'> </td> " &
" <td style='width:40%; text-align:center; border-top:1px solid #000;'>Nome do Coordenador<br />Coordenador(a)</td> " &
" </tr> " &
" </table> " &
" </div> " &
" </div> " &
" </div> " &
" </div> " &
" " &
" <div class='page'> " &
" <div class='content2'> " &
" <!-- Content of page 2 goes here --> " &
" <div style='height:570px; padding:30px 130px 60px 130px; background-image:url(" & pSrc & "); background-position:bottom right; background-repeat:no-repeat;'> " &
" <h3>" & pCurso & "</h3>" &
" <hr />" &
" <p><b>Conteúdo Programático:</b></p>" &
" <p>" & Server.HtmlDecode(pConteudoProgramatico) & "</p>" &
" <hr />" &
" <p><b>Professor(a):</b> " & pProfessor & " | <b>Certificado Nº:</b> " & pCedula & " | <b>Livro:</b> " & pLivro & " | <b>Folha:</b> " & pFolha & "</p>" &
" </div> " &
" " &
" <!-- <div style='text-align:right;'> " &
" <img src='" & pSrc & "'> " &
" </div> --> " &
" </div> " &
" </div>"
LbHtml.Text = pHtml
End Sub
Private Sub testeCertificado_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not IsPostBack Then
RecebeParametros()
End If
End Sub
End Class
The problem happens when printing. If you ask to see the printout of this document, the three pages appear with the first one blank.
Grateful,
Ilano.