Search code examples
phphtmlcsspdfdompdf

Is it possible to use PDF as HTML page background in CSS?


Is there a way to set a PDF as a background for an HTML file? It needs to be compliant to CSS v2.1. I'm looking to doing something like this in the html page:

body {
     background-image: url(FULLURL/myPDF.pdf);
}

The main purpose behind this is to to basically render an HTML as a PDF, overlaying an already existing PDF. (This I'm doing with PHP and resources like DOMPDF)

The reason it was to be CSS v2.1 compliant, is because the resource is set that way: https://github.com/dompdf/dompdf

https://www.w3.org/TR/CSS2/

Anyone have any ideas? I'm a bit stuck.


Solution

  • Setting it as a background, no, not possible. You may be able to get away with an ugly hack, but... I think you need to rethink what you're trying to accomplish and find an alternative solution.

    PDF is a proprietary format and therefore does not play well with open web languages.