google-drive-apigoogle-drive-shared-driveflysystem-google-drive

Displaying pdf files from google drive


I am displaying pdf files from my google drive on my webpage. I did it by showing an Iframe with this link:

https://drive.google.com/uc?export=view&id={FILE_ID}

This worked well for a while. But suddenly the file is just downloading instead of being shown in the IFrame. I read about maybe there is some QUOTA from google that prevents from using the export=view for too many users. I couldn't find any information on that. Does anyone know if they just changed their file management and I need to change my links? Or if having a pro plan with google drive fixes this issue?

I struggle to find any information on this. Thanks a lot!


Solution

  • It's explained here: https://gist.github.com/tzmartin/1cf85dc3d975f94cfddc04bc0dd399be

    src="https://docs.google.com/viewer?srcid=[YOUR_FILE_ID]&pid=explorer&efh=false&a=v&chrome=false&embedded=true"

    Example:

    <html>
    <body>
    <iframe src="https://docs.google.com/viewer?srcid=1fmvVwtP6LmI9nPPtp-962rUmIKfdSANY&pid=explorer&efh=false&a=v&chrome=false&embedded=true" width="580px" height="480px"></iframe>
    </body>
    </html>

    Tested it on Edge (Version 120.0.2210.133) and Chrome (Version 120.0.6099.224)