4

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.

LatentDenis
  • 2,839
  • 12
  • 48
  • 99

3 Answers3

5

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.

Community
  • 1
  • 1
mister martin
  • 6,197
  • 4
  • 30
  • 63
  • If this is unlikely to work, do you think you could aid me with my original question? http://stackoverflow.com/questions/36752092/how-to-overlay-write-on-top-of-existing-pdf-with-html-generated-pdf – LatentDenis Apr 20 '16 at 19:48
  • 1
    @NoReceipt4Panda the answer to your original question is that it's not possible. – mister martin Apr 20 '16 at 19:55
  • Are you talking about the link I just posted as a response? or did you think I meant this question? – LatentDenis Apr 20 '16 at 19:56
  • @NoReceipt4Panda both, it is not possible to set PDF as a background in CSS, nor is it possible to overlay HTML on top of it. – mister martin Apr 20 '16 at 19:58
  • My original question is more along the lines of "can I overlay a pdf on top of a pdf" one of which is an HTML rendered pdf. – LatentDenis Apr 20 '16 at 20:02
  • Also, I understand I can't set a PDF as a background. it's a different question. – LatentDenis Apr 20 '16 at 20:05
2

Background not an option as far as I know. But refer embed pdf to view a pdf on a page.

Community
  • 1
  • 1
Ani Menon
  • 27,209
  • 16
  • 105
  • 126
0

Referring to the original question: it is possible and it's actually pretty annoying! It leaves a whole white block on the webpage before the actual content; it can be viewed by right clicking View Background Image...

It looks like (incorrect URL):

leo
  • 1