How Do I change output Paper Size to A4 in React Native (expo android)

Viewed 54

I am using React Native to make an Android App for the billing app and the output paper is 216mmX279mm which is not true PDF size, I am using expo-print, printToFileAsync and from the expo I want PDF output exactly A4 size which 210mmX297mm

enter image description here

I looked it up at the expo print documentation and it took me .@page docs on MDN website How do I Change Output to A4 size
I checked the Documentation of print andFilePrintOptions it says

Height of the single page in pixels. Defaults to 792 which is a height of US Letter paper format with 72 PPI. enter image description here

So How Can I change default to A4 and increase DPI?

1 Answers

Found It.

const printToFile = async () => {

const { uri } = await Print.printToFileAsync({
  html, height:842, width:595
});
console.log('File has been saved to:', uri);
await shareAsync(uri, { UTI: '.pdf', mimeType: 'application/pdf' });

So, By default, height:792, width:612 of US letter paper at 72 PPI as I ask in the question,
html is a string and also takes height and width as number as shown code block,

if you wanna change PPI change pixel size for example
A4 72PPI = H842, W595
A4 150PPI = H1754,W1240 I think it only takes "px"

Related