714b4aaf883731d75a80096bf61c5d24b99cd469
API/CodeSamples/CustomPdfExporter.md
| ... | ... | @@ -0,0 +1,58 @@ |
| 1 | +#Code Sample: Custom PDF Exporter |
|
| 2 | + |
|
| 3 | +```csharp |
|
| 4 | +using Izenda.Controls; |
|
| 5 | +using Izenda.AdHoc; |
|
| 6 | +using System; |
|
| 7 | + |
|
| 8 | +public class CustomPdfGenerator : PdfGeneratorBase |
|
| 9 | +{ |
|
| 10 | + public override IContentGenerator GenerateOutput(ReportSet reportSet) |
|
| 11 | + { |
|
| 12 | + string html = PrepareReportSetHtml(reportSet, true, true); |
|
| 13 | + byte[] fileContents = null; |
|
| 14 | + try |
|
| 15 | + { |
|
| 16 | + fileContents = CustomExport(html, reportSet); |
|
| 17 | + } |
|
| 18 | + catch (Exception ex) |
|
| 19 | + { |
|
| 20 | + Debug.Write(string.Format("CustomPdfGenerator::GenerateOutput {0}", ex.Message)); |
|
| 21 | + } |
|
| 22 | + return new FileContentGenerator(Guid.NewGuid().ToString(), fileContents, GetOutputFileName(reportSet.ReportNameSafe), |
|
| 23 | + Utility.GetMIMEType(FileExtension.ToUpper())); |
|
| 24 | + } |
|
| 25 | + |
|
| 26 | + private byte[] CustomExport(string html, ReportSet reportSet) |
|
| 27 | + { |
|
| 28 | + //perform custom logic here |
|
| 29 | + return new byte[0]; |
|
| 30 | + } |
|
| 31 | +} |
|
| 32 | +``` |
|
| 33 | + |
|
| 34 | +```visualbasic |
|
| 35 | +Imports Izenda.Controls |
|
| 36 | +Imports Izenda.AdHoc |
|
| 37 | +Imports System |
|
| 38 | + |
|
| 39 | +Public Class CustomPdfGenerator |
|
| 40 | + Inherits PdfGeneratorBase |
|
| 41 | + Public Overrides Function GenerateOutput(ByVal reportSet As ReportSet) As IContentGenerator |
|
| 42 | + Dim html As String = PrepareReportSetHtml(reportSet, True, True) |
|
| 43 | + Dim fileContents As Byte() = Nothing |
|
| 44 | + Try |
|
| 45 | + fileContents = CustomExport(html, reportSet) |
|
| 46 | + Catch ex As Exception |
|
| 47 | + Debug.Write(String.Format("CustomPdfGenerator::GenerateOutput {0}", ex.Message)) |
|
| 48 | + End Try |
|
| 49 | + Return New FileContentGenerator(Guid.NewGuid().ToString(), fileContents, GetOutputFileName(reportSet.ReportNameSafe), |
|
| 50 | + Utility.GetMIMEType(FileExtension.ToUpper())) |
|
| 51 | + End Function |
|
| 52 | + |
|
| 53 | + Private Function CustomExport(ByVal html As String, ByVal reportSet As ReportSet) As Byte() |
|
| 54 | + 'perform custom logic here |
|
| 55 | + Return New Byte() {} |
|
| 56 | + End Function |
|
| 57 | +End Class |
|
| 58 | +``` |
|
| ... | ... | \ No newline at end of file |