# File lib/pdf/writer.rb, line 169
169:     def prepress(options = { })
170:       pdf = self.new(options)
171: 
172:       bleed_size  = options[:bleed_size] || 12
173:       mark_length = options[:mark_length] || 18
174: 
175:       pdf.left_margin   = options[:left_margin] if options[:left_margin]
176:       pdf.right_margin  = options[:right_margin] if options[:right_margin]
177:       pdf.top_margin    = options[:top_margin] if options[:top_margin]
178:       pdf.bottom_margin = options[:bottom_margin] if options[:bottom_margin]
179: 
180:       # This is in an "odd" order because the y-coordinate system in PDF
181:       # is from bottom to top.
182:       tx0 = pdf.pages.media_box[0] + pdf.left_margin
183:       ty0 = pdf.pages.media_box[3] - pdf.top_margin
184:       tx1 = pdf.pages.media_box[2] - pdf.right_margin
185:       ty1 = pdf.pages.media_box[1] + pdf.bottom_margin
186: 
187:       bx0 = tx0 - bleed_size
188:       by0 = ty0 - bleed_size
189:       bx1 = tx1 + bleed_size
190:       by1 = ty1 + bleed_size
191: 
192:       pdf.pages.trim_box  = [ tx0, ty0, tx1, ty1 ]
193:       pdf.pages.bleed_box = [ bx0, by0, bx1, by1 ]
194: 
195:       all = pdf.open_object
196:       pdf.save_state
197:       kk = Color::CMYK.new(0, 0, 0, 100)
198:       pdf.stroke_color! kk
199:       pdf.fill_color! kk
200:       pdf.stroke_style! StrokeStyle.new(0.3)
201: 
202:       pdf.prepress_clip_mark(tx1, ty0,   0, mark_length, bleed_size)  # Upper Right
203:       pdf.prepress_clip_mark(tx0, ty0,  90, mark_length, bleed_size)  # Upper Left
204:       pdf.prepress_clip_mark(tx0, ty1, 180, mark_length, bleed_size)  # Lower Left
205:       pdf.prepress_clip_mark(tx1, ty1, -90, mark_length, bleed_size)  # Lower Right
206: 
207:       mid_x = pdf.pages.media_box[2] / 2.0
208:       mid_y = pdf.pages.media_box[3] / 2.0
209: 
210:       pdf.prepress_center_mark(mid_x, ty0,   0, mark_length, bleed_size) # Centre Top
211:       pdf.prepress_center_mark(tx0, mid_y,  90, mark_length, bleed_size) # Centre Left
212:       pdf.prepress_center_mark(mid_x, ty1, 180, mark_length, bleed_size) # Centre Bottom
213:       pdf.prepress_center_mark(tx1, mid_y, -90, mark_length, bleed_size) # Centre Right
214: 
215:       pdf.restore_state
216:       pdf.close_object
217:       pdf.add_object(all, :all)
218: 
219:       yield pdf if block_given?
220: 
221:       pdf
222:     end