Hi @Jamie_Dassoulas
We are using Dynamic PDFnet XCFframework from above DMG mentioned URL: GitHub - saikat90/PDFSwiftSample
Steps to run the project:
Tools XCFramework are already there in the Github URL
PDFNet XCFramework we need to download from the above DMG mentioned URL
Result:
For highlighter Markup, it is not working for us
Let us know
What are we doing wrong?
Hi Saikat,
Thank you for your feedback. Can you please try the attached code to see if it works? PTAnnotEditTool
and PTToolGroupToolbar
are overridden.
Thank you,
Yifan
ViewController.swift (3.3 KB)
After adding this view controller in the above project facing a crash on GroupToolbar class initialization
PFA
ViewController.swift (3.5 KB)
Can you please help me out with this?
Thanks
Saikat
Hi Saikat,
You could try adding this in GroupToolbar
class:
override init(frame: CGRect) {
super.init(frame: frame)
}
Please let us know how this works for you.
Thank you,
Yifan
1 Like
Awesome, the Crash got resolved.
It is working for us.
Will play around more on this and let you know.
Thanks Yifan
Hi @Yifan_Zhang ,
With this solution, we are facing one issue. If we change the color of the annotation and at that time if another tool is selected its icon is also getting changed. Attaching a video for better understanding.
Steps to reproduce:
- Draw any markup. eg. using a highlighter.
- Select the Callout markup tool from toolbar.
- Select drawn highlighter markup and change the color of that annotation.
- Callout markup and highlighter both tool’s icon and color are getting change. It should change only the highlighter tool icon.
This is happening with all tools. Can you please help us with how we can fix that?
Thanks.
Controller file:
ViewController.swift (4.8 KB)
My apologies. Please try this:
@objc func colorDidChange(notification: Notification) {
let userInfo = notification.userInfo!
let style = userInfo["style"] as! PTAnnotStyle
let type = userInfo["type"] as! PTExtendedAnnotType
let presets = PTAnnotationStyleManager.default.stylePresets(forAnnotationType: type)
var styles = presets.styles
styles[Int(presets.selectedIndex)] = style
presets.styles = styles
PTAnnotationStyleManager.default.setStylePresets(presets, forAnnotationType: type)
for item in self.items ?? [] {
if let toolItem = item as? PTToolBarButtonItem {
if toolItem.toolClass?.annotType == type {
toolItem.setImageStyle(style)
}
}
}
}
Thank you,
Yifan
2 Likes
Hi @ @Yifan_Zhang , Thanks for the solution.
We have tried it and it is working fine except for these tools.
Can you tell us how we can implement the same for these also?
Thanks 
Hi Rankit,
These annotation types are managed by PTPolyLineEditTool
, you could implement the method annotStyleViewController(_ : didChange: )
in PTPolyLineEditTool
's subclass, the same way as in MyAnnotEditTool
.
Please let us know if this helps.
Best,
Yifan
1 Like
It worked. Thanks @Yifan_Zhang 
Hi @Yifan_Zhang ,
We are having one crash, Here I am attaching sample code and some screenshots.
Steps to reproduce:
- Add PDFNet and Tools xcframework in the framework folder.
- Run the project and click on PDFTron button which will navigate to DocController.
- Add any markup and change its color from the style option.
- Go back from the navigation bar button and again press PDFTron button
- App will crash
If we comment out this code in GroupToolbar class, it is working fine.
Crash :
Can you please tell us How can we fix it?
Code Attachment:
SamplePDFTronApp.zip (78.9 KB)
Hi Rankit,
Thank you for reporting the issue.
We are able to reproduce this and are investigating for the root cause.
To avoid the crash for now, please try the attached code. Free text types are not suitable for changing styles in tool manager’s callback.
SamplePDFTronApp.zip (100.3 KB)
Please let us know if you have any other questions.
Best,
Yifan