Jump to content

Recommended Posts

Posted

I am doing a catalog where each section will contain several PDFs, all the same width but of varying height. Each section's PDFs will be in a separate folder and/or have a corresponding code (ie: section1)

 

I want to have a section header and then flow all the PDFs in that folder below, crossing to another page when necessary, and have the spacing between each PDF the same.

 

I have only used Fusion Pro for mailings and very simple variable data jobs so this is beyond my scope. If anyone can point me in the right direction or get me started, I would appreciate it.

 

I am attaching a simple "sketch" that I hope explains what I'm trying to do.

 

Thank you for any help you can give me!

KayEll

Orcas test PDF.pdf

Posted

You can "return" the PDFs by bringing them in as inline graphics in a text frame. You can bring in each one with a simple text rule such as:

return '<graphic file="filename.pdf">';

Make sure to check the "Treat returned strings as tagged text" box.

 

You can optionally specify the height, or width, or both, in hundredths of points (7200 per inch), for example:

return '<graphic file="filename.pdf" width="36000">'; // 5 inches wide

You could also return multiple inline graphics from a single rule, perhaps using a loop or mapping, something like:

var fileNames = ["red.pdf","green.pdf","blue.pdf"];
return fileNames.map(function(name){return '<graphic file="' + name + '">';}).join("<br>\n");

You may notice that this is very similar to what the Inserting Multi-page PDF variable graphics sample does, but in your case, instead of returning multiple pages from a single PDF, you're just grabbing pages from different PDFs and setting them down inline.

 

That said, the problem with what you want to do is that FusionPro doesn't have any built-in mechanism to iterate through a list of file names in a folder on disk, as we discussed a few months ago here in your "Place graphics sequentially" thread:

http://forums.pti.com/showthread.php?p=16640

But you can use the same tricks suggested in that thread again for this purpose.

Posted

The simplest way to accomplish this would be to do this following:

1. Put all of your graphic subfolders (containing your PDFs) in one "graphics" folder and name them in accordance to the section header you want to display above them. For example:

./graphics/

./graphics/Section 1/

./graphics/Section 1/a.pdf

./graphics/Section 1/b.pdf

./graphics/Section 2/

./graphics/Section 2/a.pdf

./graphics/Section 2/b.pdf

./graphics/Section 2/c.pdf

2. Open up a text editor and paste the following code into it:

#!/bin/bash    
echo "****\n* Drag and drop the folder containing the subfolders of your graphics\n* And press Enter\n****"
read pathToPDFs
dataFile=~/Desktop/data.csv
echo "title,pdfs" > $dataFile
IFS=$'\n'
pdfs=`find $pathToPDFs -type f -name "*.pdf"`;
for i in $pdfs;
do	
subFolder=`echo $(dirname "$i")`;
echo "\"${subFolder/*\//}\",\"$i\"" >> $dataFile
done

3. Save that file to your desktop as "generateData.sh"

4. Open up Terminal.app and paste the following command:

sh ~/Desktop/generateData.sh

5. When prompted, drag the folder containing your subfolders ("graphics" in this example) onto the terminal window and press enter. This will generate a file called "data.csv" on your desktop. If you open it you'll notice that it has two fields: "title" and "pdfs". Title is the name of the sub folder (which will be used for the section header in FP) and PDFs is the path to each of the PDFs in those subfolders. You can make edits here as needed.

6. Open FusionPro and create a text rule (make sure you edit the path of the external data file to reflect the "data.csv" file you just created on your desktop):

var ex = new ExternalDataFileEx("/path/to/Desktop/data.csv", ",");
var result = [];
var title = '';
for (var i=1; i<=ex.recordCount; i++) {
   var graphic = ex.GetFieldValue(i, "pdfs");
   var thisTitle = ex.GetFieldValue(i, "title");
   if (thisTitle != title) { result.push(thisTitle); title = thisTitle };
   result.push('<graphic file="' + graphic + '">');
}

return result.join('<p>');

7. Click "Treat returned strings as tagged text"

8. Apply that text rule to a text frame

9. Set that text frame to Overflow to new pages

Posted

Step,

 

