How to Size A PDF in a Browser

July 30, 2019

If you followed my article, loading a PDF in your browser, you may also be wondering how to size the PDF to fit in the <embed> tag.

The problem is that your PDF may not always fit beautifully in the browser window when it loads. Maybe it's really small or it's too large. This article is how to fix that.

There are specific types of query parameters for interacting with a PDF in the browser. You use these to help format the PDF. They look like this:


Instead of the query parameters starting with a "?", it will start with a "#." The # and everything after is called a fragment. Fragments don't get sent to the server during an HTTP request.

The keys and values in the fragment will tell the browser how to size the PDF. See this document for a list of possible keys and values to use.

I wanted the PDF page to fit on the page and using this fragment, #view=FitV, solved my problem.

No go ahead and try a few of these PDF query parameter fragments on your own PDF.

This is the original stack overflow question that lead me in the right direction.