last day (16 days later) » 

10:43
1
A: Get PDF from a UILabel text mask

MooseYou have to draw text yourself in the pdf to make it editable. I have slightly modified your code, and it works. You can simply copy/paste in a new app view controller to check the result. Here is a screenshot of the document opened in AffinityDesigner. The mask is correctly applied as a layer ma...

did you check pdf which we save ? I don't get any mask.
With which code - Original or my answer? In my answer I get exactly the same result on the screen and in the pdf. A masked, editable text. Is that not what you want?
I have retried your code to be sure. It exports the mask as an overlay. I guess it is a bug or an unsupported feature in the .render function from Apple. It looks like it splits and exports all layers as flat images. Have you run my solution? On my Mac, in the simulator, I get the exact same result in the app, and in the exported pdf.
Just added a screenshot to demonstrate the render function result. @Hector, that was an interesting question ;)
I think I got solution by clip subview layer
Do you have a working solution? I'm curious to see how you can generate editable text using .render. Keep me updated, thanks :)
but it's not work with subviews can you please help me
@Moose did you check it ?
10:55
Nice approach. However, even if I render a PMLabel alone in a pdf, it is still not editable... I work a bit more to propose my 'Crawler' approach. See you soon
Can you edit the text when you open it in a pdf app, using your label class ??
yes
I use github.com/sgr-ksmt/PDFGenerator for generate PDF and it's editable
11:12
You PMLabel can't work, because when you get the current graphic context, it is not the pdf. I think the draw method creates a bitmap to render the view.
 
1 hour later…
12:25
The framework you sent me is exactly what I meant by 'a crawler'.
PDFPageRenderable.swift line 67, the view is removed from hierarchy, and rendered in a layer. So maybe your PMLabel should return a PMLayer instead of CALayer. Then your subclass would be called by PDFGenerator at rendering time. You can then use the code I sent to you in my answer to clip the layer and draw the text.
I am sorry, but I can't go further on this right now. Next time you set a Bounty, tell us you use a third party framework in the first place, because it is a radically different strategy! Have a nice day, and good luck fellow iOS developper ;)
Added a small edit in the answer tho.. I did what I could.
12:40
Thank you :) I will give you reputation bounty
I award 200 reputation to you
If you found any solution then ping me here
13:35
Thanks, that's cool :) I think your custom label idea is good. You just need to find how to override the internal layer rendering so it works with PDFGenerator. Use the code in my first answer and move it in the PMLayer.render() function. It may work. I'll try if I have some time for it. Tell me if you find too, so I don't search again on something you found. Bye

  last day (16 days later) »