簡體   English   中英

如何在 React Native(expo android)中將 output 紙張大小更改為 A4

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

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

在此處輸入圖像描述

我查看了 expo print文檔,我在 MDN 網站上查找了 .@page 文檔How do I Change Output to A4 size
我檢查了它說的printFilePrintOptions 文檔

單個頁面的高度(以像素為單位)。 默認為 792,這是具有 72 PPI 的美國信紙格式的高度。 在此處輸入圖像描述

那么如何將默認設置更改為 A4 並增加 DPI?

找到了。

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' });

所以,默認情況下,美國信紙的height:792, width:612 PPI,正如我在問題中所問的那樣,
html是一個字符串,也將heightwidth作為number ,如代碼塊所示,

例如,如果您想更改 PPI 更改像素大小
A4 72PPI = H842、W595
A4 150PPI = H1754,W1240 我認為只需要“px”

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM