Newsgroup: it.comp.os.linux.software
Titolo: Togliere i margini ai pdf

Salve,
ho diversi manuali in pdf che vorrei leggere sul palmare, ma hanno tutti 
un enorme bordo bianco, soprattutto a sinistra e a destra, che mi 
costringe a "centrare" a mano ogni pagina, mentre li leggo.
Esiste un software che, in automatico o quasi, mi elimina i margini e mi 
salva il pdf modificato?
Se riuscisse a rilevare da solo gli spazi bianchi in ogni pagina sarebbe 
meglio (perche` alcuni hanno margini diversi per pagina destra e sinistra, 
per esempio), ma al limite anche con una scarna interfaccia in cui 
seleziono io quanto tagliare.
Grazie.

"
echo " "
sleep 2
echo " "
echo " "
echo "PDFCrop automatically crops the white margins from a PDF document 
and" 
echo "rescales the pages to fit the paper in your printer. It makes the 
printed" 
echo "pages far more attractive to read!"
echo " "
echo "Specifically, this utility will crop the pages down to the size of 
the"
echo "original postscript and scale them up to fit a standard sheet of 
paper."
echo " "
echo "PDFCrop cannot handle PDF files that are more than 10,000 pages 
long, so"
echo "if your PDF file is longer than 10,000 pages, then do NOT answer 
the" 
echo "following questions and the utility will automatically exit."
echo " "
echo " "
echo "Pausing for 3 seconds, so that you can consider those messages."
echo " "
echo " "
sleep 3
echo " "
echo "Here is a list of the PDF files in the current directory:"
echo " "
ls *.pdf
# now let's get the name of the input file and the output file
echo " "
echo -n "Which PDF file would you like me to crop and resize?: "
read infile_name
# exit if the user did not enter anything:
if [ -z "$infile_name" ]; then
    echo " "
    echo "You did not tell me the file name, so I will exit now."
    echo " "
    exit
fi
echo " "
echo -n "What would you like the name of the output file to be?: "
read outfile_name
# exit if the user did not enter anything:
if [ -z "$outfile_name" ]; then
    echo " "
    echo "You did not give me a file name, so I will exit now."
    echo " "
    exit
fi
paper_size_dflt=`cat /etc/papersize`
echo " "
echo "The default paper size is $paper_size_dflt. Press Enter to accept 
this size or"
echo "enter a different size. A few valid sizes are: a4, letter and 
legal." 
echo "For more information see the PAPERSIZE man page."
echo -n "What would you like the paper size to be? (press Enter for 
$paper_size_dflt): "
read paper_size_input
# set paper size to default or user specified:
if [ -z "$paper_size_input" ]; then
    paper_size=$paper_size_dflt
    else paper_size=$paper_size_input
fi
echo " "
echo "How big would you like the white margins to be?"
echo -n "Enter a percentage. If you are unsure pick 5. Do NOT enter the % 
sign!: "
read pct
# exit if the user did not enter anything:
if [ -z "$pct" ]; then
    echo " "
    echo "You did not give me a number, so I will exit now."
    echo " "
    exit
fi
# exit if the user entered the percentage sign
chk_test=`echo "$pct" | grep %` 
if [ -z "$chk_test" ] ; then 
    chk_result="valid" 
    else chk_result="invalid"
fi
if [ $chk_result = "invalid" ]; then 
    echo " "
    echo "I told you not to enter the % sign! I will exit now."
    echo " "
    exit
fi
# if the file names and percentage are OK, then:
echo " "
echo "Ready to crop and resize $infile_name and create $outfile_name."
echo " "
# we'll hide the work in a temporary directory
mkdir tmp_pdf_crop
cp $infile_name tmp_pdf_crop/$infile_name
cd tmp_pdf_crop
# burst the original PDF and obtain the number of pages 
# note that this script requires mawk !!!
pdftk $infile_name burst
cat doc_data.txt | grep NumberOfPages > nu_pages.txt
nu_pages=`mawk '{print $2}' nu_pages.txt`
# start converting pages
x=1 # initialize x
while [ "$x" -le "$nu_pages" ]; do
     if [ "$x" -lt 10 ]; then
         pdf2ps pg_000"$x".pdf
         poster pg_000"$x".ps -c0 -w"$pct"% -m"$paper_size" -
obig_000"$x".ps
         ps2pdf big_000"$x".ps
         echo "Finished page $x of $nu_pages."
         x=$(($x+1))
     elif [ "$x" -lt 100 ]; then
         pdf2ps pg_00"$x".pdf
         poster pg_00"$x".ps -c0 -w"$pct"% -m"$paper_size" -obig_00"$x".ps
         ps2pdf big_00"$x".ps
         echo "Finished page $x of $nu_pages."
         x=$(($x+1))
     elif [ "$x" -lt 1000 ]; then
         pdf2ps pg_0"$x".pdf
         poster pg_0"$x".ps -c0 -w"$pct"% -m"$paper_size" -obig_0"$x".ps
         ps2pdf big_0"$x".ps
         echo "Finished page $x of $nu_pages."
         x=$(($x+1))
     elif [ "$x" -lt 10000 ]; then
         pdf2ps pg_"$x".pdf
         poster pg_"$x".ps -c0 -w"$pct"% -m"$paper_size" -obig_"$x".ps
         ps2pdf big_"$x".ps
         echo "Finished page $x of $nu_pages."
         x=$(($x+1))
     fi
done
# create the new PDF file and move it to the original directory
pdftk  big_*.pdf cat output $outfile_name
cd ..
mv tmp_pdf_crop/$outfile_name $outfile_name
# clean up the mess and exit
rm tmp_pdf_crop/*
rmdir tmp_pdf_crop
echo " "
echo "All done! $outfile_name has been created. Have fun!"
echo " "
exit
-- 
Puppy Linux wiki:  
http://puppylover.netsons.org/dokupuppy
Puppy Linux Forum: 
http://puppylinux.ilbello.com
Windows me genuit, Ubuntu rapuere / tenet nunc Puppy Linux...

 poster pg_000"$x".ps -c0 -w"$pct"% -m"$paper_size" -...
...non riesco a trovare in quale pacchetto debian sia il comando poster. :/
Bye.

 ...non riesco a trovare in quale pacchetto debian sia il comando poster.
OK, sono fuso. Nel pacchetto "poster"... E c'e` anche un pdfposter che 
magari fa la stessa cosa, ora controllo. :)
Bye.

Alessandro Pellizzari ha scritto:

Prova GhostScript.