|
@@ -387,6 +387,9 @@ class KMWatermarkPDFView: CPDFView {
|
|
|
guard let headerFooter = headerFooter else { return }
|
|
|
|
|
|
let pageBounds = page.bounds(for: .cropBox)
|
|
|
+ let xMargin = 0.0//pageBounds.origin.x * 2
|
|
|
+ let yMargin = 0.0//pageBounds.origin.y * 2
|
|
|
+
|
|
|
NSGraphicsContext.saveGraphicsState()
|
|
|
|
|
|
if context != nil {
|
|
@@ -421,7 +424,7 @@ class KMWatermarkPDFView: CPDFView {
|
|
|
attributes: attributes).size
|
|
|
|
|
|
var posY = min(pageBounds.size.height - (headerFooter.topMargin), pageBounds.size.height - size.height)
|
|
|
- tString.draw(in: CGRect(x: headerFooter.leftMargin, y: posY, width: size.width, height: size.height), withAttributes: attributes)
|
|
|
+ tString.draw(in: CGRect(x: headerFooter.leftMargin + xMargin, y: posY + yMargin, width: size.width, height: size.height), withAttributes: attributes)
|
|
|
|
|
|
|
|
|
let topCenterString = headerFooter.topCenterString
|
|
@@ -432,7 +435,7 @@ class KMWatermarkPDFView: CPDFView {
|
|
|
attributes: attributes).size
|
|
|
|
|
|
posY = min(pageBounds.size.height - (headerFooter.topMargin), pageBounds.size.height - size.height)
|
|
|
- tString.draw(in: CGRect(x: pageBounds.size.width/2 - size.width/2, y: posY, width: size.width, height: size.height), withAttributes: attributes)
|
|
|
+ tString.draw(in: CGRect(x: pageBounds.size.width/2 - size.width/2 + xMargin, y: posY + yMargin, width: size.width, height: size.height), withAttributes: attributes)
|
|
|
|
|
|
|
|
|
let topRightString = headerFooter.topRightString
|
|
@@ -443,8 +446,8 @@ class KMWatermarkPDFView: CPDFView {
|
|
|
attributes: attributes).size
|
|
|
|
|
|
posY = min(pageBounds.size.height - (headerFooter.topMargin), pageBounds.size.height - size.height)
|
|
|
- tString.draw(in: CGRect(x: pageBounds.size.width - (headerFooter.rightMargin) - size.width,
|
|
|
- y: posY,
|
|
|
+ tString.draw(in: CGRect(x: pageBounds.size.width - (headerFooter.rightMargin) - size.width + xMargin,
|
|
|
+ y: posY + yMargin,
|
|
|
width: size.width,
|
|
|
height: size.height),
|
|
|
withAttributes: attributes)
|
|
@@ -458,7 +461,7 @@ class KMWatermarkPDFView: CPDFView {
|
|
|
attributes: attributes).size
|
|
|
|
|
|
posY = max((headerFooter.bottomMargin) - size.height, 0)
|
|
|
- tString.draw(in: CGRect(x: headerFooter.leftMargin, y: posY, width: size.width, height: size.height), withAttributes: attributes)
|
|
|
+ tString.draw(in: CGRect(x: headerFooter.leftMargin + xMargin, y: posY + yMargin, width: size.width, height: size.height), withAttributes: attributes)
|
|
|
|
|
|
|
|
|
let bottomCenterString = headerFooter.bottomCenterString
|
|
@@ -469,8 +472,8 @@ class KMWatermarkPDFView: CPDFView {
|
|
|
attributes: attributes).size
|
|
|
|
|
|
posY = max((headerFooter.bottomMargin) - size.height, 0)
|
|
|
- tString.draw(in: CGRect(x: pageBounds.size.width/2 - size.width/2,
|
|
|
- y: posY,
|
|
|
+ tString.draw(in: CGRect(x: pageBounds.size.width/2 - size.width/2 + xMargin,
|
|
|
+ y: posY + yMargin,
|
|
|
width: size.width,
|
|
|
height: size.height),
|
|
|
withAttributes: attributes)
|
|
@@ -484,8 +487,8 @@ class KMWatermarkPDFView: CPDFView {
|
|
|
attributes: attributes).size
|
|
|
|
|
|
posY = max((headerFooter.bottomMargin) - size.height, 0)
|
|
|
- tString.draw(in: CGRect(x: pageBounds.size.width - (headerFooter.rightMargin) - size.width,
|
|
|
- y: posY,
|
|
|
+ tString.draw(in: CGRect(x: pageBounds.size.width - (headerFooter.rightMargin) - size.width + xMargin,
|
|
|
+ y: posY + yMargin,
|
|
|
width: size.width,
|
|
|
height: size.height),
|
|
|
withAttributes: attributes)
|
|
@@ -494,17 +497,17 @@ class KMWatermarkPDFView: CPDFView {
|
|
|
context.setStrokeColor(NSColor(red: 51.0/255.0, green: 186.0/255.0, blue: 234.0/255.0, alpha: 1.0).cgColor)
|
|
|
context.setLineWidth(1.0)
|
|
|
|
|
|
- context.move(to: CGPoint(x: 0, y: headerFooter.bottomMargin + bottomOffset))
|
|
|
- context.addLine(to: CGPoint(x: pageBounds.size.width, y: headerFooter.bottomMargin + bottomOffset))
|
|
|
+ context.move(to: CGPoint(x: xMargin, y: headerFooter.bottomMargin + bottomOffset))
|
|
|
+ context.addLine(to: CGPoint(x: xMargin + pageBounds.size.width, y: headerFooter.bottomMargin + bottomOffset))
|
|
|
|
|
|
- context.move(to: CGPoint(x: headerFooter.leftMargin, y: 0))
|
|
|
- context.addLine(to: CGPoint(x: headerFooter.leftMargin, y: pageBounds.size.height))
|
|
|
+ context.move(to: CGPoint(x: xMargin + headerFooter.leftMargin, y: 0))
|
|
|
+ context.addLine(to: CGPoint(x: xMargin + headerFooter.leftMargin, y: pageBounds.size.height))
|
|
|
|
|
|
- context.move(to: CGPoint(x: pageBounds.size.width - (headerFooter.rightMargin), y: 0))
|
|
|
- context.addLine(to: CGPoint(x: pageBounds.size.width - (headerFooter.rightMargin), y: pageBounds.size.height))
|
|
|
+ context.move(to: CGPoint(x: xMargin + pageBounds.size.width - (headerFooter.rightMargin), y: 0))
|
|
|
+ context.addLine(to: CGPoint(x: xMargin + pageBounds.size.width - (headerFooter.rightMargin), y: pageBounds.size.height))
|
|
|
|
|
|
- context.move(to: CGPoint(x: 0, y: pageBounds.size.height - (headerFooter.topMargin) - topOffset))
|
|
|
- context.addLine(to: CGPoint(x: pageBounds.size.width, y: pageBounds.size.height - (headerFooter.topMargin) - topOffset))
|
|
|
+ context.move(to: CGPoint(x: xMargin, y: pageBounds.size.height - (headerFooter.topMargin) - topOffset))
|
|
|
+ context.addLine(to: CGPoint(x: xMargin + pageBounds.size.width, y: pageBounds.size.height - (headerFooter.topMargin) - topOffset))
|
|
|
|
|
|
let arr: [CGFloat] = [8, 1]
|
|
|
context.setLineDash(phase: 0, lengths: arr)
|