Articles in this section
Category / Section

How to convert HTML to PDF using Blink in AWS Elastic Beanstalk

5 mins read

Steps to convert HTML to PDF using Blink in AWS Elastic Beanstalk

Step 1: Create a new C# ASP.NET Core Web Application project.

Create a new C# ASP.NET Core Web Application project.

Step 2: In configuration windows, name your project and select Next.
In configuration windows, name your project and select Next.

Select the framework

Step 3: Install the Syncfusion.HtmlToPdfConverter.Net.Aws NuGet package as a reference to your AWS Elastic Beanstalk project from NuGet.org.
Install the HTML to PDF AWS nuget package.

Step 4: A default controller named HomeController.cs gets added to create the ASP.NET Core MVC project. Include the following namespaces in that HomeController.cs file.

using Syncfusion.Pdf;
using Syncfusion.HtmlConverter;
using System.IO;

Step 5: Add a new button in index.cshtml as follows.

@{
   Html.BeginForm("BlinkToPDF", "Home", FormMethod.Get);
   {
       <div>
           <input type="submit" value="HTML To PDF" style="width:150px;height:27px" />
           <br />
           <div class="text-danger">
               @ViewBag.Message
           </div>
       </div>
   }
   Html.EndForm();
}

Step 6: Add a new action method named BlinkToPDF in HomeController.cs and include the following code example to convert HTML to PDF document using the Convert method in HtmlToPdfConverter class. The HTML content will be scaled based on the given ViewPortSize property of the BlinkConverterSettings class.

public IActionResult BlinkToPDF()
{
         //Initialize HTML to PDF converter.
         HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.Blink);
         BlinkConverterSettings settings = new BlinkConverterSettings();
         //Set command line arguments to run without the sandbox.
         settings.CommandLineArguments.Add("--no-sandbox");
         settings.CommandLineArguments.Add("--disable-setuid-sandbox");
         //Set Blink viewport size.
         settings.ViewPortSize = new Syncfusion.Drawing.Size(1280, 0);
         //Assign Blink settings to the HTML converter.
         htmlConverter.ConverterSettings = settings;
         //Convert URL to PDF document.
         PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com");
         //Create the memory stream.
         MemoryStream stream = new MemoryStream();
         //Save the document to the memory stream.
         document.Save(stream);
         return File(stream.ToArray(), System.Net.Mime.MediaTypeNames.Application.Pdf, "BlinkLinuxDockerAWSBeanstalk.pdf");
}

Step 7: Click the Publish to AWS Elastic Beanstalk (Legacy) option by right-clicking the project to publish the application in the AWS Elastic Beanstalk environment.

Publish a AWS Elastic Beanstalk

Step 8: Select the Create a new application environment and click Next from Publish to AWS Elastic Beanstalk window.
Select the Create a new application environment

Step 9: Please give any valid name to the environment and URL text box. Check whether the URL link is available while clicking the Check availability option. If the requested link is available means, click NEXT in the Application Environment window.
Please give any valid name to environment.

Step 10: Select t3a.micro from the Instance Type text box and select Next in the AWS Options Window.
Select t3a.micro as Instance Type

Step 11: Select the Roles and Next option from the Permissions window.
Select the Roles and click Next

Step 12: Click Next from the Application Options window.
Click Next on Application Options

Step 13: Click Deploy from the Review window.
Click Deploy button on Review window

Step 14: Click the URL link to launch the application once the Environment is updated successfully and Environment status is healthy.
Environment is updated successfully.

Now, the webpage will open in the browser. Click the button to convert the webpage to a PDF document.
Open the webpage in browser and Click the button.

By executing the program, you will get a PDF document as follows.
output screenshot

A complete working sample for converting an HTML to PDF using Blink in AWS Elastic Beanstalk can be downloaded from GitHub.

Click here to explore the rich set of Syncfusion Essential® PDF features.

Take a moment to peruse the documentation for Converting HTML to PDF, where you will find various options for URL to PDF, HTML string to PDF, and Hyperlinks.

AWS Elastic Beanstalk: AWSElasticBeanstalkSample.zip

See Also:

Convert HTML to PDF in AWS Lambda
Convert HTML to PDF in Azure Function
Convert HTML to PDF in Azure App Service
Convert HTML to PDF in Azure Function Linux
Convert HTML to PDF in Azure App Service Linux
Convert HTML to PDF in docker

Starting with v16.2.0.x, if you reference the Syncfusion® assemblies from the trial setup or the NuGet feed, include a license key in your projects. Refer to the link to learn about generating and registering the Syncfusion® license key in your application to use the components without trail message.

I hope you enjoyed learning about how to convert HTML to PDF using Blink in AWS Elastic Beanstalk.

You can refer to our ASP.NET Core PDF’s feature tour page to know about its other groundbreaking feature representations. You can also explore our ASP.NET Core PDF example to understand how to present and manipulate data.

For current customers, you can check out our ASP.NET Core components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our ASP.NET Core PDF and other ASP.NET Core components.

If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied