Re: Drawing to a PDF context


Quincey Morris
 

On Mar 4, 2020, at 06:52 , Sandor Szatmari <admin.szatmari.net@...> 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).

Are you switching over to PDFKit? In that case, you’ll have to respect whatever coordinate system it uses. It looks like there’s some advice on that subject in the “Override the Draw Method and Add Your Custom Graphic” section of https://developer.apple.com/documentation/pdfkit/adding_custom_graphics_to_a_pdf.

Join {cocoa@apple-dev.groups.io to automatically receive all group messages.