private static bool GeneraPDF(string readContents, string _file_pdf_destino) { Boolean _valida = false; try { var htmlToPdf = new NReco.PdfGenerator.HtmlToPdfConverter(); htmlToPdf.PageHeight = 242; htmlToPdf.PageWidth = 170; var margins = new NReco.PdfGenerator.PageMargins(); margins.Bottom = 2; margins.Top = 1; margins.Left = 2; margins.Right = 5; htmlToPdf.Margins = margins; htmlToPdf.Orientation = NReco.PdfGenerator.PageOrientation.Portrait; htmlToPdf.Zoom = 1F; htmlToPdf.Size = NReco.PdfGenerator.PageSize.A4; var pdfBytes = htmlToPdf.GeneratePdf(readContents); //File.WriteAllBytes(@_file_pdf_destino, pdfBytes); _valida = true; } catch { _valida = false; } return(_valida); }
private static bool GeneraPDF(string readContents, string _file_pdf_destino) { Boolean _valida = false; try { //string readContents; //using (StreamReader streamReader = new StreamReader(@_file_html, Encoding.UTF8)) //{ // readContents = streamReader.ReadToEnd(); //} //readContents = readContents.Replace("XXXXXXXX", "AAAAAAA"); var htmlToPdf = new NReco.PdfGenerator.HtmlToPdfConverter(); htmlToPdf.PageHeight = 180; htmlToPdf.PageWidth = 140; var margins = new NReco.PdfGenerator.PageMargins(); margins.Bottom = 2; margins.Top = 1; margins.Left = 3; margins.Right = 5; htmlToPdf.Margins = margins; htmlToPdf.Orientation = NReco.PdfGenerator.PageOrientation.Portrait; htmlToPdf.Zoom = 1F; htmlToPdf.Size = NReco.PdfGenerator.PageSize.A4; var pdfBytes = htmlToPdf.GeneratePdf(readContents); File.WriteAllBytes(@_file_pdf_destino, pdfBytes); _valida = true; } catch { _valida = false; } return(_valida); }