-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add OutputFormat option to add html output (#96)
This change adds the OutputFormat option to BlazorReports to register a report to output either PDF or HTML format. This helps in debugging reports while building them.
- Loading branch information
1 parent
a6d70da
commit ff9ea24
Showing
11 changed files
with
160 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using BlazorReports.Models; | ||
|
||
namespace BlazorReports.Extensions; | ||
|
||
/// <summary> | ||
/// Extension methods for <see cref="BlazorReport" />. | ||
/// </summary> | ||
public static class BlazorReportExtensions | ||
{ | ||
/// <summary> | ||
/// Gets the content type for the specified <see cref="BlazorReport" />. | ||
/// </summary> | ||
/// <param name="blazorReport"> The <see cref="BlazorReport" /> to get the content type for. </param> | ||
/// <returns> The content type for the specified <see cref="BlazorReport" />. </returns> | ||
public static string GetContentType(this BlazorReport blazorReport) | ||
{ | ||
return blazorReport.OutputFormat switch | ||
{ | ||
ReportOutputFormat.Pdf => "application/pdf", | ||
ReportOutputFormat.Html => "text/html", | ||
_ => "application/pdf" | ||
}; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the file extension for the specified <see cref="BlazorReport" />. | ||
/// </summary> | ||
/// <param name="blazorReport"> The <see cref="BlazorReport" /> to get the file extension for. </param> | ||
/// <returns> The file extension for the specified <see cref="BlazorReport" />. </returns> | ||
public static string GetFileExtension(this BlazorReport blazorReport) | ||
{ | ||
return blazorReport.OutputFormat switch | ||
{ | ||
ReportOutputFormat.Pdf => "pdf", | ||
ReportOutputFormat.Html => "html", | ||
_ => "pdf" | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace BlazorReports.Models; | ||
|
||
/// <summary> | ||
/// Output format for the report. | ||
/// </summary> | ||
public enum ReportOutputFormat | ||
{ | ||
/// <summary> | ||
/// Portable Document Format | ||
/// </summary> | ||
Pdf, | ||
|
||
/// <summary> | ||
/// HyperText Markup Language | ||
/// </summary> | ||
Html | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.