Code Monkey home page Code Monkey logo

netcorepdfreports's Introduction

Net Core Pdf Reports

Demonstrates how to use PhantomJS to convert an HTML file to a PDF file in .NET Core, Windows or Linux, without expensive 3rd party libraries. This example was created on Windows. You will need to install the Linux version of the exe on your target machine for this to work in a Linux environment.

This is a simple example using a static HTML file. For a real life application, you would generate the HTML dynamically that would be used as the input to the PhantomJS.exe command line instruction. The command line takes three parameters:

var command = $"{rasterizeFile } { outputFile} {targetFile}";

The rasterize file is the JavaScript instruction for formatting the page output of the PDF. You can find more details about this file here: https://phantomjs.org/api/

PhantomJS is a “headless” browser, that can render a web page like any other browser, from the command line. It can convert HTML files to images or pdf files. If you can render it in HTML, you can output it as a PDF report...for free. And since it is a command line utility, you can call it from any language that can shell execute.

The PhantomJS browser, like all browsers, may not render exactly the same. In my testing, I have found no issues that I could not work around. It rendered about 97% the same as Chrome.

netcorepdfreports's People

Contributors

kmgayda avatar

Watchers

 avatar

Forkers

donizeti23

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.