Code covered by the BSD License  

Highlights from
append_pdfs

5.0

5.0 | 5 ratings Rate this file 79 Downloads (last 30 days) File Size: 4.55 KB File ID: #31215

append_pdfs

by

 

27 Apr 2011 (Updated )

Append/concatenate multiple PDF files into a single file using Ghostscript.

| Watch this File

File Information
Description

This function appends multiple PDF files to an existing PDF file, or concatenates them into a PDF file if the output file doesn't yet exist. This can be much faster than appending PDFs one at at time.

This function requires that you have ghostscript installed on your system. Ghostscript can be downloaded from: http://www.ghostscript.com

It also includes code from the export_fig package to interface with Ghostcript.

Acknowledgements

Export Fig inspired this file.

MATLAB release MATLAB 7.11 (R2010b)
Other requirements Ghostscript
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (17)
14 Oct 2013 Corey

Hi Oliver,
Thank you for your response.
I am indeed using the functional form of the command. Apparently this is a limitation with using GhostScript in general. Was just curious if there was a sneaky workaround for paths that get too long.
http://ghostscript.com/doc/current/Language.htm

03 Oct 2013 Oliver Woodford

Christa: To save to a particular folder, just specify the full or relative path in the output filename. I haven't seen the blank first page, so can't help there.

Corey: I haven't seen the 128 character limit problem, so can't really help. However, are you using the functional form of the command? E.g.:
output = 'test.pdf';
inputs = {'long_name1.pdf', 'long_name2.pdf'};
append_pdfs(output, inputs{:});

02 Oct 2013 Corey

This is great. I was wondering if you knew a good way to get around the 128 character limit on filename sizes? When you are appending to too many subfolders, the path can get too long, and cause the function to fail. Of course, one could reduce the length of the path, but if there is a sneaky way to get around this 128 character limit, it would be appreciated!

14 Sep 2013 Christa

Thanks for sharing this! It is very helpful. I have a couple questions though. I'd like to save the combined pdf into a specific folder, not just the general matlab folder that I'm working in. Also, it is outputting a blank white sheet as the first page of my pdf. Any idea how to correct either of these issues? Thanks in advance!

02 Apr 2013 Courtney

Bitmap/vector problem appears to have resolved itself. Disregard my question. Thanks!

02 Apr 2013 Courtney

Hi Oliver,
Thanks for your suite of image exporting functions. I'm having an issue with complex (large, ~15MB) vector-rendered pdfs being transformed to bitmaps when combined, and getting pixelated. Any way around this?

26 Feb 2013 Claudia  
21 Aug 2012 Ben Noffke  
10 Apr 2012 Christoph david  
10 Apr 2012 Christoph david

Thank you very much! You were right. I created a cell array and now it works.

I apologize for the rate.
This was my first post on mathworks. When I clicked the "submit" button nothing happend so I thought I have to rate. Without thinking (and without reading) I rated 4 stars. Than I realised that I just had to reload the page to see my post.
Sorry for that.

Thank you for this tool!

10 Apr 2012 Oliver Woodford

Christoph: This an issue with your use of MATLAB syntax, rather than anything else. Make a cell array, string1, of the input file names, then call
append_pdfs('output.pdf', string1{:});
It's not clear why gave the function 4 stars. Any suggestions?

10 Apr 2012 Christoph david

It works when I write output, input1, input2 inside '' with .pdf extensions <== true.
+ I can't make it work if I stock all inputs during a loop in a string (the string includes the apostrophes and commas)
e.g. string1='input1','input2'
append_pdfs('output',string1) doesn't work.
Anyone an idea how to make it work?
Thx a lot!

03 Apr 2012 Hakan Çakan

Oliver,
Thank you very much. I solved it but in the help section it is written that:

% Example:
% append_pdfs(output, input1, input2, ...)

It works when I write output, input1, input2 inside '' with .pdf extensions. It would be beter if you update help file accordingly.

Thanks again.

05 May 2011 Oliver Woodford

Michael: Fix submitted. Thanks for reporting the problem.

04 May 2011 Michael Teo

I was trying to appends 200+pdfs to 1 pdf. It resulted in "The command line is too long." message.

Pls advise, thanks.

04 May 2011 Oliver Woodford

Thanks, David. It'll be in the next version.

28 Apr 2011 David Chorlian

Regarding ghostscript.m, in Linux /usr/bin/gs is the more likely path for gs.

Updates
28 Apr 2011

Bug fix to ghostscript.m mostly affecting Linux (thanks to Paul Durack for reporting it).

05 May 2011

Fixed bug affecting long commands. Thanks to Michael Teo for reporting it.

01 Jun 2011

Improve quality of bitmaps. Thanks to Martin Wittmann for pointing out the issue.

10 Apr 2012

Added more syntax examples.

Contact us