9

A flash file can be embedded in a PDF document. Does anyone know if it is also possible to embed an HTML webpage?

Added:

  • I don't mean just a plain HTML document, but a webpage with Javascript too.

5 Answers 5

10

The answer is no. While you can embed videos, sounds and SWF files in a PDF, dynamic HTML files aren't supported. (Adobe AIR is more suitable to package and distribute HTML files).

The best you can do in a PDF is to use the ATTACH option in Adobe Acrobat. This will "attach" any file with the PDF document similar to how you add an attachment with an email. But the attachment can't be viewed within the PDF document, and has to be opened separately.


More info:
Javascript can be added to PDF files and used to manipulate various elements within the PDF file.

2
  • Actually you can view basic html pages in Flash out of the box and embed the swf that does that in a pdf. There are significant limitations to what kind of HTML gets rendered though. Someone crazy enough could create his/her own better HTML renderer in Flash stackoverflow.com/questions/1079950/embedding-webpage-in-flash Jan 13, 2020 at 1:38
  • Adobe now claims: "Beginning with Acrobat 7, there have been extensive improvements to the JavaScript functionality. There is now support for multimedia, improved printing control, controlling layers, 3D support, and more." So theoretically we should be able to do a lot just with Javascript without needing HTML at all.
    – Sam
    Mar 2, 2020 at 22:55
4

Not directly. Depending on what you're looking for, however, you can use something like dompdf (PHP) to generate a PDF file from an HTML document, then merge that document with your original. It even supports JavaScript, up to the level Adobe Reader supports JavaScript.

That said, the PDF file format is really for things you want to print (i.e. want to look the same everywhere), not things you want to click on (i.e. look sensible everywhere). Adobe's decision to include Flash support was probably made from a marketing standpoint, not a technical one.

2
  • Yes, PDF file format is best for printing. But the decision to include flash in PDF is actually a very good idea. E.g. Create some presentation in flash. Embed it in PDF. Distribute it. Great for marketing, elearning and so on ...
    – Sam
    May 13, 2012 at 12:20
  • Do you know any file type that is responsive like HTML, but can be conveniently shared privately like PDF?
    – Ooker
    Dec 8, 2017 at 2:18
2

The best workaround would be to create a web/html viewer in Adobe Flash and embed that in a PDF as an SWF. There is an option to "Add SWF" in Acrobat under "Rich Media."

1

Created a NPM module that allows you to add custom HTML and CSS to PDF's.

const pdf = require('add-html-to-pdf');

var options = {
input: 'sample.pdf',
output: 'done.pdf',
html: "<div style='color:red'>This is awesome!</div>",
useDocker: true
}

pdf.insertHTMLInPDF(options);
1
  • The question is about an HTML page somewhere on the Internet not HTML code Jan 13, 2020 at 1:22
0

You could reconstruct the html, css and js on the web page using php.

Im using a plugin with a wordpress site that is pretty outdated but works very well for creating pdfs with html, css and javascript.

it's called tcpdf

plugins/tcpdf/tcpdf.php

https://tcpdf.org/examples/

the pdf is made on the fly as a function.

1
  • 1
    this does not appear to be an Answer to the Question that was asked. how does it apply to the subject of the Question?
    – Lee_Dailey
    May 27, 2020 at 23:35

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.