Re: Drawing to a PDF context

Sandor Szatmari


On Mar 4, 2020, at 11:07 AM, Quincey Morris <quinceymorris@...> wrote:

On Mar 4, 2020, at 06:52 , Sandor Szatmari <> wrote:

I need to replace calls to CGShowTextAtPoint() with calls to -drawAtPoint:withAttributes:

I made this change and drawing fails… :/ 
i.e. no text rendered, no exception, logging of errors, etc. simply no text

Well, by default, NWView coordinates are flipped vs. CGContext coordinates. I suggest you try temporarily forcing the point you’re drawing at to be the center of the context or view, and see if the text even appears. If so, you should be able to see what you need to do to transform the point at which you’re drawing (based on which direction the text is running, and whether it’s upside down).

I tried a couple tweaks of the drawing coordinates but I should investigate more.  

Also interesting. If I call [NSGraphics currentContext] before trying to set the context it returns nil.

Are you switching over to PDFKit? In that case, you’ll have to respect whatever coordinate system it uses.

Not switching to PDFKit.  Just updating deployment target SDK and dealing with deprecations.

Thank you!

It looks like there’s some advice on that subject in the “Override the Draw Method and Add Your Custom Graphic” section of

Join to automatically receive all group messages.