PuppeteerSharp
DinkToPdf
Our great sponsors
PuppeteerSharp | DinkToPdf | |
---|---|---|
16 | 4 | |
3,162 | 1,037 | |
3.3% | - | |
9.3 | 0.0 | |
3 days ago | about 4 years ago | |
C# | C# | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
PuppeteerSharp
-
What do .NET devs use for web scraping these days?
PuppeteerSharp
-
(Free) Open-source PDF Generation/Export
Otherwise, any pdf to hml chromium based solution hosted via docker, like gotenberg](https://github.com/gotenberg/gotenberg) or browserless.io(which is free if you create open source). Generating pdfs from html directly in .NET was always a pain. Wkhtml (and wrappers that use it) uses WebKit and comes with a load of issues of its own, similar to running and styling anything in Safari. Using chromium based engine saves a lot of time as it's the most popular way of doing it these days. You can also use puppeteer-sharp with local chromium if you host your app on something that allows it(f.e. not Azure Functions).
- A Handlebar and Puppeteer Equivalent in C#?
-
Puppeteer Sharp: Crawl the Web using C# and Headless Chrome
Puppeteer Sharp is a port of the popular Headless Chrome NodeJS API built by Google. Puppeteer Sharp was written in C# and released in 2017 by Darío Kondratiuk to offer the same functionality to .NET developers.
-
Looking for a way to allow users to download a PDF containing client-side rendered graphs
there is a dotnet package for using headless chrome: https://www.puppeteersharp.com/ its a port of the nodejs package of the same name
-
HTMLtoPDF
For the actual conversion of html to pdf we use PuppeteerSharp (https://www.puppeteersharp.com ) but you need browserless for that, which requires an api key (don’t know the pricing)
-
Dynamic html parser (alternative of phantomJS)
The README in the GitHub site has been good enough for me: https://github.com/hardkoded/puppeteer-sharp
-
QuestPDF 2022.01 - a new version of the open-source, C# library for generating complex PDF documents with fluent API, now with complex table-layout support 🎉 Please help me make it popular 🚀
Iv'e been using https://github.com/hardkoded/puppeteer-sharp for html to pdf conversion for quite some time with success. (in both .net framework and .net core)
-
Last C# PDF doc/tutorial by Microsoft. Tomorrow, the PDF generation feature will be officially retired. So, I took this opportunity to archive this format. (Up to .NET 6)
Just generate HTML and use https://github.com/hardkoded/puppeteer-sharp to produce a PDF from headless Chrome.
-
Best PDF generation library to create nested tables
Another idea is to maybe generate the document as HTML first and then convert the HTML to a PDF (with somehting like PuppeteerSharp. I have found this more flexible in the past, but I have not personally done with with nested tables.
DinkToPdf
-
How to generate PDF and HTML in 2023?
I used this package for a while to generate the PDF from HTML - https://github.com/rdvojmoc/DinkToPdf
-
Loving MudBlazor but need a fully-featured PDF viewer/annotator component like Syncfusion's
This may not be applicable in your situation, but I'll leave this info here anyways. I used DinkToPdf https://github.com/rdvojmoc/DinkToPdf for a Blazor Server and a Blazor WASM OMS application. I created a 'Reports' controller, created two different controller action methods. One to create the HTML for the PDF and the other to actually generate the PDF.
-
Best free .NET core 5.0 HTML to PDF to use?
The install instructions for DinkToPdf (see github) have a step about installing native binaries that your tutorial seems to be missing.
-
Azure Functions & wkhtmltopdf: Convert HTML to PDF
using Microsoft.Azure.WebJobs; using Microsoft.Azure.WebJobs.Extensions.Http; using Microsoft.Extensions.Logging; using DinkToPdf; using IPdfConverter = DinkToPdf.Contracts.IConverter; using Microsoft.WindowsAzure.Storage; using Microsoft.WindowsAzure.Storage.Blob; using System.Threading.Tasks; namespace Html2Pdf { public class Html2Pdf { // Read more about converter on: https://github.com/rdvojmoc/DinkToPdf // For our purposes we are going to use SynchronizedConverter IPdfConverter pdfConverter = new SynchronizedConverter(new PdfTools()); // A function to convert html content to pdf based on the configuration pased as arguments // Arguments: // HtmlContent: the html content to be converted // Width: the width of the pdf to be created. e.g. "8.5in", "21.59cm" etc. // Height: the height of the pdf to be created. e.g. "11in", "27.94cm" etc. // Margins: the margis around the content // DPI: The dpi is very important when you want to print the pdf. // Returns a byte array of the pdf which can be stored as a file private byte[] BuildPdf(string HtmlContent, string Width, string Height, MarginSettings Margins, int? DPI = 180) { // Call the Convert method of SynchronizedConverter "pdfConverter" return pdfConverter.Convert(new HtmlToPdfDocument() { // Set the html content Objects = { new ObjectSettings { HtmlContent = HtmlContent } }, // Set the configurations GlobalSettings = new GlobalSettings { // PaperKind.A4 can also be used instead of width & height PaperSize = new PechkinPaperSize(Width, Height), DPI = DPI, Margins = Margins } }); } // The name of the function [FunctionName("Html2Pdf")] // The first arugment tells that the functions can be triggerd by a POST HTTP request. // The second argument is mainly used for logging information, warnings or errors public async Task Run([HttpTrigger(AuthorizationLevel.Function, "POST")] Html2PdfRequest Request, ILogger Log) { // PDFByteArray is a byte array of pdf generated from the HtmlContent var PDFByteArray = BuildPdf(Request.HtmlContent, "8.5in", "11in", new MarginSettings(0, 0, 0, 0)); // The connection string of the Storage Account to which our PDF file will be uploaded // The connection string of the Storage Account to which our PDF file will be uploaded var StorageConnectionString = "DefaultEndpointsProtocol=https;AccountName=;AccountKey=;EndpointSuffix=core.windows.net"; // Generate an instance of CloudStorageAccount by parsing the connection string var StorageAccount = CloudStorageAccount.Parse(StorageConnectionString); // Create an instance of CloudBlobClient to connect to our storage account CloudBlobClient BlobClient = StorageAccount.CreateCloudBlobClient(); // Get the instance of CloudBlobContainer which points to a container name "pdf" // Replace your own container name CloudBlobContainer BlobContainer = BlobClient.GetContainerReference("pdf"); // Get the instance of the CloudBlockBlob to which the PDFByteArray will be uploaded CloudBlockBlob Blob = BlobContainer.GetBlockBlobReference(Request.PDFFileName); // Upload the pdf blob await Blob.UploadFromByteArrayAsync(PDFByteArray, 0, PDFByteArray.Length); } } }
What are some alternatives?
CefSharp - .NET (WPF and Windows Forms) bindings for the Chromium Embedded Framework
WKHTMLToPDF - Convert HTML to PDF using Webkit (QtWebKit)
playwright-dotnet - .NET version of the Playwright testing and automation library.
gotenberg - A developer-friendly API for converting numerous document formats into PDF files, and more!
ASP.NET Core - ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
Report-From-DocX-HTML-To-PDF-Converter - .NET Core library to create custom reports based on Word docx or HTML documents and convert to PDF
HtmlAgilityPack - Html Agility Pack (HAP) is a free and open-source HTML parser written in C# to read/write DOM and supports plain XPATH or XSLT. It is a .NET code library that allows you to parse "out of the web" HTML files.
scryber.core - Scryber.Core is a dotnet html to pdf engine written entirely in C# for creating beautiful flexible, flowing documents from html templates including css styles, data binding, svg drawing and encryption
FlaUI - UI automation library for .Net
go-wkhtmltopdf - Go bindings for wkhtmltopdf and high-level HTML to PDF conversion interface
playwright-sharp - .NET version of the Playwright testing and automation library. [Moved to: https://github.com/microsoft/playwright-dotnet]
GotenbergSharpApiClient - .NET C# Client for the Gotenberg API