question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

printToFileAsync seems to ignore width and height on native iOS Build

See original GitHub issue

Summary

When calling printToFileAsync of the expo-print library and passing in a custom width and height, the passed width and height seem to get ignored (passing 2480x3508 to get a 300dpi A4 pdf, results in a pdf with the default 612x792 resolution).

This seems to happen only on native iOS builds (eas builds and with expo build), everything works fine on android and when running with expo go.

expo-print Version: 11.0.4 (same error on 11.1.0)

Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!

managed

What platform(s) does this occur on?

iOS

SDK Version (managed workflow only)

43

Environment

Expo CLI 5.0.3 environment info: System: OS: macOS 12.1 Shell: 5.8 - /bin/zsh Binaries: Node: 16.13.1 - ~/.nvm/versions/node/v16.13.1/bin/node Yarn: 1.22.17 - ~/.nvm/versions/node/v16.13.1/bin/yarn npm: 8.1.2 - ~/.nvm/versions/node/v16.13.1/bin/npm Managers: CocoaPods: 1.11.2 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3 IDEs: Android Studio: 2020.3 AI-203.7717.56.2031.7935034 Xcode: 13.2.1/13C100 - /usr/bin/xcodebuild npmPackages: expo: ^43.0.0 => 43.0.5 react: 17.0.1 => 17.0.1 react-dom: 17.0.1 => 17.0.1 react-native: 0.64.3 => 0.64.3 react-native-web: 0.17.1 => 0.17.1 npmGlobalPackages: eas-cli: 0.45.1 expo-cli: 5.0.3 Expo Workflow: managed

Reproducible demo

Pretty much the same code as in the usage example here.

import * as Print from "expo-print";

...
const html = `
	<html>
		<head>
			<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" />
		</head>
		<body>
			<h1>Hello World</h1>
		</body>
	</html>
	`;

const result = await Print.printToFileAsync({
	html: html,
	width: 2480,
	height: 3508,
	margins: {
		top: 0,
		bottom: 0,
		left: 0,
		right: 0
	}
});

Sharing.shareAsync(result.uri, {
			mimeType: "application/pdf",
			UTI: ".pdf"
		});

Info of the generated pdf:

Screenshot 2022-01-25 at 16 04 35

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:10

github_iconTop GitHub Comments

4reactions
xXDeonoXxcommented, Mar 30, 2022

exact same issue here…

expo sdk 43

3reactions
xXDeonoXxcommented, Aug 12, 2022

so on expo 42 its working properly?

yes, 42 is the last version this is working properly

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native Responsive Font Size - Stack Overflow
We use a simple, straight-forward, scaling utils functions we wrote: import { Dimensions } from 'react-native'; const { width, height } = ...
Read more >
Print - Expo Documentation
Prints a document or HTML, on web this prints the HTML from the page. Note: On iOS, printing from HTML source doesn't support...
Read more >
How to make Auto Layout more convenient in iOS - Medium
When the view changes size, the width and height of the red box changes proportionally, but the top spacing remains fixed. In code,...
Read more >
Resizing images to fit the screen using GeometryReader
When we create an Image view in SwiftUI, it will automatically size itself according to the dimensions of its contents.
Read more >
PixelRatio - React Native
A good rule of thumb is to multiply the size of the image you display by the pixel ratio. var image = getImage({...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found