Good day,
Hi Evans,
We were able to reproduce the reported issue in our end. When loading the provided PDF URL in our SfPdfViewer it throws an exception "The loaded PDF file is corrupted or damaged". We initially thought that the shared PDF was corrupted, but to confirm we checked loading various other PDF files from Google Drive in our SfPdfViewer and faced the same issue. Then, we prepared a sample without our SfPdfViewer, where we read the PDF file from Google Drive using http package and then saved it and opened that PDF file in the Adobe Reader - Mobile using open_file package (which is used to view the PDF document in the default PDF Viewer). Even in Adobe Reader - Mobile, we faced the same corrupted file issue. We are currently checking on this and will update the further details on August 22, 2022.
Please find the reference sample code snippet that we tried without our SfPdfViewer and the Adobe Reader screenshot from below,
Code Snippet:
//Get the external storage directory Directory directory = (await getApplicationDocumentsDirectory());
//Get the directory
path
//Create an empty file
to write the PDF data
//Write the PDF data
//Open the PDF file in
default mobile PDFViewer
|
// Adobe Reader Output Screenshot
https://www.syncfusion.com/downloads/support/directtrac/general/MicrosoftTeams-image1975372025.png
Regards,
Deepika Ravi
Hi Evns,
Sorry for the inconvenience.
We are checking on this and will update the further details on August 24, 2022.
Regards,
Deepika R
Hi Evans,
On further analysis, we found that the document bytes retrieved from the http package are not proper, which returns document type html data, so when loading the Google Drive URL , it throws an exception [“The loaded PDF file is corrupted or damaged]. We did some search and found the workaround to resolve the issue, kindly change the URL link in this format [https://drive.google.com/uc?export=view&id=<FILE_ID>] and then load the URL in the SfPdfViewer.network constructer. The following code example explains the same.
Code snippet:
class _HomePage extends State<HomePage> {
|
Reference link: https://stackoverflow.com/questions/59849232/display-images-from-google-drive-using-networkimage
The above mentioned suggestion is the one way of workaround solution for resolve the issue .Please let us know If you need a sample with authentication and then accessed Google drive, retrieves PDF data using Google Drive APIs, and then loads that data into SfPdfViewer.
Regards,
Deepika Ravi