How to embed PDF in a web page without javascript [duplicate] - html

This question already has answers here:
Recommended way to embed PDF in HTML?
(30 answers)
Closed 9 years ago.
I want to show pdfs in certain pages on my site. I've experimented with google's viewer api and it works great but I dont want to depend on a third party api call. I also want it to be as robust and reliable as possible, so I'm trying to avoid javascript. I see some indication that it can be done with just HTML using either or tags, but there appears to be disagreement as to the browser support: Recommended way to embed PDF in HTML?
Is there a definitive way to do this?
I need to support IE8+ and the site will be responsive, so the solution has to be able to accommodate smaller screen sizes.
Attention duplicate police: The entire basis for this question is to figure out what is specifically NOT answered in the other question. I even linked to that question in my ow

If you don't want to use JavaScript -- no, there is not.
Even if there is a good enough solution for some OS with something like Acrobat Reader installed (maybe you get lucky with Windows), all the other OSes still don't support it.
So, if you want your site to be seen more or less the same way by everybody, you'll have to go with Javascript base things and their not so robust and reliable support -- they are pretty portable, that's a great thing on the web.
Related:
Open Source Javascript PDF viewer
Why Use a Javascript PDF Viewer

Related

Is #page:last really something?

I am currently working with pdf generation, and it looks like #page:last is what I need. Unfortunately, it doesn't work, and I can't find it in any doc I have found (eg. https://www.w3.org/TR/css3-page/)
But, and here is the question, I found several answers in SO talking about that mystery #page:last (eg. https://stackoverflow.com/a/27448329/4525068 https://stackoverflow.com/a/1176839/4525068)
So, what about it? Is that been removed? Has it already existed? If not, why those answers are accepted? Any workaround?
Yes and no. Paged media is only supported by certain PDF generation tools, such as PrinceXML. It is not supported by any web browsers. So you can use it to make documents, and it's really handy, but not for making web sites.

How to let robots parse our custom html elements? [duplicate]

This question already has answers here:
How do search engines deal with AngularJS applications?
(15 answers)
Closed 6 years ago.
I have a website containing custom elements (i use angular 2), and google fails to parse them correctly :
It only sees
<my-app></my-app>
It seems that the value of this component is not retrieved at all by google robots.
Is there a best practice / workaround ?
Thanks for your help.
This has been asked a million times. Please refer to this question and this specific page by google.
Times have changed. Today, as long as you're not blocking Googlebot from crawling your JavaScript or CSS files, we are generally able to render and understand your web pages like modern browsers. To reflect this improvement, we recently updated our technical Webmaster Guidelines to recommend against disallowing Googlebot from crawling your site's CSS or JS files.
What you can do is getting the HTML of your rendered page and inserting it into the <my-app></my-app> tags without user information or the like.
This will get replaced anyway after Angular has booted up, this means you can even put something completely different in there.

How to detect an Operating System [duplicate]

This question already has answers here:
Cross Browser Flash Detection in Javascript
(16 answers)
Closed 9 years ago.
I am in the process of trying to rewrite my website, and I have limited experience in HTML/CSS/Javascript. It is a photography website using galleries. I am wanting to make the default view to be using Flash, but I know that iPad/iPhone etc do not support Flash. I am looking for a way to determine what the OS is so I can direct the iWhatevers (and others if there are any), to a purely HTML site, and the non-iWhatevers to the Flash site.
I presume it would be done in the Heading part of the HTML, but what script would I use to do this?
Thank you in advance...
That sounds like a lot of extra work to create to maintain a Flash and a regular HTML site when a properly done HTML5 site can kill all the browsers with one stone. Consider a CMS like WordPress if you are not comfortable with a lot of coding.
However, if you want to go the route you mentioned, this thread will show you how: Detect if device is iOS

How to prevent users from downloading Presentation ( PPT ) and videos from my HTML page [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to prevent downloading images and video files from my website?
I have an HTML page which resides locally on my machine. I have 2 items on every page 1 - PPT presentation 2 - Video tutorial . I want to prevent users from downloading the content for their personal use. How can this be achieved?
Thanks in Advance !
Maddy
Unfortunately the short answer is that it cannot not be done in a good way, if the content should be available at your website at the same time.
There are solutions where you obfuscate the path to the file when it is sent to the browser, and then use a JavaScript to "decrypt" the path at the client. But those solutions are in no way bullet proof, as the decryption technique would have to be sent to the client as well.
This one is not easy to do, especially if you show them on your page already. As you do so they'll get downloaded on the browser an there's no way, at least i'm aware of you could do this with ease!
All you can do is to make it harder... but it still always be possibile! Even if you could stop them from downloading the file, you can't stop them from hooking a VCR to their video card and re-recording it. Even if you use some protected-path technology to stop that, you can't stop them from pointing a camcorder at the screen.
Same applies to the ppt presentations... as they can view them... users could take screenshots or do whatever to create their own copy!

Dynamic HTML to PDF [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 1 year ago.
Improve this question
I need to be able to convert dynamic HTML (html that is rendered on page load by javascript) to a PDF. I know there are plenty of HTML to PDF converters but none of the ones I have found thus far cope with dynamic HTML.
The given tool should be able to successfully convert the following page - http://www.simile-widgets.org/timeline/
Cheers
Anthony
UPDATE:
I don't need the JavaScript functionality here... i.e. i don't need to be able to interact screen... I just want the finial rendering of the screen to be captured in the PDF - like taking a photo after the page is loaded. And in the example I provided the javascript is only rendering divs to the screen so its nothing that it shouldn't be able to handle as long as it "lets" the "page" render first.
There is no way it can be done. The interfaces available for scripts in PDF are extremely limited compared to the full DOM and BOM access you enjoy in a web browser. Such interaction as you can achieve in PDF is not readily translatable from how it works in a browser and would almost certainly need hand authoring.
Your example page has many effects that PDF, as an essentially static document layout format, simply cannot reproduce at all.
Edit:
I just want the finial rendering of the screen to be captured in the PDF
Ah, OK, that's a far easier and more common problem then.
In that case you'll have to use and automate a real web browser (like Firefox), or a toolkit that provides all the logic of a web browser (like WebKit), then either:
export to PDF, either using built-in tools like ‘Print to file’ in Firefox (with background images/colours turned on) or one of the PDF export add-ons, or
take a image snapsnot of the browser (and include the image in a PDF if you have to)
See these questions for some discussion of browser snapshotting.
The fact that it uses any JavaScript at all means a lot of converters won't work. The JavaScript may be simple, but you still need an interpreter to handle it.
I haven't used it for myself, but you might try wkhtmltopdf. It uses the webkit rendering engine, and I believe it includes full javascript support. You would need to be able to install the software and run the executable, but otherwise it should be fairly straightforward.
You could use a javascript URI to alert the current DOM. eg:
javascript:alert("<html>" + document.documentElement.innerHTML + "</html>")
Copy the HTML and save to a file.
Then run it through the HTML2PDF converter.
dynamic-html-pdf
This is best library for node js convert dynamic html to pdf.
https://www.npmjs.com/package/dynamic-html-pdf
You can probably use PhantomJS or headless chrome.
Try xhtml2pdf. Here's the project page at python.org.