When opening pdf's in Chrome and Firefox, the "view source" button is greyed out. "Inspect elemet," however, reveals HTML. Are the browsers simply downloading the file and generating html to display it?
1 Answer
Firefox has used PDF.js as the default PDF viewer since Firefox 19. When you view a PDF in Firefox (provided you haven't changed your browser's PDF settings), you are viewing an HTML rendering of the document. You can't "view source" because there was no HTML source downloaded, but you can "inspect element" because the document you're viewing in-browser is written in HTML, based on the original PDF.
In Chrome (at least v29, in Windows), the browser relies on a native PDF plugin. There is HTML generated, but it looks like:
<html>
<body><embed ...></body>
</html>
where the <embed>
element holds the PDF and is rendered by a plugin. This is the same way that images are rendered standalone in Chrome. You wouldn't "view source" on an image, but Chrome allows you to inspect the minimal framing HTML that surrounds the content.