简体   繁体   中英

How to render HTML and graphics on top of existing PDF using wkhtmltopdf

I have these inputs:

  • an HTML page
  • an Existing PDF, and some more HTML/stuff I want to draw on top of that PDF (text, html, circles)
  • an HTML Page

I want to render a 3-page PDF, and have them all be displayed on in a single PDF.

In other words, my question is How do I use an existing PDF as a template for more input

Can this be done from PHP and how?

不幸的是,使用wkhtmltopdf,您无法修改/编辑现有的PDF。

With a custom XSL using this code, you could easily do it.

http://www.cloudformatter.com/CSS2Pdf.APIDoc.Usage

The backend rendering engine is XSL FO based which supports injecting a PDF as a background image.

So easy, I did you a sample. Go to this page:

http://www.cloudformatter.com/CSS2Pdf.CustomTipsTricks.BackgroundImages

Click the Open-> PDF button. The "Top Secret" PDF is injected as a background, the HTML overlayed on top. You can use this solution to combine your HTML, PDF and HTML+PDF in any way you wish.

In fact, with HTML, this Javascript and a little customization you could have a document that was:

start document

format HTML div
format HTML div with this PDF background
format another HTML div
inject this entire PDF
format another HTML div with a different PDF background
inject a different entire PDF
...

end document

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM