Open typemytype opened 5 years ago
proposal:
bleedRect(-10, -10, 10, 10)
relative to the page size
or newPage((600, 600), bleed=(-10, -10, 10, 10))
as an extra argument when creating a new page.
🥳
Roberto Arista
ಠ_à²
Sent from my mobile: +39 366 45 37 413
On 13 Aug 2019, at 19:02, Frederik Berlaen notifications@github.com wrote:
proposal:
bleedRect(-10, -10, 10, 10) relative to the page size
or newPage((600, 600), bleed=(-10, -10, 10, 10)) as an extra argument when creating a new page.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
I suppose all bleed arguments can be positive, as you'd never want a negative bleed, no?
I'd be +1 for:
newPage((600, 600), bleed=(10, 10, 10, 10))
Perhaps also accepting:
newPage((600, 600), bleed=10)
I like this as an optional argument, and I like @justvanrossum's tweak to this proposal. I think of bleed as something that happens at each edge, rather than a big background rectangle.
Also, are different bleed values for different edges even needed?
Also 2, want to work on a PR?
are different bleed values for different edges even needed?
My guess is yes. In the circumstance of preparing a file with facing pages (e.g. a book), I think the edge of a page that is in the gutter probably shouldn't get a bleed.
want to work on a PR?
Possibly ... but I wouldn't really know where to start, so I'm not sure I'd be very efficient and may require some hand-holding. Is the newPage
function here, or somewhere else?
https://github.com/typemytype/drawbot/blob/33cb3d60afd30b33713e1d655dba8bfe09337d16/drawBot/drawBotDrawingTools.py#L263
If so, how does that connect to whatever actually creates the page (probably something in Core Graphics)?
test script for reference, but cannot figure out what the correct values are
how to test if those values are set correctly?
import Quartz
import AppKit
import os
width, height = 500, 100
bleed = (10, 10, 10, 10)
mediaBox = Quartz.CGRectMake(0, 0, width, height)
bleedBox = Quartz.CGRectMake(-bleed[0], -bleed[1], bleed[2], bleed[3])
print(bleedBox)
auxiliaryInfo = dict()
auxiliaryInfo[Quartz.kCGPDFContextMediaBox] = mediaBox
auxiliaryInfo[Quartz.kCGPDFContextBleedBox] = bleedBox
# auxiliaryInfo[Quartz.kCGPDFContextCropBox]
# auxiliaryInfo[Quartz.kCGPDFContextTrimBox]
# auxiliaryInfo[Quartz.kCGPDFContextArtBox]
pdfData = Quartz.CFDataCreateMutable(None, 0)
dataConsumer = Quartz.CGDataConsumerCreateWithCFData(pdfData)
pdfContext = Quartz.CGPDFContextCreate(dataConsumer, mediaBox, None)
Quartz.CGPDFContextBeginPage(pdfContext, auxiliaryInfo)
Quartz.CGPDFContextEndPage(pdfContext)
Quartz.CGPDFContextClose(pdfContext)
path = os.path.expanduser('~/test--.pdf')
pdfData.writeToFile_atomically_(path, True)
We can see it, for example, in Acrobat: In 'Output Preview,' you need to select 'Show art, trim, & bleed boxes.' If they are present, they will be displayed.
Also, in CLI, we can use mutool with mutool pages test.pdf
. This will print something like
<page pagenum="1">
<BleedBox l="14.1732" b="14.1732" r="485.827" t="85.8268" />
</page>
if they are there, and
<page pagenum="1">
</page>
if they are not.
Well, for some reason, the script above did not successfully set the bleed in my case. Just wanted to mention it because I think having this feature is really great and super helpful for production purposes.
https://developer.apple.com/documentation/coregraphics/kcgpdfcontextbleedbox?language=objc
requested here https://forum.drawbot.com/topic/183/is-there-a-way-to-build-bleed-into-a-file-for-printing