Skip to content

Commit ea4a03d

Browse files
Merge pull request #31 from SyncfusionExamples/968984_commandline
968984_Removed the commandline arguments in the blink converter settings.
2 parents ae6f1ca + 710c96e commit ea4a03d

File tree

97 files changed

+174047
-25
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+174047
-25
lines changed

AWS/AWSElasticBeanstalkSample/Controllers/HomeController.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ public IActionResult BlinkToPDF()
2626
//Initialize HTML to PDF converter.
2727
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.Blink);
2828
BlinkConverterSettings settings = new BlinkConverterSettings();
29-
//Set command line arguments to run without the sandbox.
30-
settings.CommandLineArguments.Add("--no-sandbox");
31-
settings.CommandLineArguments.Add("--disable-setuid-sandbox");
3229
//Set Blink viewport size.
3330
settings.ViewPortSize = new Syncfusion.Drawing.Size(1280, 0);
3431
//Assign Blink settings to the HTML converter.

AWS/HTML_to_PDF_Lambda_Docker_Container/HTML_to_PDF_Lambda_Docker_Container/Function.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ public string FunctionHandler(string input, ILambdaContext context)
2525
BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings();
2626

2727
blinkConverterSettings.BlinkPath = Path.GetFullPath("BlinkBinariesAws");
28-
blinkConverterSettings.CommandLineArguments.Add("--no-sandbox");
29-
blinkConverterSettings.CommandLineArguments.Add("--disable-setuid-sandbox");
3028

3129
blinkConverterSettings.AdditionalDelay = 3000;
3230

AWS/NetCoreAWSFargate/Controllers/HomeController.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ public IActionResult BlinkToPDF()
2525
//Initialize HTML to PDF converter.
2626
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.Blink);
2727
BlinkConverterSettings settings = new BlinkConverterSettings();
28-
//Set command line arguments to run without the sandbox.
29-
settings.CommandLineArguments.Add("--no-sandbox");
30-
settings.CommandLineArguments.Add("--disable-setuid-sandbox");
3128
//Set Blink viewport size.
3229
settings.ViewPortSize = new Syncfusion.Drawing.Size(1280, 0);
3330
//Assign Blink settings to the HTML converter.

Azure/HTML_to_PDF_Azure_app_service/HtmlToPdfBlinkAzureAppLinux/Controllers/HomeController.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ public ActionResult ExportToPDF()
3131
//Initialize HTML to PDF converter
3232
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();
3333
BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings();
34-
//Set command line arguments to run without sandbox.
35-
blinkConverterSettings.CommandLineArguments.Add("--no-sandbox");
36-
blinkConverterSettings.CommandLineArguments.Add("--disable-setuid-sandbox");
3734
htmlConverter.ConverterSettings = blinkConverterSettings;
3835
PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com");
3936
MemoryStream outputStream = new MemoryStream();

Azure/HTML_to_PDF_Azure_app_service_docker/HTML_to_PDF_Azure_app_service_docker/Controllers/HomeController.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ public ActionResult ExportToPDF()
3636
//Initialize HTML to PDF converter.
3737
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();
3838
BlinkConverterSettings settings = new BlinkConverterSettings();
39-
//Set command line arguments to run without the sandbox.
40-
settings.CommandLineArguments.Add("--no-sandbox");
41-
settings.CommandLineArguments.Add("--disable-setuid-sandbox");
4239
//Assign Blink settings to the HTML converter.
4340
htmlConverter.ConverterSettings = settings;
4441
//Convert URL to PDF.

Azure/HTML_to_PDF_Azure_functions/HTML_to_PDF_Azure_functions/Function1.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ public static async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Func
3434

3535
//Initialize the HTML to PDF converter with the Blink rendering engine.
3636
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.Blink);
37-
38-
//Set command line arguments to run without sandbox.
39-
settings.CommandLineArguments.Add("--no-sandbox");
40-
settings.CommandLineArguments.Add("--disable-setuid-sandbox");
4137
settings.BlinkPath = blinkBinariesPath;
4238
//Assign BlinkConverter settings to the HTML converter
4339
htmlConverter.ConverterSettings = settings;

