From 6d09d2ee9f08a8a4f98e1aba25cc7fa0bf83e2a9 Mon Sep 17 00:00:00 2001 From: Sowmiya Loganathan Date: Tue, 26 Sep 2023 19:21:23 +0530 Subject: [PATCH 1/2] Updated the vol3 features code example --- .../PDF/Convert-HTML-To-PDF/features.md | 74 ++++++++++++------- 1 file changed, 49 insertions(+), 25 deletions(-) diff --git a/File-Formats/PDF/Convert-HTML-To-PDF/features.md b/File-Formats/PDF/Convert-HTML-To-PDF/features.md index 554e700cf..da2ce1f7c 100644 --- a/File-Formats/PDF/Convert-HTML-To-PDF/features.md +++ b/File-Formats/PDF/Convert-HTML-To-PDF/features.md @@ -1821,9 +1821,9 @@ blinkConverterSettings.Margin.All = 30; blinkConverterSettings.Css = "body {\r\n background-color: red; \r\n}"; htmlConverter.ConverterSettings = blinkConverterSettings; //Convert the URL to PDF document. -PdfDocument document = htmlConverter.Convert(https://www.syncfusion.com); +PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com"); //Create a filestream. -FileStream fileStream = new FileStream("Test.pdf", FileMode.CreateNew, FileAccess.ReadWrite); +FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); //Save and close the PDF document. document.Save(fileStream); document.Close(true); @@ -1844,7 +1844,7 @@ htmlConverter.ConverterSettings = blinkConverterSettings 'Convert the URL to PDF document. Dim document As PdfDocument = htmlConverter.Convert(https://www.syncfusion.com) 'Create a filestream. -Dim fileStream As FileStream = New FileStream("Test.pdf", FileMode.CreateNew, FileAccess.ReadWrite) +Dim fileStream As FileStream = New FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite) 'Save and close the PDF document. document.Save(fileStream) document.Close(true) @@ -1853,6 +1853,8 @@ document.Close(true) {% endtabs %} +You can download a complete working sample from [GitHub](). + ## Inject custom JavaScript The Blink rendering engine offers support for injecting custom JavaScript to be applied to the HTML or a URL before rendering it into a PDF document using the 'JavaScript' property of the [BlinkConverterSettings](https://help.syncfusion.com/cr/file-formats/Syncfusion.HtmlConverter.BlinkConverterSettings.html) class. @@ -1871,9 +1873,9 @@ blinkConverterSettings.Margin.All = 30; blinkConverterSettings.JavaScript = "document.querySelectorAll('img').forEach((node)=>{node.remove();})"; htmlConverter.ConverterSettings = blinkConverterSettings; //Convert the URL to PDF document. -PdfDocument document = htmlConverter.Convert(https://www.syncfusion.com); +PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com"); //Create a filestream. -FileStream fileStream = new FileStream("Test.pdf", FileMode.CreateNew, FileAccess.ReadWrite); +FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); //Save and close the PDF document. document.Save(fileStream); document.Close(true); @@ -1892,9 +1894,9 @@ blinkConverterSettings.Margin.All = 30 blinkConverterSettings.JavaScript = "document.querySelectorAll('img').forEach((node)=>{node.remove();})" htmlConverter.ConverterSettings = blinkConverterSettings 'Convert the URL to PDF document. -Dim document As PdfDocument = htmlConverter.Convert(https://www.syncfusion.com) +Dim document As PdfDocument = htmlConverter.Convert("https://www.syncfusion.com") 'Create a filestream. -Dim fileStream As FileStream = New FileStream("Test.pdf", FileMode.CreateNew, FileAccess.ReadWrite) +Dim fileStream As FileStream = New FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite) 'Save and close the PDF document. document.Save(fileStream) document.Close(true) @@ -1903,6 +1905,8 @@ document.Close(true) {% endtabs %} +You can download a complete working sample from [GitHub](). + ## Performance optimization The Blink rendering engine provides support for reusing the browser process to optimize the HTML to a PDF performance for multiple operations using the 'ReuseBrowserProcess' property of the [HtmlToPdfConverter](https://help.syncfusion.com/cr/file-formats/Syncfusion.HtmlConverter.HtmlToPdfConverter.html) class. @@ -1915,43 +1919,63 @@ The Blink rendering engine provides support for reusing the browser process to o HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); //Reuse the browser instance. htmlConverter.ReuseBrowserProcess = true; -for (int i = 0; i < 10; i++) -{ +//Create PDF document. +PdfDocument document = new PdfDocument(); +//Create memory stream. +MemoryStream memoryStream = new MemoryStream(); +for (int i = 0; i < 10; i++) +{ + //Initialize the blink converter settings. BlinkConverterSettings settings = new BlinkConverterSettings(); settings.AdditionalDelay = 1000; settings.EnableJavaScript = true; - htmlConverter.ConverterSettings = settings; + //Assign the settings to HTML converter. + htmlConverter.ConverterSettings = settings; //Convert the URL to PDF document. - PdfDocument document = htmlConverter.Convert(https://www.google.com); - document.Save("Sample.pdf"); + document = htmlConverter.Convert("https://www.google.com"); + //Save and close the PDF document. + document.Save(memoryStream); + document.Close(true); + File.WriteAllBytes("ReuseBrowserProcess" + Guid.NewGuid().ToString() + ".pdf", memoryStream.ToArray()); } +//Close HTML converter. htmlConverter.Close(); {% endhighlight %} {% highlight vb.net tabtitle="VB.NET [Windows-specific]" %} -'Initialize HTML to PDF converter. +'Initialize the HTML to PDF converter. Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() -'Reuse the browser instance. -htmlConverter.ReuseBrowserProcess = true -For i As Integer = 0 To 9 -{ - Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter() +'Reuse the browser instance. +htmlConverter.ReuseBrowserProcess = True +'Create PDF document. +Dim document As PdfDocument = New PdfDocument() +'Create memory stream. +Dim memoryStream As MemoryStream = New MemoryStream() +For i As Integer = 0 To 10 - 1 + 'Initialize the blink converter settings. + Dim settings As BlinkConverterSettings = New BlinkConverterSettings() settings.AdditionalDelay = 1000 - settings.EnableJavaScript = true - htmlConverter.ConverterSettings = settings - 'Convert URL to PDF document. - Dim document As PdfDocument = htmlConverter.Convert(https://www.google.com) - document.Save("Sample.pdf"); -} -Next i + settings.EnableJavaScript = True + 'Assign the settings to HTML converter. + htmlConverter.ConverterSettings = settings + 'Convert the URL to PDF document. + document = htmlConverter.Convert("https://www.google.com") + 'Save and close the PDF document. + document.Save(memoryStream) + document.Close(True) + File.WriteAllBytes("ReuseBrowserProcess" & Guid.NewGuid().ToString() & ".pdf", memoryStream.ToArray()) +Next +'Close HTML converter. htmlConverter.Close() {% endhighlight %} {% endtabs %} +You can download a complete working sample from [GitHub](). + ## Temporary path The Blink HTML converter launching Chrome browser to perform conversion. While launching Chrome browser, temporary files are created in a temporary folder. From 0fe2b9e4feb63ea2f11236647118dac7fbe4dbcc Mon Sep 17 00:00:00 2001 From: Sowmiya Loganathan Date: Wed, 27 Sep 2023 15:22:49 +0530 Subject: [PATCH 2/2] Update GitHub samples link --- File-Formats/PDF/Convert-HTML-To-PDF/features.md | 10 ++++++---- File-Formats/PDF/Working-with-OCR/Features.md | 5 ++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/File-Formats/PDF/Convert-HTML-To-PDF/features.md b/File-Formats/PDF/Convert-HTML-To-PDF/features.md index da2ce1f7c..b0f5ae073 100644 --- a/File-Formats/PDF/Convert-HTML-To-PDF/features.md +++ b/File-Formats/PDF/Convert-HTML-To-PDF/features.md @@ -1853,7 +1853,7 @@ document.Close(true) {% endtabs %} -You can download a complete working sample from [GitHub](). +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/Blink/Inject_custom_CSS_to_HTML). ## Inject custom JavaScript @@ -1905,7 +1905,7 @@ document.Close(true) {% endtabs %} -You can download a complete working sample from [GitHub](). +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/Blink/Inject_custom_JavaScript_to_HTML). ## Performance optimization @@ -1974,7 +1974,7 @@ htmlConverter.Close() {% endtabs %} -You can download a complete working sample from [GitHub](). +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/Blink/Optimize-HTML-to-PDF-performance). ## Temporary path @@ -2077,4 +2077,6 @@ document.Close(True) {% endhighlight %} -{% endtabs %} \ No newline at end of file +{% endtabs %} + +You can download a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/HTML%20to%20PDF/Blink/Set_blink_path_in_HTML_to_PDF). \ No newline at end of file diff --git a/File-Formats/PDF/Working-with-OCR/Features.md b/File-Formats/PDF/Working-with-OCR/Features.md index 822998c46..57d0d1e01 100644 --- a/File-Formats/PDF/Working-with-OCR/Features.md +++ b/File-Formats/PDF/Working-with-OCR/Features.md @@ -1211,6 +1211,7 @@ processor.Settings.Performance = Performance.Fast {% endhighlight %} {% endtabs %} + ## TesseractBinaries Paths and Tesseract Language Data Starting with v21.1.x, TesseractBinaries, and Tesseract language data folder paths are added by default. So, there is no need to provide these paths explicitly. However, you can refer to TesseractBinaries and Tessdata paths manually in your application as per the requirement. @@ -1345,4 +1346,6 @@ End Using {% endhighlight %} -{% endtabs %} \ No newline at end of file +{% endtabs %} + +You can downloaded a complete working sample from [GitHub](https://github.com/SyncfusionExamples/PDF-Examples/tree/master/OCR/.NET/Get-image-rotation-angle-from-OCR).