Search code examples
pdfamazon-s3pdf-generationghostscriptpdf-conversion

How to Merge PDFs from S3 using ghostscript


ghostscript is working fine to merge multiple pdf files into one. It is working fine when we merge files from our server. Now, I want to merge pdf files which are present in amazon S3.

Is that possible? something like

 gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=output.pdf https://<bucket>.s3.amazonaws.com/pdf1.pdf http://<bucket>.s3.amazonaws.com/pdf2.pdf

Solution

  • No, you cannot do that. Ghostscript does not have a http client built in, and it requires random access to the files as well, so it might be very slow even if it did work.

    All files must be available via the local Operating System's file system.

    Of course, it would in principle be possible to add a new file device type (similar to %rom% and %ram%) to do file access by http. Ghostscript is open source so you can add this yourself if you want.

    Please note that you aren't merging PDF files, the source files are interpreted and a brand new PDF file created from the marking content of the input. Its not the same thing.