0

I am trying to remove left and right right white spaces of PDF and here is what I have written:

gswin64c.exe -sDEVICE=pdfwrite -sOutputFile=c:\test\test\out\IEq3_8.5011.pdf -dPDFSETTINGS=/prepress -c "<</PageOffset [0 0]>> setpagedevice" -f C:\test\test\out\IEq3_8.5011.pdf

I have successfully done this using bbox but only thing is that bbox strips the white margins from all sides wherein I would like to retain the top and bottom white spaces in result output. Here is something I have written for bbox:

gswin64c.exe -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=c:\test\test\out\%~nx1 -c "[/CropBox [%MyVar%] /PAGES pdfmark" -f %~1

I am new to ghostscript but trying hard to fix some issues in our tools wherein our input is PDF.

Any pointers will be appreciated. Thanks, P

PC245
  • 21
  • 3
  • I don't see a question here, its not at all clear to me what you are asking and, lacking an example, what your problem is. Not only that but the 'successful' command line doesn't actually appear to do anything (the default for PageOffset is 0 0). The bbox device doesn't 'strip margins' at all, it just tells you what the bounding box of the content of the input is. Your CropBox pdfmark won't work because it only appears to have one variable, and you need 4. – KenS Feb 20 '20 at 08:11
  • Let me rephrase my question: I am getting bounding to file with '"gswin64c.exe" -dBATCH -dNOPAUSE -q -sDEVICE=bbox c:\test\test\input.pdf 2> c:\test\CropBox.txt' and using it to crop the output pdf "gswin64c.exe" -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=c:\test\test\out\out.pdf -c "[/CropBox [120 117 128 127] /PAGES pdfmark" -f c:\test\test\in.pdf' . The only problem is that it strips spaces from all sides but I need to remove spaces only on left and right side of content. The 4 variables of bbox is understood but I am finding it difficult to get the values to strip spaces exactly. – PC245 Feb 20 '20 at 09:47
  • Then only use the bounding box x values and leave the y values unchanged. You'll need to retrieve the current CropBox or MediaBox values for that of course because you need to specify all 4 to the CropBox pdfmark. The 4 values you want are **not** the 4 values returned by the bbox device, you only want two of those, if you use all 4 then you will as you note crop top and bottom as well. – KenS Feb 20 '20 at 10:56

0 Answers0