Organizations perform HTML to PDF conversions for many reasons, such as archiving web content, simplifying web content review processes, or creating a printer-friendly web page version.

GrapeCity Documents for PDF API features the GcHtml package. GcHtml lets users convert an HTML string or an HTML web page to PDF.

The RenderToPdf method of the GcHtmlRenderer class performs the conversion. Different overloads of this method let users save the HTML to a PDF file or a stream. Alter the generated PDF file settings (page height, width, header, footer, etc.) with the PdfSettings class.

Outlined below is the process of converting a web page to a PDF file on a Linux Azure app service using the GcHtmlRenderer class.

Step 1: Create a Web Application that Converts HTML to PDF

  • Create a new ASP. NET Core Web application using the Model-View-Controller template in VS2019 on a Windows machine.

Converting HTML to PDF on Linux Azure App Service

  • Install the following packages in the project using NuGet Package Manager
  • Grapecity.Documents.Html
  • Grapecity.Documents.Html.Windows.X64
  • Grapecity.Documents.Html.Linux.X64

(Note: The application deployment target is Linux, hence ‘Grapecity.Documents.Html.Windows .X64’ package is only needed for local debugging on Windows)

  • Use GcHtmlRenderer and RenderToPdf method
  • Add a method to HomeController.cs which implements the “Render HTML to PDF” feature

#web #.net #desktop #document apis

Converting HTML to PDF on Linux Azure App Service
1.75 GEEK