Bug 691145

Summary: Trimbox not being cropped properly
Product: Ghostscript Reporter: Raine Ekman <raine.ekman>
Component: PDF InterpreterAssignee: Alex Cherepanov <alex>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P4    
Version: 8.71   
Hardware: PC   
OS: Linux   
Customer: Word Size: ---
Attachments: Sample file: big-crop-trim-box.pdf
patch

Description Raine Ekman 2010-02-26 05:33:52 UTC
$ grep -a Box problem.pdf |grep -v FontBBox
/TrimBox [28.3297 29.0042 624.602 870.126]
/MediaBox [0.0 0.0 841.89 595.276]
/CropBox [0.0 0.0 841.89 595.276]
/BleedBox [28.3297 29.0042 624.602 870.126]

$ gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=jpeg -r150 -dTextAlphaBits=4 
-dGraphicsAlphaBits=4 -dMaxStripSize=8192 -sOutputFile=problem.jpg problem.pdf 
GPL Ghostscript 8.71 (2010-02-10)
Copyright (C) 2010 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 1.
Page 1

$ identify problem.jpg 
problem.jpg JPEG 1754x1240 1754x1240+0+0 8-bit DirectClass 224KB 0.000u 0:00.000


$ gs -dUseTrimBox -dSAFER -dBATCH -dNOPAUSE -sDEVICE=jpeg -r150 -
dTextAlphaBits=4 -dGraphicsAlphaBits=4 -dMaxStripSize=8192 -
sOutputFile=problem.jpg problem.pdf 

$ identify problem.jpg 
problem.jpg JPEG 1242x1752 1242x1752+0+0 8-bit DirectClass 135KB 0.000u 0:00.000


This seems to be the entire TrimBox with quite a bit of empty space from 
outside the MediaBox.

Shouldn't the second result really be an intersection of the MediaBox and the 
TrimBox, as the PDF reference, version 1.7, section 10.10 states:
"The crop, bleed, trim, and art boxes should not ordinarily extend beyond the 
boundaries of the media box. If they do, they are effectively reduced to their 
intersection with the media box."
Comment 1 Alex Cherepanov 2010-02-27 17:16:52 UTC
Created attachment 5996 [details]
Sample file: big-crop-trim-box.pdf
Comment 2 Alex Cherepanov 2010-02-27 17:18:40 UTC
Created attachment 5997 [details]
patch

Following PDF reference, version 1.7, section 10.10, crop /TrimBox and /CropBox

by the /MediaBox.
Comment 3 Alex Cherepanov 2010-02-27 17:20:44 UTC
The patch has been committed as a rev. 10824.
Regression testing shows no differences.
Comment 4 Alex Cherepanov 2010-02-27 17:22:15 UTC
Comment on attachment 5996 [details]
Sample file: big-crop-trim-box.pdf

A simple sample file with MediaBox and TrimBox extending beyond MediaBox