Starting from Sierra the's a pdf drawWithBox:toContext:
operation available. But in former OS versions this is not present. When there's a graphic context the predecessor drawWithBox:
worked nicely where ever a context is present (e.g. in drawRect:
). But if you don't have such a context, I don't see a way to use drawWithBox:
(except for taking a random context which "might" be present). I tried this:
_contextRef =
CGBitmapContextCreate(_cvMat.data, ...
...
if (v12) {
[page drawWithBox:kPDFDisplayBoxBleedBox toContext:cgContext];
} else {
[NSGraphicsContext setCurrentContext:(__bridge NSGraphicsContext * _Nullable)(cgContext)];
[page drawWithBox:kPDFDisplayBoxBleedBox];
}
but that just dumped
-[__NSCFType graphicsPort]: unrecognized selector sent to instance 0x7f8de1e219a0
which is not an error message encountered (or sought after) very often.