Skip to content

Commit

Permalink
wire in (page) bleed calculations to WebView.swift per issue #7 - unt…
Browse files Browse the repository at this point in the history
…ested
  • Loading branch information
thisisaaronland committed Feb 19, 2021
1 parent bfc7755 commit 247b1ad
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Sources/Webster/WebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class WebViewDelegate: NSObject, WebFrameLoadDelegate {

public var dpi: CGFloat = 72.0
public var margin: CGFloat = 1.0
public var bleed: CGFloat = 0.0
public var width: CGFloat = 6.0
public var height: CGFloat = 9.0
public var target: URL!
Expand Down Expand Up @@ -32,9 +33,12 @@ class WebViewDelegate: NSObject, WebFrameLoadDelegate {
]

let printInfo: NSPrintInfo = NSPrintInfo(dictionary: printOpts)
let baseMargin: CGFloat = margin * dpi
let baseMargin: CGFloat = (margin + bleed) * dpi

printInfo.paperSize = NSMakeSize(width * dpi, height * dpi)
let w = width + (bleed * 2.0)
let h = height + (bleed * 2.0)

printInfo.paperSize = NSMakeSize(w * dpi, h * dpi)
printInfo.topMargin = baseMargin
printInfo.leftMargin = baseMargin
printInfo.rightMargin = baseMargin
Expand Down

0 comments on commit 247b1ad

Please sign in to comment.