Webview, pdf, google drive

2 Likes

It’s not a publicly shared link.

1 Like

I had redone the public authorization, but that does not change the problem.

webview pdf auth

I tried your link in my app, which uses the same google docs wrapper. Seems like it’s seeing it but not rendering it as a pdf. I’ll play around with it and see if I can get it to work. All of my PDF’s are uploaded through the app, so I haven’t ran into this issue before. I’ll get back to you.

2 Likes

Merci, jeff

Note, this is a pdf created from a script

var html = "<h1> Hello world, Test New PDF Hello manu </h1>"
           + "<p> The quick brown fox jumped over the lazy dog";

  var blob = Utilities.newBlob (html, "text / html", "text.html");
  var pdf = blob.getAs ("application / pdf");

  var file = DriveApp.createFile (pdf) .setName ("text2.pdf");

But I also did a test with another “real” pdf file, and it’s the same.

1 Like

OK, so I’m not overly familiar with google drives different url structures, but this version works.

https://drive.google.com/uc?id=1vH3mS84YQMJJy4rnYps0P83hhD9MSKhi

If your script is writing the file name to the sheet, hopefully you can write the url in the format above. The file ID is the same, but the rest of the url is structured a little different. Just remember that the file has to be placed into a publicly shared folder, or hopefully you can set the permissions as you are generating the PDF.

3 Likes

Yes Yes Yes
Fantastic
thank you sir

Yes I can format the address from the file id.

1 Like

For information
Here is the script with the permissions and formatting of the Url.

  var html = "<h1> Hello world, Test New PDF Hello manu </h1>"
           + "<p> The quick brown fox jumped over the lazy dog";

  var blob = Utilities.newBlob (html, "text / html", "text.html");
  var pdf = blob.getAs ("application / pdf");
  var file = DriveApp.createFile (pdf) .setName ("text2.pdf");

  file.setSharing(DriveApp.Access.ANYONE, DriveApp.Permission.EDIT);

  var id=file.getId();
  var url = "https://drive.google.com/uc?id=" + id;

  Logger.log(url);
3 Likes

For information 2

If you want to create a link to save a file on your computer.
Add “& export = download” at the end of the address

2 Likes

Thanks for the script. I like the idea of converting html to a pdf. It’s simple. I might have to explore using this in my app.

2 Likes

Yes, but I have some of the HTML is Markdown format, and I’m stuck.
To be continued …

Here is how I do it:
Upload the PDFs to a Google Drive Folder
Use the Files Cabinet extension to create a list of the files in that folder
Set the folder share to anyone with link
Find Replace the URL column for /file/d/ and change /view to /preview for the embed to work
Now bring it into Glide. Then I either add the pdf cover or generate an image column
example: Kierkegaard

Hope this helps…

1 Like

Good afternoon friend, congratulations on your app, it was really cool! I’m new to Glide, I would like more details so you can do this operation to view the pdf. Did you use script? Can you help me?

Thank you so much

2 Likes

Hello,
No script to display a pdf in Glide.
You can use a WebView or an image for this operation.

So, but in the webview it doesn’t open because it has to be in the paid plan and the image I put an image linked to the link and opened externally and not in the app

1 Like

For the image here are the parameters that I use

And here is the FileUrl column

You just need the ID of the file in your google drive.

image

2 Likes

Manu.n, veja: Video

File Id in my Google Drive? I do not know

Ehmm
It is true that in image, it displays only the first page or the whole pdf.
But according to the video, the preview in the picture works?

For the webview, use the model as in FileUrl above.

For the file ID, you already have it

image

it starts with 13pPn1Jq8W4…

In Google Drive, right click on the PDF file and choose Get Link

image