All Projects → rdvojmoc → Dinktopdf

rdvojmoc / Dinktopdf

Licence: mit
C# .NET Core wrapper for wkhtmltopdf library that uses Webkit engine to convert HTML pages to PDF.

Projects that are alternatives of or similar to Dinktopdf

Docnet
DocNET is as fast PDF editing and reading library for modern .NET applications
Stars: ✭ 128 (-81.23%)
Mutual labels:  pdf, pdf-converter
Stapler
A small utility making use of the pypdf library to provide a (somewhat) lighter alternative to pdftk
Stars: ✭ 238 (-65.1%)
Mutual labels:  pdf, pdf-converter
Net Core Docx Html To Pdf Converter
.NET Core library to create custom reports based on Word docx or HTML documents and convert to PDF
Stars: ✭ 133 (-80.5%)
Mutual labels:  pdf, pdf-converter
Remarks
Extract highlights, scribbles, and annotations from PDFs marked with the reMarkable tablet. Export to Markdown, PDF, PNG, and SVG
Stars: ✭ 94 (-86.22%)
Mutual labels:  pdf, pdf-converter
Images To Pdf
An app to convert images to PDF file!
Stars: ✭ 602 (-11.73%)
Mutual labels:  pdf, pdf-converter
Email To Pdf Converter
Converts email files (eml, msg) to pdf
Stars: ✭ 110 (-83.87%)
Mutual labels:  pdf, pdf-converter
Doctron
Docker-powered html convert to pdf(html2pdf), html to image(html2image like jpeg,png),which using chrome(golang) kernel, add watermarks to pdf, convert pdf to images etc.
Stars: ✭ 141 (-79.33%)
Mutual labels:  pdf, pdf-converter
Gotenberg Go Client
Go client for the Gotenberg API
Stars: ✭ 35 (-94.87%)
Mutual labels:  pdf, pdf-converter
Node Html Pdf
📄 Html to pdf converter in nodejs. It spawns a phantomjs process and passes the pdf as buffer or as filename.
Stars: ✭ 3,364 (+393.26%)
Mutual labels:  pdf, pdf-converter
Python Automation Scripts
Simple yet powerful automation stuffs.
Stars: ✭ 292 (-57.18%)
Mutual labels:  pdf, pdf-converter
Gotenberg Php Client
PHP client for the Gotenberg API
Stars: ✭ 80 (-88.27%)
Mutual labels:  pdf, pdf-converter
Pdf To Text
Extract text from a pdf
Stars: ✭ 462 (-32.26%)
Mutual labels:  pdf, pdf-converter
Laravel Pdf
A Simple package for easily generating PDF documents from HTML. This package is specially for laravel but you can use this without laravel.
Stars: ✭ 79 (-88.42%)
Mutual labels:  pdf, pdf-converter
Ptext Release
pText is a library for reading, creating and manipulating PDF files in python.
Stars: ✭ 124 (-81.82%)
Mutual labels:  pdf, pdf-converter
Pdfsave
Convert websites into readable PDFs
Stars: ✭ 46 (-93.26%)
Mutual labels:  pdf, pdf-converter
Pdfcropmargins
pdfCropMargins -- a program to crop the margins of PDF files
Stars: ✭ 141 (-79.33%)
Mutual labels:  pdf, pdf-converter
Docconv
Converts PDF, DOC, DOCX, XML, HTML, RTF, etc to plain text
Stars: ✭ 735 (+7.77%)
Mutual labels:  pdf, pdf-converter
Booktype
Booktype is a free, open source platform that produces beautiful, engaging books formatted for print, Amazon, iBooks and almost any ereader within minutes.
Stars: ✭ 810 (+18.77%)
Mutual labels:  pdf, pdf-converter
Pdf Flipbook
Browse PDF document like a book turning its pages
Stars: ✭ 279 (-59.09%)
Mutual labels:  pdf, pdf-converter
Serverless Libreoffice
Run LibreOffice in AWS Lambda to create PDFs & convert documents
Stars: ✭ 410 (-39.88%)
Mutual labels:  pdf, pdf-converter

DinkToPdf

.NET Core P/Invoke wrapper for wkhtmltopdf library that uses Webkit engine to convert HTML pages to PDF.

Install

Library can be installed through Nuget. Run command bellow from the package manager console:

PM> Install-Package DinkToPdf

Copy native library to root folder of your project. From there .NET Core loads native library when native method is called with P/Invoke. You can find latest version of native library here. Select appropriate library for your OS and platform (64 or 32 bit).

IMPORTANT

Library was NOT tested with IIS. Library was tested in console applications and with Kestrel web server both for Web Application and Web API .

Basic converter

Use this converter in single threaded applications.

Create converter:

var converter = new BasicConverter(new PdfTools());

Synchronized converter

Use this converter in multi threaded applications and web servers. Conversion tasks are saved to blocking collection and executed on a single thread.

var converter = new SynchronizedConverter(new PdfTools());

Define document to convert

var doc = new HtmlToPdfDocument()
{
    GlobalSettings = {
        ColorMode = ColorMode.Color,
        Orientation = Orientation.Landscape,
        PaperSize = PaperKind.A4Plus,
    },
    Objects = {
        new ObjectSettings() {
            PagesCount = true,
            HtmlContent = @"Lorem ipsum dolor sit amet, consectetur adipiscing elit. In consectetur mauris eget ultrices  iaculis. Ut                               odio viverra, molestie lectus nec, venenatis turpis.",
            WebSettings = { DefaultEncoding = "utf-8" },
            HeaderSettings = { FontSize = 9, Right = "Page [page] of [toPage]", Line = true, Spacing = 2.812 }
        }
    }
};

Convert

If Out property is empty string (defined in GlobalSettings) result is saved in byte array.

byte[] pdf = converter.Convert(doc);

If Out property is defined in document then file is saved to disk:

var doc = new HtmlToPdfDocument()
{
    GlobalSettings = {
        ColorMode = ColorMode.Color,
        Orientation = Orientation.Portrait,
        PaperSize = PaperKind.A4,
        Margins = new MarginSettings() { Top = 10 },
        Out = @"C:\DinkToPdf\src\DinkToPdf.TestThreadSafe\test.pdf",
    },
    Objects = {
        new ObjectSettings()
        {
            Page = "http://google.com/",
        },
    }
};
converter.Convert(doc);

Dependency injection

Converter must be registered as singleton.

public void ConfigureServices(IServiceCollection services)
{
    // Add converter to DI
    services.AddSingleton(typeof(IConverter), new SynchronizedConverter(new PdfTools()));
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].