Setting Drawing (PKDrawing) programmatically from outside


Hello, I have the PKDrawing model for each page and I want to show on the pdf without using extra layer except yours. it is like a migration from my old canvasview to yours. and I can reach the CanvasView inside PTPencilDrawingCreate tool but setting the drawing is problematic when size does not get match.
I wonder are there any other hints or solutions you could give me please ?


Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:


Hi there,
Thanks for getting in touch with us.
How are you creating your own PKDrawing models? Is it possible to instead use the PTPencilDrawingCreate tool directly?
If you are able to provide an example/sample project that demonstrates your setup and your intended use case then we will be better able to look into this on our end. Thanks!

Hi, Unfortunately I cant provide an example but basically,
The app I work for use their canvasView as another layer and keep the PKDrawing on each page itself and now I am going to change it to your tools directly. Thats how I got the data.
So I kinda need a migration to show the drawings on the old documents.
I hope I’ve explained myself well.


for the people need a solution in future, you can create PTInk programmatically and achieve at least some migration with accurate position and color.

Hi @ogito,

Apologies for the delay here. I briefly took a look yesterday to see if we could implement some functionality to convert a drawing from one PKCanvasView to the one created internally by PTPencilDrawingCreate but it is not a straightforward task.

Could you expand a bit on what you are trying to do with the drawing?
Internally the annotations created by the PTPencilDrawingCreate tool are just image stamps so you could extract the image from your canvas using the -[PKDrawing imageFromRect:scale:] API, and then stamp the image onto the document.

Is that an approach that works for you?