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

15,019

Solution 1

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.

Solution 2

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

Share:
15,019
LatentDenis
Author by

LatentDenis

Learning new stuff everyday. Developer by day, music producer by night. Mostly dealing with Angular, C#, .NET, PHP, WordPress, CSS, and JavaScript.

Updated on July 02, 2022

Comments

  • LatentDenis
    LatentDenis almost 2 years

    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
    LatentDenis about 8 years
    If this is unlikely to work, do you think you could aid me with my original question? stackoverflow.com/questions/36752092/…
  • mister martin
    mister martin about 8 years
    @NoReceipt4Panda the answer to your original question is that it's not possible.
  • LatentDenis
    LatentDenis about 8 years
    Are you talking about the link I just posted as a response? or did you think I meant this question?
  • mister martin
    mister martin about 8 years
    @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.
  • LatentDenis
    LatentDenis about 8 years
    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
    LatentDenis about 8 years
    Also, I understand I can't set a PDF as a background. it's a different question.