Skip to content
Advertisement

How can I convert each google slide into a PDF and JPG?

Google Apps Script

  • I want to create PDF files per each slide of a Google slide file (a normal slide with words and graphs).
  • I reviewed past questions and I found a solution that generates PDF files but taking the slides as images (I need to be able to search for words in those pdf).
  • Another solution was applied to convert the spreadsheet -> PDF but also it didn’t work for my case.

This was my reference

JavaScript

Update

  • I forgot to mention that the Google slide file has a different page setup size than the default.
  • The first answer to this question solved the problem to generate the pdf files, but it doesn’t consider the size of the slide.

Advertisement

Answer

I believe your goal as follows.

  • You want to export each page of a Google Slides as each PDF file.
  • You want to achieve this using Google Apps Script.

In this case, how about the following flow?

  1. Retrieve all slides from the source Google Slides.
  2. Create a temporal Google Slides.
  3. Export each page as a PDF file.
  4. Remove the temporal Google Slides.

When this flow is reflected to a script, it becomes as follows.

Sample script:

Please copy and paste the following script to the script editor of Google Slides, and run the function myFunction. By this, the script is run.

JavaScript
  • In this case, the filenames of each PDF file are like page_1.pdf, page_2.pdf.

Note:

  • From your title, if you want to export each slide as each JPEG file instead of PDF file, you can also use the following sample script. In this case, Slides API is used. So, before you run the script, please enable Slides API at Advanced Google services.

    JavaScript
    • In this case, the filenames of each JPEG file are like page_1.jpg, page_2.jpg.

References:

Added:

From the following OP’s replying,

My Slide file has a different page setup than the default, so when applying your code the PDF files generated end up with the default size, giving distorted files. How can I address that?

Actually, it’s my bad. I mean that my original Google Slide file has a different page setup (let’s say 14 x 18 cm). Your code works, but the PDF files generated have the default page setup of a slide.

From above replying, it seems that the page size is not default. In this case, I would like to propose to use the page size of the original Google Slides. The sample script is as follows.

Sample script:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement