---
title: "Merging multiple PDF files as a single PDF and converting all the pages in a PDF to PNG images using Google Apps Script"
author: "Martin Hawksey"
date: 2023-01-13T17:18:05+00:00
modified: 2023-01-13T17:18:54+00:00
canonical_url: https://pulse.appsscript.info/p/2023/01/merging-multiple-pdf-files-as-a-single-pdf-and-converting-all-the-pages-in-a-pdf-to-png-images-using-google-apps-script/
markdown_url: https://pulse.appsscript.info/p/2023/01/merging-multiple-pdf-files-as-a-single-pdf-and-converting-all-the-pages-in-a-pdf-to-png-images-using-google-apps-script.md
categories:
  - "Drive"
  - "Intermediate"
  - "Snippet"
  - "Solutions"
  - "V8"
tags:
  - "tanaikech.github.io"
featured_image: https://pulse.appsscript.info/files/2023/01/fig1.png
description: "Kanshi Tanaike has recently been exploring and sharing some Apps Script solutions for handling PDF Documents using the PDF-LIB JavaScript library. So far they have looked at merging PDF files as well as converting PDF pages into PNG images. The solution uses fetch and eval to load PDF-LIB, but with a minor modification hoisting the declaration of setTimeout you can also copy the source code into the script editor and avoid the evils of evals (visit this post link for an example setup). The Apps Script execution runtime limit will be a factor in the size of PDF Documents you can handle, but for smaller jobs a great solution to keep in mind."
---

# Merging multiple PDF files as a single PDF and converting all the pages in a PDF to PNG images using Google Apps Script

![Merging multiple PDF files as a single PDF and converting all the pages in a PDF to PNG images using Google Apps Script](https://pulse.appsscript.info/files/2023/01/fig1.png)

> [https://tanaikech.github.io/2023/01/10/merging-multiple-pdf-files-as-a-single-pdf-file-using-google-apps-script/](https://tanaikech.github.io/2023/01/10/merging-multiple-pdf-files-as-a-single-pdf-file-using-google-apps-script/)
> This is a sample script for merging multiple PDF files as a single PDF file using Google Apps Script. [and] This is a sample script for converting all pages in a PDF file to PNG images using Google Apps Script.

Kanshi Tanaike has recently been exploring and sharing some Apps Script solutions for handling PDF Documents using the [PDF-LIB JavaScript library**](https://pdf-lib.js.org/). So far they have looked at merging PDF files as well as converting PDF pages into PNG images.

The solution uses `fetch` and `eval` to load PDF-LIB, but with a minor modification hoisting the declaration of `setTimeout` you can also copy the source code into the script editor and avoid the *evils of evals* ([a modified example here**](https://script.google.com/d/1wqg5CKzVlRuXWf5VtC2Efu5oUfXHilb9Uu5tMN5YdusvYXQc_oTf3EdW/edit?usp=sharing)).

The Apps Script execution runtime limit will be a factor in the size of PDF Documents you can handle, but for smaller jobs a great solution to keep in mind.

Source: [Merging Multiple PDF Files as a Single PDF File using Google Apps Script**](https://tanaikech.github.io/2023/01/10/merging-multiple-pdf-files-as-a-single-pdf-file-using-google-apps-script/) and [Converting All Pages in PDF File to PNG Images using Google Apps Script**](https://tanaikech.github.io/2023/01/11/converting-all-pages-in-pdf-file-to-png-images-using-google-apps-script/)

---

*Published by [Martin Hawksey](https://pulse.appsscript.info/p/author/admin/) on [Pulse](https://pulse.appsscript.info/). Original article: [https://pulse.appsscript.info/p/2023/01/merging-multiple-pdf-files-as-a-single-pdf-and-converting-all-the-pages-in-a-pdf-to-png-images-using-google-apps-script/](https://pulse.appsscript.info/p/2023/01/merging-multiple-pdf-files-as-a-single-pdf-and-converting-all-the-pages-in-a-pdf-to-png-images-using-google-apps-script/)*
