You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
977 B

6 years ago
  1. //
  2. // CustomPrintPageRenderer.swift
  3. // Print2PDF
  4. //
  5. // Created by Gabriel Theodoropoulos on 24/06/16.
  6. // Copyright © 2016 Appcoda. All rights reserved.
  7. //
  8. import UIKit
  9. class CustomPrintPageRenderer: UIPrintPageRenderer {
  10. let A4PageWidth: CGFloat = 595.2
  11. let A4PageHeight: CGFloat = 841.8
  12. override init() {
  13. super.init()
  14. // Specify the frame of the A4 page.
  15. let pageFrame = CGRect(x: 0.0, y: 0.0, width: A4PageWidth, height: A4PageHeight)
  16. // Set the page frame.
  17. self.setValue(NSValue(cgRect: pageFrame), forKey: "paperRect")
  18. // Set the horizontal and vertical insets (that's optional).
  19. // self.setValue(NSValue(CGRect: pageFrame), forKey: "printableRect")
  20. self.setValue(NSValue(cgRect: pageFrame.insetBy(dx: 10.0, dy: 10.0)), forKey: "printableRect")
  21. self.headerHeight = 50.0
  22. self.footerHeight = 50.0
  23. }
  24. }