Laravel-snappy: Size change when changing OS

Created on 26 Jul 2017  路  5Comments  路  Source: barryvdh/laravel-snappy

I developed my app in macOS Sierra, but when I moved to production, in Ubuntu 16.04, the size of generated items becomes bigger.
How can i solve this? Some screenshots (biggest is the good one):

macOS Sierra:
macos

Ubuntu 16.04:
ubuntu

Most helpful comment

Thanks for the answers!
I have fixed it this way for now:

 $zoom_factor = (App::environment('production')) ? '1.23' : '1.00';
 $pdf = PDF::loadView('pdf.example')->setOption('zoom', $zoom_factor)

All 5 comments

I get same issue, then not yet resolved

Same issue here, anybody has a fix/workaround or something in that direction?

While, I was use setOption zoom
PDF::loadHTML($html)->setOption('zoom','1.2822');
The zoom value not sure, but I was adjust it manually. The result between local development (Mac El Capitan) and server (Ubuntu 16.04) is approximately the same.

I done this:

switch(PHP_OS)
{
    case 'Linux':
        $zoom = '1';
        break;   
    default:
        $zoom = '0.8'; 
}

First, i get the PHP_OS predefined constant, and switch it, and depending on value, i assign a 'zoom level' to $zoom Then, I do:

return PDF::loadHTML($html)->setOption('zoom', $zoom)->inline();

My server's OS is Ubuntu 16.04, and my computer is macOs High Sierra, and the values where 1 for production sever in Ubuntu, and 0.8 for dev computer in macOS. I don't know what value are the correct for Windows, but you can try values.

NOTE: Posible values for PHP_OS are:

  • CYGWIN_NT-5.1
  • Darwin
  • FreeBSD
  • HP-UX
  • IRIX64
  • Linux
  • NetBSD
  • OpenBSD
  • SunOS
  • Unix
  • WIN32
  • WINNT
  • Windows

Thanks for the answers!
I have fixed it this way for now:

 $zoom_factor = (App::environment('production')) ? '1.23' : '1.00';
 $pdf = PDF::loadView('pdf.example')->setOption('zoom', $zoom_factor)
Was this page helpful?
0 / 5 - 0 ratings

Related issues

zhuojiawei picture zhuojiawei  路  5Comments

MaximeDawn picture MaximeDawn  路  3Comments

LucasPantoja picture LucasPantoja  路  8Comments

hilmanfaiz picture hilmanfaiz  路  5Comments

larsemil picture larsemil  路  5Comments