wonday / react-native-pdf

A <Pdf /> component for react-native
MIT License
1.58k stars 540 forks source link

{uri:"data:application/pdf;base64,JVBERi0xLjcKJc..."} work on ondroid but does not work on ios #705

Open chukiatt opened 1 year ago

chukiatt commented 1 year ago

What react-native version are you using? "react": "18.1.0", "react-native": "0.70.5",

What react-native-pdf version are you using? "react-native-pdf": "^6.6.2",

What platform does your issue occur on? (android/ios/both) ios

Describe your issue as precisely as possible : 1) Steps to reproduce the issue or to explain in which case you get the issue 2) Interesting logs

Join a screenshot or video of the problem on the simulator or device?

Show us the code you are using?

testPrint(): Promise {

const databaseID = PxData.default.endPoint.databaseID;
let printDocumentsQuery = {
  branchID: 100,
  doctype: 'AP_HP',
  dpcode: '141000',
  costVisible: true,
  criteria: "H.DocNo='000-HP17000004'",
  orderBy: null,
  printDocItems: true,
  formName: 'ใบรับสินค้า',
  lang: 'th',
  customizeVersion: null,
  reportFormat: 'pdf',
};

 var queryString = Object.keys(printDocumentsQuery)
  .map((key) => {
    return encodeURIComponent(key) + '=' + encodeURIComponent(printDocumentsQuery[key]);
  })
  .join('&');

let url = `https://report.posware.net/api/PrintDocument/${databaseID}/query?${queryString}`;
console.log(url);

return new Promise((resolve, reject) => {
  axios({
    url: url,
    method: 'GET',
    responseType: 'arraybuffer',
  })
    .then((response) => {
      const base64 = Buffer.from(response.data, 'binary').toString('base64');
      const source = { uri: 'data:application/pdf;base64,' + base64 };

      resolve(source);
    })
    .catch((error) => {
      console.error(error);
      reject(error);
    });
});

}

lylysunshinee commented 1 year ago

same issue

sergio-cravas commented 1 year ago

Same here! There are any udpates? Did you manage to solve the problem @chukiatt?