On Mar 4, 2020, at 11:06 AM, Quincey Morris <email@example.com> wrote:
On Mar 4, 2020, at 06:52 , Sandor Szatmari <firstname.lastname@example.org> wrote:
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 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
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.
When I wrote an app that added things to an existing PDF a couple years ago, I was able to use text and custom annotations to display elements on a document in a PDFView, but was unable to figure out how to use PDFKit to save the annotations into the document so that they would be visible with Preview or Acrobat. It appears that PDFKit is primarily oriented around on-screen display and markup of a PDF, not creating or modifying a PDF.
So to save the changes I had to redraw the existing document in a CGPDFContext and then draw the elements as images in that context as well. This turns each PDF page into an image, which wasn’t a problem in my case, but is usually not desirable.