Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #4699 > unrolled thread

Assembling PDFs into a PDF document?

Started byAES <siegman@stanford.edu>
First post2011-09-02 07:32 +0000
Last post2011-09-03 21:58 +0000
Articles 7 — 6 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Assembling PDFs into a PDF document? AES <siegman@stanford.edu> - 2011-09-02 07:32 +0000
    Re: Assembling PDFs into a PDF document? David Bailey <dave@removedbailey.co.uk> - 2011-09-03 12:07 +0000
    Re: Assembling PDFs into a PDF document? Alan <alan.isaac@gmail.com> - 2011-09-03 12:09 +0000
    Re: Assembling PDFs into a PDF document? dr DanW <dmaxwarren@gmail.com> - 2011-09-03 12:11 +0000
      Re: Assembling PDFs into a PDF document? AES <siegman@stanford.edu> - 2011-09-03 21:57 +0000
      Re: Assembling PDFs into a PDF document? Armand Tamzarian <mike.honeychurch@gmail.com> - 2011-09-05 11:17 +0000
    Re: Assembling PDFs into a PDF document? JUN <noeckel@gmail.com> - 2011-09-03 21:58 +0000

#4699 — Assembling PDFs into a PDF document?

FromAES <siegman@stanford.edu>
Date2011-09-02 07:32 +0000
SubjectAssembling PDFs into a PDF document?
Message-ID<j3q0ql$6fn$1@smc.vnet.net>
[I can set about learning how to do the following by myself, but if 
anyone has an off-the-cuff answer or pointers to the starting point, 
I'll be appreciative.]

Given a large number of single-page PDF image files, all in a single 
folder (on a Mac), write a notebook that will build a single multipage 
document containing some or all of these files, in accordance with 
(and with page order determined by) a list of some or all of these 
image file names.

For extra credit:  Have each page in the final document bookmarked by 
the name of the corresponding file.

Thanks for any assistance.

[toc] | [next] | [standalone]


#4712

FromDavid Bailey <dave@removedbailey.co.uk>
Date2011-09-03 12:07 +0000
Message-ID<j3t59j$56v$1@smc.vnet.net>
In reply to#4699
On 02/09/2011 08:32, AES wrote:
> [I can set about learning how to do the following by myself, but if
> anyone has an off-the-cuff answer or pointers to the starting point,
> I'll be appreciative.]
>
> Given a large number of single-page PDF image files, all in a single
> folder (on a Mac), write a notebook that will build a single multipage
> document containing some or all of these files, in accordance with
> (and with page order determined by) a list of some or all of these
> image file names.
>
> For extra credit:  Have each page in the final document bookmarked by
> the name of the corresponding file.
>
> Thanks for any assistance.
>
I doubt if this is possible, because the Import operation, can extract 
raw text or whole pages in the form of images. It is not possible to 
extract formatted text - say in the form of a notebook. Maybe that will 
change in future versions of Mathematica, but I understand that the PDF 
format is rather opaque.

David Bailey
http://www.dbaileyconsultancy.co.uk

[toc] | [prev] | [next] | [standalone]


#4716

FromAlan <alan.isaac@gmail.com>
Date2011-09-03 12:09 +0000
Message-ID<j3t5de$581$1@smc.vnet.net>
In reply to#4699
http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/

hth,
Alan Isaac

[toc] | [prev] | [next] | [standalone]


#4720

Fromdr DanW <dmaxwarren@gmail.com>
Date2011-09-03 12:11 +0000
Message-ID<j3t5h8$58o$1@smc.vnet.net>
In reply to#4699
Step 1: be grateful you own a Mac.  PDF's are so easy to manipulate on a Mac.

This is one of those rare circumstances where I don't think Mathematica is your best solution.  Preview exports actions to Automator for compiling pages into a PDF and for watermarking.

Since this is a Mathematica forum, I have to ask the group: Can Mathematica be used to script Automator or Applescript actions?

Daniel

[toc] | [prev] | [next] | [standalone]


#4725

FromAES <siegman@stanford.edu>
Date2011-09-03 21:57 +0000
Message-ID<j3u7s5$a8i$1@smc.vnet.net>
In reply to#4720
Original query:

> Given a large number of single-page PDF image files, all in a single
> folder (on a Mac), write a notebook that will build a single multipage
> document containing some or all of these files, in accordance with
> (and with page order determined by) a list of some or all of these
> image file names.
>
> For extra credit:  Have each page in the final document bookmarked by
> the name of the corresponding file.

In article <j3t5h8$58o$1@smc.vnet.net>,
 dr DanW <dmaxwarren@gmail.com> wrote:

> This is one of those rare circumstances where I don't think Mathematica is 
> your best solution.  Preview exports actions to Automator for compiling pages 
> into a PDF and for watermarking.

I guess I'm surprised at the answers I've gotten to this query -- thus 
far, anyway -- which basically say, "You gotta do this by hand".  All 
I want to do is, in essence, import a bunch of files; concatenate 'em 
(without in any way opening, "reading" or in any way processing them); 
and re-export the concatenated file.  

What I failed to understand, I suppose, is that one doesn't just 
"concatenate" PDF files in this fashion.  Text files, yes; image 
files, probably; but PDF files, no. (Or can one, in fact, do this with 
PDF files, without converting each PDF file to a .jpg or .png file? --  
maybe at the cost of a bulkier final document?)

The Automator suggestion is interesting.  I've played with it a bit; 
found it powerful but quirky; and not a particularly fun language to 
program in -- partly because it's hard to follow just what it's doing, 
step by step, partly because it's not well documented.

But suppose your workflow involves generating and saving a large 
number of one-page PDF files -- each file a spec sheets or catalog 
page for one of the products or commercial items that you sell, for 
example.  

Every so often you edit a master list of the PDF files for those 
products that you currently sell (a list of the file names, that is), 
removing obsolete items, adding new ones.  Then you hand this list to 
a Mathematica notebook, which builds an updated multipage catalog of 
all your current products.  This can't be done . . . ???

As I'm typing, I thinking:  Hey, I'm quite sure I can do this in TeX, 
and quite easily in fact.  I'll give that a try.

[toc] | [prev] | [next] | [standalone]


#4757

FromArmand Tamzarian <mike.honeychurch@gmail.com>
Date2011-09-05 11:17 +0000
Message-ID<j42b48$rs7$1@smc.vnet.net>
In reply to#4720
On Sep 3, 10:11 pm, dr DanW <dmaxwar...@gmail.com> wrote:
> Step 1: be grateful you own a Mac.  PDF's are so easy to manipulate on =
a Mac.
>
> This is one of those rare circumstances where I don't think Mathematica i=
s your best solution.  Preview exports actions to Automator for compiling=
 pages into a PDF and for watermarking.
>
> Since this is a Mathematica forum, I have to ask the group: Can Mathemati=
ca be used to script Automator or Applescript actions?
>
> Daniel

There is this:

http://library.wolfram.com/infocenter/MathSource/5688/

which may help. There is also a services package as well. I haven't
used either of them for many years and recall that an update was
needed for the graphics rendering in services (for better resolution).

Mike

[toc] | [prev] | [next] | [standalone]


#4727

FromJUN <noeckel@gmail.com>
Date2011-09-03 21:58 +0000
Message-ID<j3u7u3$a8r$1@smc.vnet.net>
In reply to#4699
On Sep 2, 12:32 am, AES <sieg...@stanford.edu> wrote:
> [I can set about learning how to do the following by myself, but if
> anyone has an off-the-cuff answer or pointers to the starting point,
> I'll be appreciative.]
>
> Given a large number of single-page PDF image files, all in a single
> folder (on a Mac), write a notebook that will build a single multipage
> document containing some or all of these files, in accordance with
> (and with page order determined by) a list of some or all of these
> image file names.
>
> For extra credit:  Have each page in the final document bookmarked by
> the name of the corresponding file.
>
> Thanks for any assistance.

I think the only reason this may be worth doing in Mathematica is that
the sorting and selection of the input files perhaps requires some
nontrivial processing. Assuming you have already solved that problem,
here is a simple way to proceed.

Calling this a Mathematica solution is perhaps cheating, but here it
is anyway:

coalescePDF[inputFiles_?ListQ, outputFile_?StringQ] :=
 If[FileExistsQ[outputFile],
  Print[outputFile <>
    " already exists and has not been overwritten"],
  Run["/System/Library/Automator/Combine\\ PDF\\ \
Pages.action/Contents/Resources/join.py --output " <> outputFile <>
    " " <> StringJoin[Riffle[inputFiles, " "]]]
  ]

The input filenames are passed to this function as strings in the list
inputFiles, and the desired output file name is the second argument.
So you would call it like this:

coalescePDF[{"picture1.pdf","picture2.pdf"}, "output.pdf"]

Just in case the line breaks are ambiguous when this gets posted, make
sure the string in the path name reads as one line containing
"Combine\\ PDF\\ Pages.action"
That's an Automator action that comes with OS X, so it's perhaps
better than using LaTeX or ghostscript etc., although I'm sure you
have those installed too.

Regards,
Jens

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web