-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added support for print type raw-html (#8)
* added support for print type raw-html * Added comments and changed visibility * formatting * Update Version to 6.1.0 Added HTMLRAW --------- Co-authored-by: Benjamin Vertonghen <[email protected]>
- Loading branch information
1 parent
f3018f3
commit f599095
Showing
7 changed files
with
66 additions
and
4 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
samples/Append.Blazor.Printing.Wasm/Examples/RawHtml.razor
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,20 @@ | ||
@inject IPrintingService PrintingService | ||
<Example Name="@this.GetType().Name"> | ||
<Documentation> | ||
<h3>Raw HTML</h3> | ||
<p>Print raw HTML.</p> | ||
</Documentation> | ||
<Code> | ||
@{ | ||
string rawHtml = String.Join( | ||
Environment.NewLine, | ||
"<h1>Print.js Raw HTML Print Test</h1>", | ||
"<p style=\"color: blue;\">Lorem ipsum dolor sit amet, consectetur adipiscing elit,</p>", | ||
"<p>sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>"); | ||
} | ||
|
||
<button @onclick="@(_ => PrintingService.Print(rawHtml, PrintType.RawHtml))"> | ||
Print Raw Html | ||
</button> | ||
</Code> | ||
</Example> |
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
20 changes: 20 additions & 0 deletions
20
samples/Append.Blazor.Printing.Wasm/wwwroot/examples/RawHtml.md
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,20 @@ | ||
@inject IPrintingService PrintingService | ||
<Example Name="@this.GetType().Name"> | ||
<Documentation> | ||
<h3>Raw HTML</h3> | ||
<p>Print raw HTML.</p> | ||
</Documentation> | ||
<Code> | ||
@{ | ||
string rawHtml = String.Join( | ||
Environment.NewLine, | ||
"<h1>Print.js Raw HTML Print Test</h1>", | ||
"<p style=\"color: blue;\">Lorem ipsum dolor sit amet, consectetur adipiscing elit,</p>", | ||
"<p>sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>"); | ||
} | ||
|
||
<button @onclick="@(_ => PrintingService.Print(rawHtml, PrintType.RawHtml))"> | ||
Print Raw Html | ||
</button> | ||
</Code> | ||
</Example> |
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ public enum PrintType | |
Pdf, | ||
Html, | ||
Image, | ||
Json | ||
Json, | ||
RawHtml | ||
} | ||
} |
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,19 @@ | ||
using System; | ||
|
||
namespace Append.Blazor.Printing | ||
{ | ||
internal static class PrintTypeExtensions | ||
{ | ||
/// <summary> | ||
/// Adapts the <see cref="PrintType"/> to the JavaScript version. | ||
/// </summary> | ||
public static string ToPrintJsString(this PrintType printType) | ||
{ | ||
return printType switch | ||
{ | ||
PrintType.RawHtml => "raw-html", | ||
_ => Enum.GetName(typeof(PrintType), printType).ToLower(), | ||
}; | ||
} | ||
} | ||
} |