1

I have a very simple use case. I want to create a pdf from a html file that I have.

Problem:

I have checked this tool. But it does not work for css3. And gives errors while parsing bootstrap files. xhtml2pdf

I am currently checking Prince (giving some issues when I am running it.)

Has anyone faced such an issue and have you been able to solve it ?

2
  • 1
    Depending on your budget: look into Phantomjs+rasterize.js or PrinceXML or PDFRreactor. Also reportlab may help you...FAQ Commented Oct 4, 2013 at 7:12
  • 1
    wkhtmltopdf is also useful, but in my experience Prince is superior, though pricey. Commented Oct 4, 2013 at 7:20

1 Answer 1

2

There is surprisingly very little options available when you are not prepared to pay for a commercial library. I had the same requirement from one of my clients that did not want to pay for any third party tools, so I had to make a plan. This is what I did, not the best solution, but it got the job done

  1. I downloaded the newest version of wkhtmltopdf. Unfortunately the wkhtmltopdf tool did not display some of my google graphs embedded in my HTML when converting to PDF. So I used the wkhtmltoimage tool also included to convert to a PNG, which woked as expected and displayed all the graphs.
  2. I then downloaded the newest version of imagemagick and converted the PNG to PDF.

I automated this process using C#. You should be able to do this using python as well (Please note that I have no knowledge of python, and could be wrong).

Unfortunately this is not the most elegant solution because you have to perform two conversions and do a bit of work to automate everyting, but this is the best solution I could come up with that gave me the desired results and quality.

Of course there are losts of commercial software out there that will do a faster and better job.

Just a side note:

The web page that I had to convert was devloped in HTML5 and CSS3 using version 3 of bootstrap and it contained some google graphs and charts. Everything was converted without any problems.

Sign up to request clarification or add additional context in comments.

1 Comment

Sorry, I meant ImageMagick, not GhostScript. Updated the post. @AkashDeshpande

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.