|
@@ -410,7 +410,6 @@ extension KMPrintPresenter: KMPrintPresenterDocument {
|
|
|
|
|
|
page.page.draw(with: PDFDisplayBox.cropBox, to: context)
|
|
|
// page.transform(context, for: PDFDisplayBox.cropBox)
|
|
|
-
|
|
|
if border {
|
|
|
var dirtyRect = rect
|
|
|
if rotate == 90 ||
|
|
@@ -428,6 +427,51 @@ extension KMPrintPresenter: KMPrintPresenterDocument {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ func drawLabelTextContextSize(context: CGContext) {
|
|
|
+ let pageSize = CGSize(width: 0, height: 0)
|
|
|
+ let KBlankA4W = pageSize.width
|
|
|
+ let KBlankA4H = pageSize.height
|
|
|
+
|
|
|
+ var contextString: String
|
|
|
+// if let labelString = PDFPrint.labelString, !labelString.isEmpty {
|
|
|
+// contextString = labelString
|
|
|
+// } else {
|
|
|
+ let date = Date()
|
|
|
+ let formatter = DateFormatter()
|
|
|
+ formatter.dateFormat = "YYYY-MM-dd hh:mm:ss"
|
|
|
+ contextString = "(\("1"),\("1")) \("filePath.lastPathComponent") \(formatter.string(from: date))"
|
|
|
+// }
|
|
|
+
|
|
|
+ let fontSize = 12.0 * (max(KBlankA4W, KBlankA4H) / 842)
|
|
|
+ let font = NSFont.systemFont(ofSize: fontSize)
|
|
|
+ let color = NSColor.black
|
|
|
+
|
|
|
+ var size = NSSize.zero
|
|
|
+ var style = NSMutableParagraphStyle()
|
|
|
+ style.alignment = .center
|
|
|
+ style.lineBreakMode = .byCharWrapping
|
|
|
+ var attributes = [NSAttributedString.Key: Any]()
|
|
|
+ attributes[.paragraphStyle] = style
|
|
|
+ attributes[.foregroundColor] = color
|
|
|
+ attributes[.font] = font
|
|
|
+ size = contextString.boundingRect(with: CGSize(width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude),
|
|
|
+ options: [.usesLineFragmentOrigin, .usesFontLeading],
|
|
|
+ attributes: attributes).size
|
|
|
+
|
|
|
+// if PDFPrint.splitType == .pageNumber {
|
|
|
+ contextString.draw(in: CGRect(x: 10 + 10,
|
|
|
+ y: KBlankA4H - 10 + size.height,
|
|
|
+ width: size.width, height: size.height),
|
|
|
+ withAttributes: attributes)
|
|
|
+// } else {
|
|
|
+// contextString.draw(in: CGRect(x: PDFPrint.edgeInsets.left + 10,
|
|
|
+// y: KBlankA4H - PDFPrint.edgeInsets.top + size.height,
|
|
|
+// width: size.width, height: size.height),
|
|
|
+// withAttributes: attributes)
|
|
|
+// }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
protocol KMPrintPresenterPage {}
|