Coder Social home page Coder Social logo

adamhockemeyer / wkhtmltopdf-docker-azure-app-service Goto Github PK

View Code? Open in Web Editor NEW
8.0 4.0 6.0 674 KB

A sample .Net Core web app that is containerized with Docker and can be deployed to Azure App Service to generate PDF documents from HTML.

C# 70.15% Dockerfile 14.39% HTML 15.46%
wkhtmltopdf dinktopdf netcore21 pdf-generation azure-app-service docker container-linux

wkhtmltopdf-docker-azure-app-service's Introduction

Using wkhtmltopdf (dinktopdf) with Docker and Azure App Service

This repo demonstrates how to use DinkToPdf which is a Nuget package that acts as a wrapper around the very popular wkhtmltopdf library to provide HTML to PDF generation capabilities.

Issue

Many PDF generation solutions leverage User32/GDI32 and these are largely blocked in the Azure Web App sandbox. (https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#pdf-generation-from-html).

Solution

This example runs wkhtmltopdf as a Docker container which allows us to add the (Linux) system dependencies that are required to generate PDFs.

You could potentually deploy this solution and use it as a sort of "microservice" for generating PDF's based on HTML content.

Disclaimer: This is a simple demo and may need to be modified by you for your specific use case (i.e. Custom Fonts, Authentication, etc).

Technologies Utilized:

Example passing a url and having a PDF generated from it: alt text

Try it out in 2 minutes!

You can try out this example quickly by using a Docker image that is built based on this repo and is published to Docker Hub.

  1. Login to the Azure Portal
  2. Create a new resource and select 'Web App'.
  3. Fill in your app name, resource group, select 'Docker' for the OS, and pick your App Service Plan Size.
  4. Finally under 'Configure Container' select 'Docker Hub' as the image source, keep the Repository Access on 'Public' and then enter 'hock2k5/wkhtmltopdf-netcore:latest' into the box titled 'Image and optional tag (eg 'image:tag').
  5. Click 'OK', and then click 'Create' and you are done!
  6. Once you web app (app service) is created, you will need to visit the url based on the app name you selected to start the process of the docker image being pulled down into your web app. This can take a few minutes. You can check on the status by going into your web app, and under the 'Settings' blade on the left side, click on 'Container settings' and from their you can view the logs. If nothing shows up under logs you may need to go to the 'Diagnostic logs' section under monitoring and enable logs.

alt text

wkhtmltopdf-docker-azure-app-service's People

Contributors

adamhockemeyer avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.