Skip to content

Commit

Permalink
921494_ft1 Resolved the given feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
sameerkhan001 committed Dec 13, 2024
1 parent db8aecf commit a70ac7e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,6 @@

//Close the document.
loadedDocument.Close(true);
certificateStream.Dispose();
imageStream.Dispose();
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ Step 4: **Add digital signature code**: Use the following code snippet in `Progr

// Close the document
loadedDocument.Close(true);
certificateStream.Dispose();
imageStream.Dispose();
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,28 @@ Step 3: **Include necessary namespaces**: Add the following namespaces in your `
Step 4: **Convert HTML to PDF**: Implement the following code in `Program.cs` to convert a website URL to a PDF file:

```csharp
// Initialize the HTML to PDF converter
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();

// Convert a URL to a PDF document
PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com");

// Create the FileStream to save the PDF document
FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite);

// Save and close the PDF document
document.Save(fileStream);
document.Close(true);
//Initialize HTML to PDF converter.
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();
//Create blink converter settings
BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings();
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
//Set command line arguments to run without the sandbox.
blinkConverterSettings.CommandLineArguments.Add("--no-sandbox");
blinkConverterSettings.CommandLineArguments.Add("--disable-setuid-sandbox");
}
//Assign Blink converter settings to HTML converter.
htmlConverter.ConverterSettings = blinkConverterSettings;
//Convert URL to PDF document.
PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com");
//Create file stream.
using (FileStream fileStream = new FileStream(Path.GetFullPath(@"Output/Output.pdf"), FileMode.Create, FileAccess.ReadWrite))
{
//Save the PDF document
document.Save(fileStream);
}
//Close the document.
document.Close(true);
```

You can download a complete working sample from the [GitHub repository](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/Blink/Convert-website-URL-to-PDF-document).
Expand Down

0 comments on commit a70ac7e

Please sign in to comment.