Skip to content

Commit 9c918ee

Browse files
committed
README file changes
1 parent 268ec00 commit 9c918ee

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

Blazor/README.md

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,12 @@ The Syncfusion HTML to PDF converter is a .NET library used to convert HTML or w
2727
4. Add the following code to convert HTML to PDF document in [ExportService](HTML_to_PDF_Blazor/Data/ExportService.cs) class.
2828

2929
```csharp
30-
public MemoryStream CreatePdf()
30+
public MemoryStream CreatePdf(string url)
3131
{
3232
//Initialize HTML to PDF converter.
33-
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();
34-
BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings();
35-
//Set Blink viewport size.
36-
blinkConverterSettings.ViewPortSize = new Syncfusion.Drawing.Size(1280, 0);
37-
//Assign Blink converter settings to HTML converter.
38-
htmlConverter.ConverterSettings = blinkConverterSettings;
33+
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();
3934
//Convert URL to PDF document.
40-
PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com");
35+
PdfDocument document = htmlConverter.Convert(url);
4136
//Create memory stream.
4237
MemoryStream stream = new MemoryStream();
4338
//Save the document to memory stream.
@@ -49,6 +44,9 @@ The Syncfusion HTML to PDF converter is a .NET library used to convert HTML or w
4944
5. Register your service in the ConfigureServices method available in the Startup.cs class as follows.
5045

5146
```csharp
47+
/// <summary>
48+
/// Register your ExportService
49+
/// </summary>
5250
public void ConfigureServices(IServiceCollection services)
5351
{
5452
services.AddRazorPages();
@@ -63,6 +61,7 @@ The Syncfusion HTML to PDF converter is a .NET library used to convert HTML or w
6361
```csharp
6462
@inject ExportService exportService
6563
@inject Microsoft.JSInterop.IJSRuntime JS
64+
@inject NavigationManager NavigationManager
6665
@using System.IO;
6766
```
6867

@@ -75,13 +74,25 @@ The Syncfusion HTML to PDF converter is a .NET library used to convert HTML or w
7574
8. Add the ExportToPdf method in FetchData.razor page to call the export service.
7675

7776
```csharp
77+
@code {
78+
private string currentUrl;
79+
/// <summary>
80+
/// Get the current URL
81+
/// </summary>
82+
protected override void OnInitialized()
83+
{
84+
currentUrl = NavigationManager.Uri;
85+
}
86+
}
7887
@functions
7988
{
80-
89+
/// <summary>
90+
/// Create and download the PDF document
91+
/// </summary>
8192
protected async Task ExportToPdf()
8293
{
8394
ExportService exportService = new ExportService();
84-
using (MemoryStream excelStream = exportService.CreatePdf())
95+
using (MemoryStream excelStream = exportService.CreatePdf(currentUrl))
8596
{
8697
await JS.SaveAs("HTML-to-PDF.pdf", excelStream.ToArray());
8798
}

0 commit comments

Comments
 (0)