Skip to content

Commit 756d475

Browse files
committed
994279-ug: Resolved the given feedback.
1 parent 19d5d32 commit 756d475

File tree

1 file changed

+39
-35
lines changed
  • Document-Processing/PDF/Conversions/HTML-To-PDF/NET

1 file changed

+39
-35
lines changed

Document-Processing/PDF/Conversions/HTML-To-PDF/NET/features.md

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -819,10 +819,10 @@ using Syncfusion.Drawing;
819819
using Syncfusion.HtmlConverter;
820820
using Syncfusion.Pdf;
821821

822-
// Create an instance of HTML-to-PDF converter using Blink rendering engine
822+
// Create an instance of HTML-to-PDF converter
823823
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();
824824
// Configure Blink converter settings
825-
BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings
825+
BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings()
826826
{
827827
ViewPortSize = new Size(1280, 0), // Set viewport width for rendering
828828
EnableToc = true, // Enable Table of Contents (TOC)
@@ -832,24 +832,25 @@ blinkConverterSettings.Toc.StartingPageNumber = 1;
832832
// Apply the settings to the converter
833833
htmlConverter.ConverterSettings = blinkConverterSettings;
834834
// Read the main HTML content and convert it to PDF
835-
string inputhtml = File.ReadAllText("Data/input.html");
836-
using (PdfDocument document = htmlConverter.Convert(inputhtml, ""))
835+
string inputhtml = File.ReadAllText("input.html");
836+
PdfDocument document = htmlConverter.Convert(inputhtml, "");
837+
//Create cover page and insert to the 0th index.
838+
// Apply scaling settings for the cover page
839+
htmlConverter.ConverterSettings = new BlinkConverterSettings()
837840
{
838-
// Apply scaling settings for the cover page
839-
htmlConverter.ConverterSettings = new BlinkConverterSettings()
840-
{
841-
Scale = 1.5f
842-
};
843-
// Convert the cover page HTML to PDF
844-
string coverimage = File.ReadAllText(Path.GetFullPath(@"Data/coverpage.html"));
845-
using (PdfDocument coverPage = htmlConverter.Convert(coverimage, ""))
846-
{
847-
// Insert the cover page at the beginning of the main document
848-
document.Pages.Insert(0, coverPage.Pages[0]);
849-
// Save the PDF document
850-
document.Save("Output.pdf");
851-
}
852-
}
841+
Scale = 1.5f
842+
};
843+
// Convert the cover page HTML to PDF
844+
string coverimage = File.ReadAllText("coverpage.html");
845+
PdfDocument coverPage = htmlConverter.Convert(coverimage, "");
846+
// Insert the cover page at the beginning of the main document
847+
document.Pages.Insert(0, coverPage.Pages[0]);
848+
// Save the PDF document
849+
document.Save("Output.pdf");
850+
//Dispose the document
851+
coverPage.Close(true);
852+
document.Close(true);
853+
htmlConverter.Close();
853854

854855
{% endhighlight %}
855856

@@ -859,7 +860,7 @@ Imports Syncfusion.Drawing
859860
Imports Syncfusion.HtmlConverter
860861
Imports Syncfusion.Pdf
861862

862-
' Create an instance of HTML-to-PDF converter using Blink rendering engine
863+
' Create an instance of HTML-to-PDF converter
863864
Dim htmlConverter As New HtmlToPdfConverter()
864865
' Configure Blink converter settings
865866
Dim blinkConverterSettings As New BlinkConverterSettings() With {
@@ -871,21 +872,24 @@ blinkConverterSettings.Toc.StartingPageNumber = 1
871872
' Apply the settings to the converter
872873
htmlConverter.ConverterSettings = blinkConverterSettings
873874
' Read the main HTML content and convert it to PDF
874-
Dim inputhtml As String = File.ReadAllText("Data/input.html")
875-
Using document As PdfDocument = htmlConverter.Convert(inputhtml, "")
876-
' Apply scaling settings for the cover page
877-
htmlConverter.ConverterSettings = New BlinkConverterSettings() With {
878-
.Scale = 1.5F
879-
}
880-
' Convert the cover page HTML to PDF
881-
Dim coverimage As String = File.ReadAllText(Path.GetFullPath("Data/coverpage.html"))
882-
Using coverPage As PdfDocument = htmlConverter.Convert(coverimage, "")
883-
' Insert the cover page at the beginning of the main document
884-
document.Pages.Insert(0, coverPage.Pages(0))
885-
' Save the PDF document
886-
document.Save("Output.pdf")
887-
End Using
888-
End Using
875+
Dim inputhtml As String = File.ReadAllText("input.html")
876+
Dim document As PdfDocument = htmlConverter.Convert(inputhtml, "")
877+
' Create cover page and insert to the 0th index.
878+
' Apply scaling settings for the cover page
879+
htmlConverter.ConverterSettings = New BlinkConverterSettings() With {
880+
.Scale = 1.5F
881+
}
882+
' Convert the cover page HTML to PDF
883+
Dim coverimage As String = File.ReadAllText("coverpage.html")
884+
Dim coverPage As PdfDocument = htmlConverter.Convert(coverimage, "")
885+
' Insert the cover page at the beginning of the main document
886+
document.Pages.Insert(0, coverPage.Pages(0))
887+
' Save the PDF document
888+
document.Save("Output.pdf")
889+
' Dispose the documents
890+
coverPage.Close(True)
891+
document.Close(True)
892+
htmlConverter.Close()
889893

890894
{% endhighlight %}
891895

0 commit comments

Comments
 (0)