|
@@ -219,6 +219,31 @@ class KMBatesManager: NSObject {
|
|
|
model.name = value as! String
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ func updateCPDFBates(_ pdfBates: CPDFBates, withModel model: KMBatesModel, _ totalPDFCount: Int) {
|
|
|
+
|
|
|
+ let fontSize = model.fontsize
|
|
|
+ let fontName: String = model.fontName
|
|
|
+
|
|
|
+ let font = NSFont.boldSystemFont(ofSize:fontSize)
|
|
|
+ let style = NSMutableParagraphStyle()
|
|
|
+ style.alignment = .center
|
|
|
+ style.lineBreakMode = .byCharWrapping
|
|
|
+ let size: NSSize = "text".boundingRect(with: NSSize(width: 1000, height: 1000), options: NSString.DrawingOptions(rawValue: 3), attributes: [NSAttributedString.Key.font : font, NSAttributedString.Key.paragraphStyle : style]).size
|
|
|
+ pdfBates.margin = NSEdgeInsetsMake(max(CGFloat(model.topMargin)-size.height, 0), CGFloat(model.leftMargin), max(CGFloat(model.bottomMargin)-size.height, 0), CGFloat(model.rightMargin))
|
|
|
+
|
|
|
+ let strings = KMBatesManager.parseModel(model: model, UInt(totalPDFCount))
|
|
|
+ var count: Int = 0
|
|
|
+ let color = model.color
|
|
|
+
|
|
|
+ for text in strings {
|
|
|
+ pdfBates.setText(text, at: UInt(count))
|
|
|
+ pdfBates.setTextColor(color, at: UInt(count))
|
|
|
+ pdfBates.setFontSize(fontSize, at: UInt(count))
|
|
|
+ pdfBates.setFontName(fontName, at: UInt(count))
|
|
|
+ count += 1
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
//MARK: - Parse
|
|
|
func parseModel(model: KMBatesModel) -> Dictionary<String, Any> {
|