Thank you for your reply. However, when I do step 4 (4. Open up Terminal.app and paste the following command:

Code:

sh ~/Desktop/generateData.sh) I get "cannot execute binary file"

 

Not sure what I am doing wrong.

 

Thanks for you help! I appreciate it.

 

KayEll

Posted

What text editor did you use, KayEll?

 

It could be a permissions issue and you'll need to make that file executable (from Terminal):

chmod +x ~/Desktop/generateData.sh

 

If that doesn't work, just replace steps 2,3 and 4 by opening Terminal.app, pasting the below code into it, pressing Enter, and go to step 5.

cat<<'EOF' > ~/Desktop/generateData.sh && sh ~/Desktop/generateData.sh
#!/bin/bash    
echo "\n\n****\n* Drag and drop the folder containing the subfolders of your graphics\n* And press Enter\n****\n\n"
read pathToPDFs
dataFile=~/Desktop/data.csv
echo "title,pdfs" > $dataFile
IFS=$'\n'
pdfs=`find $pathToPDFs -type f -name "*.pdf"`;
for i in $pdfs;
do	
subFolder=`echo $(dirname "$i")`;
echo "\"${subFolder/*\//}\",\"$i\"" >> $dataFile
done
EOF

Posted
It could be a permissions issue and you'll need to make that file executable (from Terminal):

chmod +x ~/Desktop/generateData.sh

The shell script is fine, but it seems simpler to just "cd" to the folder you want in Terminal, and issue a command like this:

ls -1 *.pdf > files.txt

Posted
The shell script is fine, but it seems simpler to just "cd" to the folder you want in Terminal, and issue a command like this:

ls -1 *.pdf > files.txt

 

That would indeed be simpler but the script is doing a little bit more than dumping a list of PDFs into a text file. It is taking into consideration sub-folders within the root graphics directory containing PDFs and building a two column data file:

This will generate a file called "data.csv" on your desktop. If you open it you'll notice that it has two fields: "title" and "pdfs". Title is the name of the sub folder (which will be used for the section header in FP) and PDFs is the path to each of the PDFs in those subfolders. You can make edits here as needed.

 

This could be written as a one-liner but, at the time, I thought having the .sh file would be more helpful and easier to re-use (if needed). But in hindsight, knowing about the executable issues, an argument could be made against how "easy" it actually turned out to be. :o

 

ls -l *.pdf will only return PDF files in the directory that you cd'd into and the -l option will output a bunch of unnecessary information that will be output. I think you'd have to do something like this:

cd to the folder containing the PDFs and subfolders

echo "title,pdfs" > ~/Desktop/data.csv && find $PWD -type f -name "*.pdf" | sed -E 's/(.*)\/(.*)\//\2,\1\//' >> ~/Desktop/data.csv

Posted
That would indeed be simpler but the script is doing a little bit more than dumping a list of PDFs into a text file. It is taking into consideration sub-folders within the root graphics directory containing PDFs and building a two column data file:

Sorry, I oversimplified the problem. Yes, the original poster needs more than what I suggested.

This could be written as a one-liner but, at the time, I thought having the .sh file would be more helpful and easier to re-use (if needed). But in hindsight, knowing about the executable issues, an argument could be made against how "easy" it actually turned out to be. :o

Well, this is all Unix, so the script has to be executable, but I don't think the extra chmod makes it that much more difficult. Your solution is very clever!

ls -l *.pdf will only return PDF files in the directory that you cd'd into and the -l option will output a bunch of unnecessary information that will be output.

That "-1" option in my post was a "one," not a lower-case "L." The "dash one" puts all the output into a single column.

I think you'd have to do something like this:

cd to the folder containing the PDFs and subfolders

echo "title,pdfs" > ~/Desktop/data.csv && find $PWD -type f -name "*.pdf" | sed -E 's/(.*)\/(.*)\//\2,\1\//' >> ~/Desktop/data.csv

That works too. Cool!

Posted (edited)
That "-1" option in my post was a "one," not a lower-case "L." The "dash one" puts all the output into a single column.

 

It has become painfully evident how badly I need to update the 'script in my glasses. Sorry about that!

Edited by step
apparently p-r-e-s-c-r-i-p-t-i-o-n is a bad word

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...