Cara Kompress File PDF Menggunakan Ghostscript

cara compress PDF
download Ghostsctipt dari

https://github.com/ArtifexSoftware/ghostpdl-downloads/releases

klo windows 64 bit pilih https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs10012/gs10012w64.exe

install di C:\gs bikin folder sendiri saat proses install Jangan di Program Files
PATH = C:\gs\bin di Windows Environment Variables

kalo compress pake CMD Windows harus Running as administrator contohnya

File yg mau dikompres C:\wamp64\www\html\PDF_ASAL.pdf
Hasil Kompress C:\wamp64\www\html\Hasil.pdf

C:\Windows\system32>gswin64.exe -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook -dNOSAFER -dNOPAUSE -dQUIET -dBATCH -sOUTPUTFILE=C:\wamp64\www\html\Hasil.pdf C:\wamp64\www\html\PDF_ASAL.pdf

Ada 3 Pilihan Kompress

  1. -dPDFSETTINGS=/ebook
  2. -dPDFSETTINGS=/screen
  3. -dPDFSETTINGS=/printer
    Hasil Compress yang terkecil kalo pake screen

Kalo Mau Kompress menggunakan PHP

<?php

error_reporting(E_ALL);
ini_set(‘display_errors’, 1);

$inputFile = ‘C:\wamp64\www\html\PDF_ASAL.pdf’;
$outputFile = ‘C:\wamp64\www\html\test.pdf’;
// gswin64.exe -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook -dNOSAFER -dNOPAUSE -dQUIET -dBATCH -sOUTPUTFILE=C:\wamp64\www\html\Hasil_Kompress.pdf C:\wamp64\www\html\PDF_ASAL.pdf
shell_exec(“C:\gs\bin\gswin64.exe -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -sOUTPUTFILE=C:\wamp64\www\html\ebook.pdf ” . $inputFile);
shell_exec(“C:\gs\bin\gswin64.exe -sDEVICE=pdfwrite -dPDFSETTINGS=/screen -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -sOUTPUTFILE=C:\wamp64\www\html\screen.pdf ” . $inputFile);
shell_exec(“C:\gs\bin\gswin64.exe -sDEVICE=pdfwrite -dPDFSETTINGS=/printer -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -sOUTPUTFILE=C:\wamp64\www\html\printer.pdf ” . $inputFile);
//exec( “C:\gs\bin\gswin64.exe -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -sOUTPUTFILE= $outputFile $inputFile”);