Skip to content

Commit a4ce2ac

Browse files
committed
994279-ug: Resolved the given feedback.
1 parent 9d0ee42 commit a4ce2ac

File tree

1 file changed

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

1 file changed

+35
-44
lines changed

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

Lines changed: 35 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -807,9 +807,9 @@ padding-left: 5px;
807807

808808
You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/Blink/Create-custom-style-TOC-when-converting-HTML-to-PDF).
809809

810-
## Skip Cover Page in TOC Numbering
810+
## Exclude cover page from TOC
811811

812-
The following code snippet demonstrates how to set the starting page number for the Table of Contents (TOC) so that it skips the cover page. In this example, we have only one cover page, so the starting page number is set to 1. If your document includes multiple cover pages, you can adjust this value accordingly.
812+
This code snippet shows how to configure the Table of Contents (TOC) to skip the cover page by setting the starting page number. In this example, the cover page is a single page, so the TOC begins at page 1. For documents with multiple cover pages, adjust the starting page number as needed.
813813

814814
{% tabs %}
815815

@@ -832,22 +832,24 @@ 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("input.html"));
836-
PdfDocument document = htmlConverter.Convert(inputhtml, "");
837-
// Create new settings for scaling the cover page
838-
BlinkConverterSettings settings = new BlinkConverterSettings();
839-
settings.Scale = 1.5f;
840-
// Apply scaling settings
841-
htmlConverter.ConverterSettings = settings;
842-
// Convert the cover page HTML to PDF
843-
string coverimage = File.ReadAllText("coverpage.html"));
844-
PdfDocument coverPage = htmlConverter.Convert(coverimage, "");
845-
// Insert the cover page at the beginning of the main document
846-
document.Pages.Insert(0, coverPage.Pages[0]);
847-
// Save the PDF document
848-
document.Save("Output.pdf"));
849-
// Close the PDF document
850-
document.Close(true);
835+
string inputhtml = File.ReadAllText("Data/input.html");
836+
using (PdfDocument document = htmlConverter.Convert(inputhtml, ""))
837+
{
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+
}
851853

852854
{% endhighlight %}
853855

@@ -859,42 +861,31 @@ Imports Syncfusion.Pdf
859861

860862
' Create an instance of HTML-to-PDF converter using Blink rendering engine
861863
Dim htmlConverter As New HtmlToPdfConverter()
862-
863864
' Configure Blink converter settings
864865
Dim blinkConverterSettings As New BlinkConverterSettings() With {
865866
.ViewPortSize = New Size(1280, 0), ' Set viewport width for rendering
866867
.EnableToc = True ' Enable Table of Contents (TOC)
867868
}
868-
869869
' Set TOC starting page number to skip the cover page
870870
blinkConverterSettings.Toc.StartingPageNumber = 1
871-
872871
' Apply the settings to the converter
873872
htmlConverter.ConverterSettings = blinkConverterSettings
874-
875873
' Read the main HTML content and convert it to PDF
876-
Dim inputhtml As String = File.ReadAllText("input.html")
877-
Dim document As PdfDocument = htmlConverter.Convert(inputhtml, "")
878-
879-
' Create new settings for scaling the cover page
880-
Dim settings As New BlinkConverterSettings()
881-
settings.Scale = 1.5F
882-
883-
' Apply scaling settings
884-
htmlConverter.ConverterSettings = settings
885-
886-
' Convert the cover page HTML to PDF
887-
Dim coverimage As String = File.ReadAllText("coverpage.html")
888-
Dim coverPage As PdfDocument = htmlConverter.Convert(coverimage, "")
889-
890-
' Insert the cover page at the beginning of the main document
891-
document.Pages.Insert(0, coverPage.Pages(0))
892-
893-
' Save the PDF document
894-
document.Save("Output.pdf")
895-
896-
' Close the PDF document
897-
document.Close(True)
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
898889

899890
{% endhighlight %}
900891

0 commit comments

Comments
 (0)