GhostScript PDF Compression Issue RRS feed

  • Question

  • User-1284851152 posted

    Dear All,

    I am trying to compress the PDF file using my Asp.Net application with GhostScript.  But somehow i couldn't get the successful ouput for some PDF.

    GhostScript Application Details

    Version : 9.19 

    name : gswin64c.exe

    Please have a look at the below mentioned issue.

    My issue is, for some PDF, ghost compression technique is not working fine rather it increases the File size.

    For eg. please have a look at this link  (Here i have added some of input and output files, which i had tested with application)

    Case 1: PDF compression not worked as desired.

     Here B_BeforeCompression.pdf (its size is 369 KB) is the source PDF, when i compress it using the GhostPDF Compression technique it actually increases its size B_AfterCompression.pdf (its size is 473 KB)

    Case 2: PDF Compression worked fine

    Here A_BeforeCompression.pdf (its size is 1458 KB) when it  is compressed, the output PDF is generated as A_AfterCompression.pdf size is 286 KB.

    Here my question is, Why this contrary occurs (a technique works with one PDF but not successfully do with the another PDF.)

     var compressCmd = "-sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=" + filepathfull;
                string ghostScriptExePath = WebConfigurationManager.AppSettings["GhostScriptExePath"];
                var startInfo = new ProcessStartInfo(ghostScriptExePath, compressCmd);
                var p = new Process { StartInfo = startInfo };
                p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                p.StartInfo.UseShellExecute = false;
                p.StartInfo.RedirectStandardOutput = false;
                if (p.ExitCode != 0)

    Please give me the possible solution that would make the PDF Compression is compatible for the all the PDF files.

    Thanks & Regards,



    Tuesday, July 19, 2016 3:10 PM

All replies

  • User-1284851152 posted

    Can anyone please give some idea on this issue?

    Wednesday, July 20, 2016 10:39 AM