Code: Select all
// Calculate the dynamic scale factor to fit A4-sized content within the screen
private func dynamicScale(for geometry: GeometryProxy) -> CGFloat {
let screenWidth = geometry.size.width
let screenHeight = geometry.size.height
// A4 dimensions in points
let a4Width: CGFloat = 595.2
let a4Height: CGFloat = 841.8
// Calculate the scale factors for width and height
let widthScale = screenWidth / a4Width
let heightScale = screenHeight / a4Height
// Use the smaller scale factor and add extra white space
return min(widthScale, heightScale) * 0.87 // Adjust this multiplier for more/less white space
}