Код: Выделить всё
@page {
size: A4;
margin: 0;
}
@media print {
* {
-webkit-print-color-adjust: exact !important;
}
}
// Create a print info object
let printInfo = UIPrintInfo.printInfo()
printInfo.outputType = .general
printInfo.jobName = "Resume Document"
// Create print interaction controller
let printController = UIPrintInteractionController.shared
printController.printInfo = printInfo
let formatter = wKWebView.viewPrintFormatter()
printController.printFormatter = formatter
// Set up a completion handler
let completionHandler: UIPrintInteractionController.CompletionHandler = { (printController, completed, error) in
if !completed, let error = error {
print("Printing failed due to error: \(error.localizedDescription)")
} else if completed {
print("Printing completed successfully")
}
}
// Present the print controller
if let rootVC = UIApplication.shared.windows.first?.rootViewController {
printController.present(animated: true, completionHandler: completionHandler)
} else {
printController.present(animated: true, completionHandler: completionHandler)
}
}
< /code>
Как я могу гарантировать, что поля уважается при печати из Wkwebview в iOS? Вы можете увидеть эти белые пространства вокруг синего цвета, они имеют поле.>
Подробнее здесь: https://stackoverflow.com/questions/795 ... ing-on-ios