topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Monday December 9, 2024, 9:29 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: program to create a printout from a directory of PDF files  (Read 4574 times)

questorfla

  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
  • Fighting Slime all the Time
    • View Profile
    • Donate to Member
program to create a printout from a directory of PDF files
« on: January 28, 2015, 12:22 AM »
This is or should be a simple task and maybe Nitro or even Adobe reader could do it.  Once upon a time, I ran across a very neat program that could take a folder full of pdfs and in short order create a "Flah" type "Flipping Book".  Nothin gto fancy but it was impressive at the time. 
The actual NEED is to simply have a way to maintain the directory structure the files are stored in. This is the correct order for what is needed and preorganized to present an electronic version o9f the files in a directory organized like the printed notebook would have been.  The "Flipping book" would have been a nifty addition that the user could copy to a few flash drives to hand out at a meeting if necessary to allow each person to "flip" though their copy at the pace they wanted to. 
The need for this though is to allow the Users here to have a way to actually print out a pre-organized "notebook" of sorts to carry with them on a business trip .
There have been enough times when the lack of an internet connection or failure of their laptop of some other reason left them high and dry when their only copy to present is on their website if it cannot be accessed.

To resolve this, i only needed tobe able to print out the pre-organized folder and sub folders that contain the files in the order in which they are stored.  It sounded easy enough until tried it.
I may be trying too hard but I have access to the actual web-server so the files do not require downloading for me to do something like this.  While I would like to offer the electronic version of "the book" the programs i tested for doing this took an extremely long time and so far i have not gotten any output that i could use, although i admit i have not tried that many nor for that long.

I thought i would get some opinions if anyone else has ever tried to print out a "booklet" or "notebook" in the same format as the files are stored on the harddrive.  They are all just PDF files in organized sub folders.  It seems ther should be a simple enough utility that could be set to print all pdf's in the folder and sub folders while putting in a separator sheet labelled with the name of the sub folders as they change.
If anyone knows of one that would do this I would be more than happy to purchase it.  The one very high-tech version i was hopeful for had just about every feature in the world and would probably need me to run every print job.  The program was full of features but required tech support from China and their time is a bit off from the time i normally work.
This is something i need to keep simple enough to allow the Users who own the files to connect through the server to print them out in the office.  The Old Flash/Html-pdf  Flipping book program i don't remember as being that hard but so far I cannot find the one from 3 years back.

For most of these people i need something not much more complicated than "Print"  :)  All ideas appreciate.  I have a copy of Nitro pdf and one of Adobe Pdf from about a year back (ver 12 maybe) if there is a procedure in either to handle things like this.

Thanks

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,644
    • View Profile
    • Donate to Member
Re: program to create a printout from a directory of PDF files
« Reply #1 on: February 03, 2015, 06:41 AM »
If I'm understanding this correctly, you want every PDF in a folder tree concatenated with a header page between each folder of PDFs stating the folder the following group of PDFs appear in.

If that's the case then here's something from the "I thought DOS was dead department":

StrangePDFThing.cmd
Code: Text [Select]
  1. @if (@CodeSection == @Batch) @then
  2.     rem StrangePDFThing.cmd
  3.     @echo off
  4.     color 1a
  5.     setlocal EnableExtensions
  6.     setlocal DisableDelayedExpansion
  7.    
  8.     echo Select SOURCE folder
  9.     for /F "delims=" %%S in ('CScript //nologo //E:JScript "%~F0"') do (
  10.         set srce=%%S
  11.     )
  12.     if "%srce%"=="" goto :End
  13.     echo Selected folder: "%srce%"
  14.    
  15.     set spath=%srce%
  16.     set wdir=%cd%
  17.     echo.%srce% > %TEMP%\header.txt
  18.     %wdir%\txttopdf.exe -pfn101 -pfs20 -pot %TEMP%\header.txt %TEMP%\header.pdf
  19.     pushd %srce%
  20.     echo.Processing: "%srce%"
  21.     %wdir%\pdftk.exe %TEMP%\header.pdf *.pdf cat output %TEMP%\out.pdf
  22.     popd
  23.     del %TEMP%\header.pdf
  24.     ren %TEMP%\out.pdf temp.pdf
  25.    
  26.     dir /b /s /ad "%spath%" | sort >%TEMP%\sPDFt.txt
  27.     for /f "tokens=*" %%a in (%TEMP%\sPDFt.txt) do call :DoSomething "%%~a"
  28.  
  29.     goto :End
  30.  
  31.     :DoSomething
  32.     echo.Processing: "%~1"
  33.     pushd "%~1"
  34.     if not exist "*.pdf" goto :SkipIt
  35.     echo.%~1 > %TEMP%\header.txt
  36.     %wdir%\txttopdf.exe -pfn101 -pfs20 -pot %TEMP%\header.txt %TEMP%\header.pdf
  37.     %wdir%\pdftk.exe %TEMP%\temp.pdf %TEMP%\header.pdf *.pdf cat output %TEMP%\out.pdf
  38.     popd
  39.     del %TEMP%\header.pdf
  40.     del %TEMP%\temp.pdf
  41.     ren %TEMP%\out.pdf temp.pdf
  42.     :SkipIt
  43.     goto :EOF
  44.     endlocal
  45.  
  46.     :End
  47.     del %TEMP%\sPDFt.txt
  48.     del %TEMP%\header.txt
  49.     ren %TEMP%\temp.pdf Combined.pdf
  50.     move %TEMP%\Combined.pdf %wdir%
  51.     exit
  52.    
  53.     End of Batch section
  54. @end
  55.  
  56.  
  57. // JScript section
  58.  
  59. // Creates a dialog box that enables the user to select a folder and display it.
  60. var title = "Select a folder", rootFolder = 0x11;
  61. var shl = new ActiveXObject("Shell.Application");
  62. var folder = shl.BrowseForFolder(0, title, 0, rootFolder);
  63. WScript.Stdout.WriteLine(folder ? folder.self.path : "");

Requirements:
TxtToPDF - from Adult PDF  (to generate the header sheets)
PDFtk - from PDF Labs  (to concatenate all the PDFs)

These are both free and they don't need to be installed to use, just run each installer through UniExtract and grab the files from the {app} folder.  Put them in the same folder as the command file so that you have the following:

help.html
libiconv2.dll
main.jpg
pdftk.exe
PdftkXp.exe
setting.jpg
sPDFt.cmd
TxtToPDF.exe

To run, just double-click the sPDFt.cmd file.

It creates a file called Combined.pdf in the same folder as the command file.  It worked here, limited testing done.

NOTE: It will completely die if any of the PDFs are protected, (ie. the protected PDF is unable to be appended which will screw up the whole procedure).

Source code included for you to self-modify  ;)