diff --git a/NFe.Danfe.Fast.Skia/DanfeFastBase.cs b/NFe.Danfe.Fast.Skia/DanfeFastBase.cs index 9c46c64b..f7178101 100644 --- a/NFe.Danfe.Fast.Skia/DanfeFastBase.cs +++ b/NFe.Danfe.Fast.Skia/DanfeFastBase.cs @@ -19,6 +19,7 @@ public void ExportarPdf(string arquivo) Relatorio.Prepare(); Relatorio.Export(new PDFExport(), arquivo); } + /// /// Converte o DANFE para PDF e copia para o stream /// @@ -37,6 +38,27 @@ public void ExportarPdf(Stream outputStream) } } + /// + /// Converte o DANFE para PDF retorna como byte[] + /// + public byte[] ExportarPdf() + { + using (MemoryStream stream = new MemoryStream()) // Create a stream for the report + { + try + { + Relatorio.Prepare(); + Relatorio.Export(new PDFExport(), stream); + return stream.ToArray(); + } + catch (System.Exception ex) + { + throw ex; + } + } + } + + /// /// Converte o DANFE para PDF e salva-o no caminho/arquivo indicado /// @@ -65,7 +87,28 @@ public void ExportarPdf(Stream outputStream, FastReport.Export.ExportBase export Relatorio.Export(exportBase, outputStream); outputStream.Position = 0; } - + + /// + /// Converte o DANFE para PDF retorna como byte[] + /// + /// Instancia do tipo de exportacao do FastReport + public byte[] ExportarPdf(FastReport.Export.ExportBase exportBase) + { + using (MemoryStream stream = new MemoryStream()) // Create a stream for the report + { + try + { + Relatorio.Prepare(); + Relatorio.Export(exportBase, stream); + return stream.ToArray(); + } + catch (System.Exception ex) + { + throw ex; + } + } + } + public byte[] ExportarHtml() { using (MemoryStream stream = new MemoryStream()) // Create a stream for the report diff --git a/NFe.Danfe.OpenFast/DanfeOpenFastBase.cs b/NFe.Danfe.OpenFast/DanfeOpenFastBase.cs index 8d2ce3d0..1eeaf0b2 100644 --- a/NFe.Danfe.OpenFast/DanfeOpenFastBase.cs +++ b/NFe.Danfe.OpenFast/DanfeOpenFastBase.cs @@ -39,6 +39,26 @@ public void ExportarPdf(Stream outputStream) } } + /// + /// Converte o DANFE para PDF retorna como byte[] + /// + public byte[] ExportarPdf() + { + using (MemoryStream stream = new MemoryStream()) // Create a stream for the report + { + try + { + Relatorio.Prepare(); + Relatorio.Export(new PDFSimpleExport(), stream); + return stream.ToArray(); + } + catch (System.Exception ex) + { + throw ex; + } + } + } + /// /// Converte o DANFE para PDF e salva-o no caminho/arquivo indicado /// @@ -68,14 +88,18 @@ public void ExportarPdf(Stream outputStream, FastReport.Export.ExportBase export outputStream.Position = 0; } - public byte[] ExportarPdf() + /// + /// Converte o DANFE para PDF retorna como byte[] + /// + /// Instancia do tipo de exportacao do FastReport + public byte[] ExportarPdf(FastReport.Export.ExportBase exportBase) { using (MemoryStream stream = new MemoryStream()) // Create a stream for the report { try { Relatorio.Prepare(); - Relatorio.Export(new PDFSimpleExport(), stream); + Relatorio.Export(exportBase, stream); return stream.ToArray(); } catch (System.Exception ex)