Ghostscript add Header Page to Split Document Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election Results Why I closed the “Why is Kali so hard” questionHow to create a single page PDF file out of multiple EPS files with GhostScriptHow to update ghostscriptSplitting a PDF file with Ghostscript results in one extra blank pageBash scripting to scan files for words and create reportHow to add printer to CUPS using Ghostscript hl7x0 driver?Ghostscript + QPDF and PDF/A-1b validation: how to add EOL separator before endstreamsAdd black border around PDF file with ghostscriptGenerating PDF handouts with ghostscriptghostscript changes orientation of PDFPDF is corrupted after compressing with Ghostscript
How to retrograde a note sequence in Finale?
How do I automatically answer y in bash script?
3 doors, three guards, one stone
Need a suitable toxic chemical for a murder plot in my novel
Can I throw a sword that doesn't have the Thrown property at someone?
What's the difference between (size_t)-1 and ~0?
Simulating Exploding Dice
Problem when applying foreach loop
Cold is to Refrigerator as warm is to?
Can a monk deflect thrown melee weapons?
What to do with post with dry rot?
What's the point in a preamp?
What is the largest species of polychaete?
How is simplicity better than precision and clarity in prose?
What are the performance impacts of 'functional' Rust?
Stars Make Stars
Statistical model of ligand substitution
Do working physicists consider Newtonian mechanics to be "falsified"?
Was credit for the black hole image misattributed?
Can the prologue be the backstory of your main character?
Why does tar appear to skip file contents when output file is /dev/null?
What would be Julian Assange's expected punishment, on the current English criminal law?
What items from the Roman-age tech-level could be used to deter all creatures from entering a small area?
Windows 10: How to Lock (not sleep) laptop on lid close?
Ghostscript add Header Page to Split Document
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Community Moderator Election Results
Why I closed the “Why is Kali so hard” questionHow to create a single page PDF file out of multiple EPS files with GhostScriptHow to update ghostscriptSplitting a PDF file with Ghostscript results in one extra blank pageBash scripting to scan files for words and create reportHow to add printer to CUPS using Ghostscript hl7x0 driver?Ghostscript + QPDF and PDF/A-1b validation: how to add EOL separator before endstreamsAdd black border around PDF file with ghostscriptGenerating PDF handouts with ghostscriptghostscript changes orientation of PDFPDF is corrupted after compressing with Ghostscript
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have a script using Ghostscript, to split PDF's, then merge them based on a set amount of pages. Is their anyway once the new merged document is created to then add a page to the beginning of the PDF, that says Part 1 of 2 or something like that, using Ghostscript, since it's what I have to do PDF manipulation.
for file in /mnt/bridge/pdfsplit/staging/*.pdf
do
echo $file
#Splits All the Files
gs -q -dNOPAUSE -sDEVICE=pdfwrite -o tmp_%04d.pdf $file
#Removes Last File in List; Ghostscript creates a blank file everytime it splits
find /mnt/bridge/pdfsplit/ -name "tmp*" | tail -1 | while read filename ; do rm $filename; done
pageCount=$(find . -name "tmp*" | wc -l)
documents=$(((pageCount / 998) + (pageCount % 998 > 0)))
pages=$(((pageCount/documents) + (pageCount % documents > 0 )))
for ((i=1; i<$pageCount; i++)); do
list=$(ls -1 tmp* 2>/dev/null | head -$pages)
count=$(ls -1 tmp* 2>/dev/null| wc -l)
gs -q -dNOPAUSE -sDEVICE=pdfwrite -o /mnt/bridge/pdfsplit/splitFiles/$(basename $file | cut -d. -f1)_Part_$(printf %04d $i).pdf -dBATCH $list
rm -f $list
echo "Part $i of $documents"
if [[ $count -eq 0 ]]; then
echo "Done"
break
fi
done
#Removes Last File in List; Ghostscript is creating a blank file
find /mnt/bridge/pdfsplit/splitFiles/ -name "*.pdf" | tail -1 | while read filename ; do rm $filename; done
done
shell-script ghostscript
add a comment |
I have a script using Ghostscript, to split PDF's, then merge them based on a set amount of pages. Is their anyway once the new merged document is created to then add a page to the beginning of the PDF, that says Part 1 of 2 or something like that, using Ghostscript, since it's what I have to do PDF manipulation.
for file in /mnt/bridge/pdfsplit/staging/*.pdf
do
echo $file
#Splits All the Files
gs -q -dNOPAUSE -sDEVICE=pdfwrite -o tmp_%04d.pdf $file
#Removes Last File in List; Ghostscript creates a blank file everytime it splits
find /mnt/bridge/pdfsplit/ -name "tmp*" | tail -1 | while read filename ; do rm $filename; done
pageCount=$(find . -name "tmp*" | wc -l)
documents=$(((pageCount / 998) + (pageCount % 998 > 0)))
pages=$(((pageCount/documents) + (pageCount % documents > 0 )))
for ((i=1; i<$pageCount; i++)); do
list=$(ls -1 tmp* 2>/dev/null | head -$pages)
count=$(ls -1 tmp* 2>/dev/null| wc -l)
gs -q -dNOPAUSE -sDEVICE=pdfwrite -o /mnt/bridge/pdfsplit/splitFiles/$(basename $file | cut -d. -f1)_Part_$(printf %04d $i).pdf -dBATCH $list
rm -f $list
echo "Part $i of $documents"
if [[ $count -eq 0 ]]; then
echo "Done"
break
fi
done
#Removes Last File in List; Ghostscript is creating a blank file
find /mnt/bridge/pdfsplit/splitFiles/ -name "*.pdf" | tail -1 | while read filename ; do rm $filename; done
done
shell-script ghostscript
add a comment |
I have a script using Ghostscript, to split PDF's, then merge them based on a set amount of pages. Is their anyway once the new merged document is created to then add a page to the beginning of the PDF, that says Part 1 of 2 or something like that, using Ghostscript, since it's what I have to do PDF manipulation.
for file in /mnt/bridge/pdfsplit/staging/*.pdf
do
echo $file
#Splits All the Files
gs -q -dNOPAUSE -sDEVICE=pdfwrite -o tmp_%04d.pdf $file
#Removes Last File in List; Ghostscript creates a blank file everytime it splits
find /mnt/bridge/pdfsplit/ -name "tmp*" | tail -1 | while read filename ; do rm $filename; done
pageCount=$(find . -name "tmp*" | wc -l)
documents=$(((pageCount / 998) + (pageCount % 998 > 0)))
pages=$(((pageCount/documents) + (pageCount % documents > 0 )))
for ((i=1; i<$pageCount; i++)); do
list=$(ls -1 tmp* 2>/dev/null | head -$pages)
count=$(ls -1 tmp* 2>/dev/null| wc -l)
gs -q -dNOPAUSE -sDEVICE=pdfwrite -o /mnt/bridge/pdfsplit/splitFiles/$(basename $file | cut -d. -f1)_Part_$(printf %04d $i).pdf -dBATCH $list
rm -f $list
echo "Part $i of $documents"
if [[ $count -eq 0 ]]; then
echo "Done"
break
fi
done
#Removes Last File in List; Ghostscript is creating a blank file
find /mnt/bridge/pdfsplit/splitFiles/ -name "*.pdf" | tail -1 | while read filename ; do rm $filename; done
done
shell-script ghostscript
I have a script using Ghostscript, to split PDF's, then merge them based on a set amount of pages. Is their anyway once the new merged document is created to then add a page to the beginning of the PDF, that says Part 1 of 2 or something like that, using Ghostscript, since it's what I have to do PDF manipulation.
for file in /mnt/bridge/pdfsplit/staging/*.pdf
do
echo $file
#Splits All the Files
gs -q -dNOPAUSE -sDEVICE=pdfwrite -o tmp_%04d.pdf $file
#Removes Last File in List; Ghostscript creates a blank file everytime it splits
find /mnt/bridge/pdfsplit/ -name "tmp*" | tail -1 | while read filename ; do rm $filename; done
pageCount=$(find . -name "tmp*" | wc -l)
documents=$(((pageCount / 998) + (pageCount % 998 > 0)))
pages=$(((pageCount/documents) + (pageCount % documents > 0 )))
for ((i=1; i<$pageCount; i++)); do
list=$(ls -1 tmp* 2>/dev/null | head -$pages)
count=$(ls -1 tmp* 2>/dev/null| wc -l)
gs -q -dNOPAUSE -sDEVICE=pdfwrite -o /mnt/bridge/pdfsplit/splitFiles/$(basename $file | cut -d. -f1)_Part_$(printf %04d $i).pdf -dBATCH $list
rm -f $list
echo "Part $i of $documents"
if [[ $count -eq 0 ]]; then
echo "Done"
break
fi
done
#Removes Last File in List; Ghostscript is creating a blank file
find /mnt/bridge/pdfsplit/splitFiles/ -name "*.pdf" | tail -1 | while read filename ; do rm $filename; done
done
shell-script ghostscript
shell-script ghostscript
edited Apr 11 at 14:25
Josh Adams
asked Apr 10 at 19:37
Josh AdamsJosh Adams
336
336
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f511745%2fghostscript-add-header-page-to-split-document%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f511745%2fghostscript-add-header-page-to-split-document%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown