Marianna Gonçalves Posted April 24, 2015 at 01:50 PM Report Share #581791 Posted April 24, 2015 at 01:50 PM Bom dia pessoal, Estou gerando um relatório .pdf a partir do visual studio ultimate 2013, mas quando ele gera o pdf cria um página em branco, com cabeçalho e rodapé, já tentei alterar as configurações, até consegui gerar mais páginas em branco, mas não consigo resolver esse bug que gera a segunda página. Grata, Marianna. Link to comment Share on other sites More sharing options...
apocsantos Posted April 24, 2015 at 04:16 PM Report Share #581804 Posted April 24, 2015 at 04:16 PM Boa tarde, Coloca cá o código que gera o relatório. Cordiais cumprimentos, Apcosantos "A paciência é uma das coisas que se aprendeu na era do 48k" O respeito é como a escrita de código, uma vez perdido, dificilmente se retoma o habito" Link to comment Share on other sites More sharing options...
Marianna Gonçalves Posted April 24, 2015 at 05:59 PM Author Report Share #581810 Posted April 24, 2015 at 05:59 PM (edited) using Microsoft.Reporting.WebForms; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Projeto___SIMP { public partial class frmHistoriaClinica : Form { public frmHistoriaClinica() { InitializeComponent(); } private void button7_Click(object sender, EventArgs e) { //adicionar uma nova linha entre "___" richHistoriaClinica.AppendText(System.Environment.NewLine + "_____" + //pegar data e hora atual + adicionar nova linha DateTime.Now.ToString() + "_____" + System.Environment.NewLine); //pular cursor para linha debaixo richHistoriaClinica.Focus(); richHistoriaClinica.SelectionLength = 0; } private void button3_Click(object sender, EventArgs e) { frmSolicitarExame novofrm = new frmSolicitarExame(); novofrm.ShowDialog(); } private void richHistoriaClinica_TextChanged(object sender, EventArgs e) { } private void btnSolicitarExame_Click(object sender, EventArgs e) { frmSolicitarExame novofrm = new frmSolicitarExame(); novofrm.ShowDialog(); } private void btnAtestadoMedico_Click(object sender, EventArgs e) { var frmQD = new frmQuantidadeDias(); DialogResult dr = frmQD.ShowDialog(); if (dr == DialogResult.OK) { ReportViewer reportViewer = new ReportViewer(); reportViewer.ProcessingMode = ProcessingMode.Local; //caminho para encontrar o relatório reportViewer.LocalReport.ReportEmbeddedResource = "Projeto___SIMP.MeuRelatorio.rdlc"; //parametros do relatório List<ReportParameter> listReportParameter = new List<ReportParameter>(); listReportParameter.Add(new ReportParameter("Nome", txtNome.Text)); listReportParameter.Add(new ReportParameter("Dias", frmQD.Dias.ToString())); reportViewer.LocalReport.SetParameters(listReportParameter); //renderizar para PDF Warning[] warnings; string[] streamids; string mimeType; string encoding; string extension; byte[] bytePDF = reportViewer.LocalReport.Render( "Pdf", null, out mimeType, out encoding, out extension, out streamids, out warnings ); FileStream fileStreamPDF = null; string nomeArquivoPDF = Path.GetTempPath() + "RelatorioAtestado" + DateTime.Now.ToString("dd_MM_yyyy - HH_mm_ss") + ".pdf"; fileStreamPDF = new FileStream(nomeArquivoPDF, FileMode.Create); fileStreamPDF.Write(bytePDF, 0, bytePDF.Length); fileStreamPDF.Close(); Process.Start(nomeArquivoPDF); } } private void frmHistoriaClinica_Load(object sender, EventArgs e) { } } } Edited April 24, 2015 at 06:16 PM by apocsantos geshi Link to comment Share on other sites More sharing options...
Solution apocsantos Posted April 24, 2015 at 08:35 PM Solution Report Share #581816 Posted April 24, 2015 at 08:35 PM Boa noite, private void btnAtestadoMedico_Click(object sender, EventArgs e) { var frmQD = new frmQuantidadeDias(); DialogResult dr = frmQD.ShowDialog(); if (dr == DialogResult.OK) { ReportViewer reportViewer = new ReportViewer(); reportViewer.ProcessingMode = ProcessingMode.Local; //caminho para encontrar o relatório reportViewer.LocalReport.ReportEmbeddedResource = "Projeto___SIMP.MeuRelatorio.rdlc"; //parametros do relatório List<ReportParameter> listReportParameter = new List<ReportParameter>(); listReportParameter.Add(new ReportParameter("Nome", txtNome.Text)); listReportParameter.Add(new ReportParameter("Dias", frmQD.Dias.ToString())); reportViewer.LocalReport.SetParameters(listReportParameter); //Altera a proriedade ConsumeContainerWhiteSpace, para true. reportViewer.ConsumeContainerWhiteSpace = true; //renderizar o pdf } } Não tenho a certeza se irá produzir o efeito desejado, pois não consegui replicar a situação. Cordiais cumprimentos, Apocsantos "A paciência é uma das coisas que se aprendeu na era do 48k" O respeito é como a escrita de código, uma vez perdido, dificilmente se retoma o habito" Link to comment Share on other sites More sharing options...
Marianna Gonçalves Posted April 28, 2015 at 02:10 PM Author Report Share #582051 Posted April 28, 2015 at 02:10 PM Obrigada Apocsantos Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now