Get a Free Trial

How to scale a PDF or DOCX to the browser width?

By default, PDF’s and DOCX are scaled to 1366 pixels, however this can be changed to any size. When scaling you are essentially trying to fit the browser width to the page size. So if you chose 1366 pixels and a A4 portrait page, which has a size in pixels of just of 700. The actual content would need to be scaled to about half the size to fit in the available page size. Of course if you reduced the browser width or increased the page size or used landscape the scaling would be a lot less or reversed entirely.

Although when scaling a document, the results may not always be perfect and you may want to try a few different sizes before you are happy. Sometimes it is useful to match the have the same browser width as the width of the document, to do this pass -1 to the browser width parameter.

In the below examples PDF's are being created, with the browser width being set to 1500px.

GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");
PDFOptions options = new PDFOptions();
options.BrowserWidth = 1500;
grabzIt.URLToPDF("http://www.spacex.com", options);
grabzIt.Save("http://www.mywebsite.com/Home/Handler");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");
PDFOptions options = new PDFOptions();
options.setBrowserWidth(1500);
grabzIt.URLToPDF("http://www.spacex.com", options);
grabzIt.Save("http://www.mywebsite.com/handler");
<script src="https://cdn.jsdelivr.net/npm/@grabzit/js@3.5.2/grabzit.min.js"></script>
<script>
GrabzIt("Sign in to view your Application Key").ConvertURL("http://www.spacex.com", 
{"format": "pdf", "download": 1, "bwidth": 1500}).Create();
</script>
var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");
var options = {"browserWidth":1500};
client.url_to_pdf("http://www.spacex.com", options);
client.save("http://www.example.com/handler", function (error, id){
    if (error != null){
        throw error;
    }
});
$grabzIt = GrabzItClient->new("Sign in to view your Application Key", "Sign in to view your Application Secret");
$options = GrabzItPDFOptions->new();
$options->browserWidth(1500);
$grabzIt->URLToPDF("http://www.spacex.com", $options);
$grabzIt->Save("http://www.mywebsite.com/handler.pl");
$grabzIt = new \GrabzIt\GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");
$options = new \GrabzIt\GrabzItPDFOptions();
$options->setBrowserWidth(1500);
$grabzIt->URLToPDF("http://www.spacex.com", $options);
$grabzIt->Save("http://www.mywebsite.com/handler.php");
grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")
options = GrabzItPDFOptions.GrabzItPDFOptions()
options.browserWidth = 1500
grabzIt.URLToPDF("http://www.spacex.com", options)
grabzIt.Save("http://www.mywebsite.com/handler.py")
https://api.grabz.it/services/convert?key=Sign in to view your Application Key&format=pdf&bwidth=1500&url=https%3A%2F%2Fspacex.com%2F
grabzIt = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")
options = GrabzIt::PDFOptions.new()
options.browserWidth = 1500
grabzIt.url_to_pdf("http://www.spacex.com", options)
grabzIt.save("http://www.mywebsite.com/handler/index")