A script to create a text file from job-folder information
Posted: Mon Oct 01, 2012 2:45 pm
Hi
I have a scripting challenge.
My goal is to insert bookmarks into a pdf, which have been merged by Switch. Before the merge, the pdf-files are a job-folder.
To insert the bookmarks I plan to use Coherent PDF (www.coherentpdf.com/). This program can insert bookmarks based on a text-file, which could look like this:
0 "First chapter" 1
0 "Second chapter" 11
0 "Last chapter" 42
The 0 defines the level. The text inside "" the name of the bookmark and the last number is to which page number the bookmark has as destination.
My resulting file should then be one pdf, where the bookmarks destination are the first page of each individual file before the merge.
In this example my starting files are named:
001-First chapter.pdf (pagecount 10)
002-Second chapter.pdf (pagecount 31)
003-Last chapter.pdf (pagecount 46)
I can do a bit of javascript, so I think I have an idea of how it should work, but just not how to write the code. Let my try to explain.
The script should look at the pdfs in the job-folder. Loop through all of them to create a text file, where each pdf creates a new line.
The first line should be like:
0 "[Job.NameProper:After=-]" 1
Second line, where the number should be replaced with the pagecount of the first-file +1:
0 "[Job.NameProper:After=-]" number
Third line, where the number should be replaced with the number from the second line + the second files pagecount:
0 "[Job.NameProper:After=-]" number
And it should go through all the files in the job-folder.
So in my example the resulting text file should look like this.
0 "First chapter" 1
0 "Second chapter" 11
0 "Last chapter" 42
The text-file should the be saved with the job-folder name.
Later on I would then use the execute command to make Coherent PDF add to bookmarks to my file from the created text-file.
I have looked at the forum and made a script, which just creates a single text-file of each pdf, but there are no adding up of the pagecount.
I used this as the source of the script: http://www.crossroads-world.com/en/Home ... posts&t=32
I hope this makes sense and somebody can help, or then please contact me.
I have a scripting challenge.
My goal is to insert bookmarks into a pdf, which have been merged by Switch. Before the merge, the pdf-files are a job-folder.
To insert the bookmarks I plan to use Coherent PDF (www.coherentpdf.com/). This program can insert bookmarks based on a text-file, which could look like this:
0 "First chapter" 1
0 "Second chapter" 11
0 "Last chapter" 42
The 0 defines the level. The text inside "" the name of the bookmark and the last number is to which page number the bookmark has as destination.
My resulting file should then be one pdf, where the bookmarks destination are the first page of each individual file before the merge.
In this example my starting files are named:
001-First chapter.pdf (pagecount 10)
002-Second chapter.pdf (pagecount 31)
003-Last chapter.pdf (pagecount 46)
I can do a bit of javascript, so I think I have an idea of how it should work, but just not how to write the code. Let my try to explain.
The script should look at the pdfs in the job-folder. Loop through all of them to create a text file, where each pdf creates a new line.
The first line should be like:
0 "[Job.NameProper:After=-]" 1
Second line, where the number should be replaced with the pagecount of the first-file +1:
0 "[Job.NameProper:After=-]" number
Third line, where the number should be replaced with the number from the second line + the second files pagecount:
0 "[Job.NameProper:After=-]" number
And it should go through all the files in the job-folder.
So in my example the resulting text file should look like this.
0 "First chapter" 1
0 "Second chapter" 11
0 "Last chapter" 42
The text-file should the be saved with the job-folder name.
Later on I would then use the execute command to make Coherent PDF add to bookmarks to my file from the created text-file.
I have looked at the forum and made a script, which just creates a single text-file of each pdf, but there are no adding up of the pagecount.
I used this as the source of the script: http://www.crossroads-world.com/en/Home ... posts&t=32
I hope this makes sense and somebody can help, or then please contact me.