Docker/HTML_to_PDF_docker/Controllers/HomeController.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ public ActionResult ExportToPDF()
4141
//Initialize HTML to PDF converter.
4242
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();
4343
BlinkConverterSettings settings = new BlinkConverterSettings();
44-
//Set command line arguments to run without sandbox.
45-
settings.CommandLineArguments.Add("--no-sandbox");
46-
settings.CommandLineArguments.Add("--disable-setuid-sandbox");
4744
//Set Blink viewport size.
4845
settings.ViewPortSize = new Syncfusion.Drawing.Size(1280, 0);
4946
//Assign Blink settings to HTML converter.

Linux/Program.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ static void Main(string[] args)
1414

1515
BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings();
1616

17-
blinkConverterSettings.CommandLineArguments.Add("--no-sandbox");
18-
19-
blinkConverterSettings.CommandLineArguments.Add("--disable-setuid-sandbox");
20-
2117
//Assign Blink converter settings to HTML converter
2218
htmlConverter.ConverterSettings = blinkConverterSettings;
2319

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Syncfusion.HtmlConverter;
3+
using Syncfusion.Pdf;
4+
using Syncfusion_HTMLtoPDF.Models;
5+
using System.Diagnostics;
6+
using System.IO;
7+
8+
namespace Syncfusion_HTMLtoPDF.Controllers
9+
{
10+
public class HomeController : Controller
11+
{
12+
private readonly Microsoft.AspNetCore.Hosting.IHostingEnvironment _hostingEnvironment;
13+
public HomeController(Microsoft.AspNetCore.Hosting.IHostingEnvironment hostingEnvironment)
14+
{
15+
_hostingEnvironment = hostingEnvironment;
16+
}
17+
public IActionResult Index()
18+
{
19+
return View();
20+
}
21+
public IActionResult ConvertToPdf()
22+
{
23+
24+
string fileName = "HtmlSample_Thousand";
25+
//string fileName = "HtmlSample";
26+
//string fileName = "HtmlSample_FiveHundred";
27+
//string fileName = "HtmlSample_Hundred";
28+
double totalTime = 0;
29+
string ConsoleLog = "";
30+
MemoryStream stream = null;
31+
for (int i = 0; i < 5; i++)
32+
{
33+
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();
34+
BlinkConverterSettings settings = new BlinkConverterSettings();
35+
settings.AdditionalDelay = 0;
36+
settings.Margin.All = 0;
37+
settings.Scale = 1.0f;
38+
htmlConverter.ConverterSettings = settings;
39+
string htmlFilePath = Path.Combine(_hostingEnvironment.WebRootPath,"Data", fileName + ".html");
40+
Stopwatch watch = new Stopwatch();
41+
watch.Start();
42+
//Convert URL to PDF
43+
PdfDocument document = htmlConverter.Convert(htmlFilePath);
44+
watch.Stop();
45+
totalTime += watch.Elapsed.TotalSeconds;
46+
ConsoleLog+=(i + 1) + " conversion time:" + watch.Elapsed.TotalSeconds+"\n";
47+
48+
if (i == 0)
49+
{
50+
using (stream = new MemoryStream())
51+
{
52+
document.Save(stream);
53+
document.Close(true);
54+
}
55+
}
56+
}
57+
double averageTime = totalTime / 5;
58+
ConsoleLog+="Average conversion time:" + averageTime+"\n";
59+
System.IO.File.WriteAllText(Path.Combine(_hostingEnvironment.WebRootPath, "Data", fileName + ".txt"), ConsoleLog);
60+
return File(stream.ToArray(), System.Net.Mime.MediaTypeNames.Application.Pdf, "HTML-to-PDF.pdf");
61+
}
62+
63+
public IActionResult Privacy()
64+
{
65+
return View();
66+
}
67+
68+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
69+
public IActionResult Error()
70+
{
71+
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
72+
}
73+
}
74+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Syncfusion_HTMLtoPDF.Models
2+
{
3+
public class ErrorViewModel
4+
{
5+
public string? RequestId { get; set; }
6+
7+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
8+
}
9+
}

0 commit comments

Comments
 (0)