• Q,: can pdftk do modest cropping or rescaling?

    From tlvp@21:1/5 to All on Sat Jul 1 22:12:08 2017
    Two pdftk usage questions, if I may:

    1) given a multipage input PDF all of whose pages involve 5.5":x8.5" output sheets (with 1" margins all around a 3.5"x6.5" inked block), is there a
    pdftk invocation that will crop that to an output PDF file all of whose
    pages involve 5"x8" output sheets (with 0.75" margins all around that same 3.5"x6.5" inked block)?

    2) given a single-page input PDF, is there a pdftk invocation that will
    deliver as output a PDF file that is essentially the original, rescaled by
    a scaling factor of my choice, between 0.9 and 1.1, with both inked matter
    and underlying output sheet scaled (down or up) by that same factor?

    If so, please offer samples; I've been unable to deduce any such from the
    pdftk documentation.

    Many thanks. Cheers, -- tlvp
    --
    Avant de repondre, jeter la poubelle, SVP.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Peter Flynn@21:1/5 to tlvp on Wed Jul 12 22:40:52 2017
    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA256

    On 07/02/2017 03:12 AM, tlvp wrote:
    Two pdftk usage questions, if I may:

    1) given a multipage input PDF all of whose pages involve
    5.5":x8.5" output sheets (with 1" margins all around a 3.5"x6.5"
    inked block), is there a pdftk invocation that will crop that to an
    output PDF file all of whose pages involve 5"x8" output sheets
    (with 0.75" margins all around that same 3.5"x6.5" inked block)?

    I don't think pdftk does cropping. But pdfcrop will crop by finding
    the minimal inked area, and then adding whatever space you specify, so
    assuming the 3.5"6.5" block is accurate, pdfcrop --margins 54 (margin
    in Adobe points) should work for a single file. So you could use pdftk
    to split the file into pages, crop them, and then reassemble the
    cropped files into a single PDF:

    pdftk yourfile.pdf burst output page_%02d.pdf
    for f in page_*.pdf; do pdfcrop --margins 54 $f; done
    pdftk page_*-crop.pdf cat output newfile.pdf

    2) given a single-page input PDF, is there a pdftk invocation that
    will deliver as output a PDF file that is essentially the
    original, rescaled by a scaling factor of my choice, between 0.9
    and 1.1, with both inked matter and underlying output sheet scaled
    (down or up) by that same factor?

    I don't think pdftk scales either. It looks as if you might be able to
    do it by converting the file to Postscript and using psresize, then
    converting the result back to PDF, eg for a 1.1 scale of an A4
    document (210mm297mm):

    pdf2ps filename.pdf
    psresize -w231mm -h327mm filename.ps filename.eps
    ps2pdf filename.eps filename-1.1.pdf

    But when I tested this, it gave me a file scaled up by 1.1, but
    truncated on the top edge. Maybe a little experimenting is needed.

    You should also look at psbook and psnup, both of which have scaling facilities. They also both require conversion to Postscript but the
    pdf2ps and ps2pdf utilities do this easily.

    ///Peter



    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v2

    iQEcBAEBCAAGBQJZZpdTAAoJEHt9ZfbX6inQtE0H/2D2ljGwA/91bL7pbelm/wJg e3iWRme8VEMNfG29PIq8Ih95S8SiDDs/yK6ytVXWBwV0lyT2bLA62qoYcQKMbV/K H3bnQ3aLQLqW2tK724LXg8G5zU/wCueCRJeuducjUxUbpxsLW0osnnA2swSdVYLw fwM8+2tf1wW7tyrAPzVa89Pe1/rV1+gZ9SUG64FbwcExEmjweaBVPK3j27s+RWrg elOD2TTAfAugzsV63fmcKXLNkJScdFDGAl+Ttk+ddIJHM6mSXQwa5Jwg/583hQuy pNSk558fiMv7hp7Ms1IiWtw9r9/42uUCaTrzxMqaQahsB691knKZg5Q3TxKB5Ow=
    =7gM9
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From tlvp@21:1/5 to Peter Flynn on Tue Jul 18 05:51:53 2017
    On Wed, 12 Jul 2017 22:40:52 +0100, Peter Flynn wrote, with details:

    I don't think pdftk does ... . But ...

    Thanks very much, Peter. All the utilities you mention are new to me, and
    very much bear my looking into: pdfcrop, pdf2ps. psresize, ps2pdf, as well
    as psbook and psnup. All new to me, believe it or not. So thanks again.

    Cheers, -- tlvp
    --
    Avant de repondre, jeter la poubelle, SVP.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From tlvp@21:1/5 to Peter Flynn on Wed Jul 19 05:00:01 2017
    On Wed, 12 Jul 2017 22:40:52 +0100, Peter Flynn wrote:

    ... so
    assuming the 3.5"×6.5" block is accurate, pdfcrop --margins 54 (margin
    in Adobe points) should work ...

    Quick sanity/comprehension check here: by "Adobe points" I take it you mean what others call simply "points" or "printer's points"? I.e., lengths of
    1/72 of an inch (so that 54 of them amount to 3/4 of an inch)?

    Thanks for confirming or correcting, as need may be. Cheers, -- tlvp
    --
    Avant de repondre, jeter la poubelle, SVP.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ivan Shmakov@21:1/5 to All on Sat Jul 22 17:25:44 2017
    Peter Flynn <peter@silmaril.ie> writes:
    On 07/02/2017 03:12 AM, tlvp wrote:

    […]

    2) given a single-page input PDF, is there a pdftk invocation that
    will deliver as output a PDF file that is essentially the original,
    rescaled by a scaling factor of my choice, between 0.9 and 1.1, with
    both inked matter and underlying output sheet scaled (down or up) by
    that same factor?

    I don't think pdftk scales either. It looks as if you might be able
    to do it by converting the file to Postscript and using psresize,
    then converting the result back to PDF, eg for a 1.1 scale of an A4
    document (210mm×297mm):

    pdf2ps filename.pdf
    psresize -w231mm -h327mm filename.ps filename.eps
    ps2pdf filename.eps filename-1.1.pdf

    But when I tested this, it gave me a file scaled up by 1.1, but
    truncated on the top edge. Maybe a little experimenting is needed.

    You should also look at psbook and psnup, both of which have scaling facilities. They also both require conversion to Postscript but the
    pdf2ps and ps2pdf utilities do this easily.

    ISTR that some of these utilities were able to work on .dsc
    files (as produced with pdf2dsc) instead, thus avoiding the need
    for a “full” PDF to PostScript conversion.

    Though perhaps it was just psselect(1).

    --
    FSF associate member #7257 58F8 0F47 53F5 2EB2 F6A5 8916 3013 B6A0 230E 334A

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Peter Flynn@21:1/5 to tlvp on Sat Jul 22 20:27:15 2017
    On 19/07/17 10:00, tlvp wrote:
    On Wed, 12 Jul 2017 22:40:52 +0100, Peter Flynn wrote:

    ... so
    assuming the 3.5"×6.5" block is accurate, pdfcrop --margins 54 (margin
    in Adobe points) should work ...

    Quick sanity/comprehension check here: by "Adobe points" I take it you mean what others call simply "points" or "printer's points"? I.e., lengths of
    1/72 of an inch (so that 54 of them amount to 3/4 of an inch)?

    Yes, as distinct from printers' traditional Anglo-American points, which
    are 72.27 to the inch.

    The difference between an Adobe big-point and the old point is only
    0.27pt per inch, but in 10″ of text (a full page of A4) that’s 2.7pt,
    which is nearly 1mm, enough to be clearly visible if you’re trying to
    align one sample with another.

    ///Peter

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Peter Flynn@21:1/5 to tlvp on Sat Jul 22 20:29:22 2017
    On 18/07/17 10:51, tlvp wrote:
    On Wed, 12 Jul 2017 22:40:52 +0100, Peter Flynn wrote, with details:

    I don't think pdftk does ... . But ...

    Thanks very much, Peter. All the utilities you mention are new to me, and very much bear my looking into: pdfcrop, pdf2ps. psresize, ps2pdf, as well
    as psbook and psnup. All new to me, believe it or not. So thanks again.

    There's a huge number of these command-line utilities for manipulating Postscript and PDF. They are mostly native Unix-based systems (eg Macs
    and GNU/Linux) but they should compile on Windows OK nowadays.

    ///Peter

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From tlvp@21:1/5 to Peter Flynn on Mon Jul 24 03:53:15 2017
    On Sat, 22 Jul 2017 20:27:15 +0100, Peter Flynn wrote:

    ... by "Adobe points" I take it you mean
    what others call simply "points" or "printer's points"? I.e., lengths of
    1/72 of an inch (so that 54 of them amount to 3/4 of an inch)?

    Yes, as distinct from printers' traditional Anglo-American points, which
    are 72.27 to the inch.

    The difference between an Adobe big-point and the old point is only
    0.27pt per inch, but in 10″ of text (a full page of A4) that’s 2.7pt, which is nearly 1mm, enough to be clearly visible if you’re trying to
    align one sample with another.

    Wow! As far back as 1952, when I started out as a printer's devil for my
    local high school newspaper, and long before Adobe ever caught its first
    living breath, what I understood by a point was 1/72nd of an inch, no extra decimal .27 to the total 72 per inch. When did that .27 get added :-) ?

    Cheers, -- tlvp
    --
    Avant de repondre, jeter la poubelle, SVP.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Piet van Oostrum@21:1/5 to tlvp on Wed Jul 26 12:50:09 2017
    tlvp <misc.tlvp@att.net> writes:

    Wow! As far back as 1952, when I started out as a printer's devil for my local high school newspaper, and long before Adobe ever caught its first living breath, what I understood by a point was 1/72nd of an inch, no extra decimal .27 to the total 72 per inch. When did that .27 get added :-) ?

    That value of the printer's point (0.01383 inch) was established in the
    19th century by the ATA (American Type Founders Association). But the
    numerical relationship of 1/72.27 of an inch was recognized by Knuth. In
    fact 1/72.27 is not exactly 0.01383, but the size of an inch has changed slightly in the meantime, and 1/72.27 is the relation with the modern
    inch. This is still an approximation, the difference is 0.1µm. I guess
    it was just sloppiness to use 1/72 of an inch, until Adobe started to
    use that as their official value (also called Postscript point), and now
    it is generally used as the value of a point in typesetting.
    --
    Piet van Oostrum <piet-l@vanoostrum.org>
    WWW: http://piet.vanoostrum.org/
    PGP key: [8DAE142BE17999C4]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From tlvp@21:1/5 to Piet van Oostrum on Thu Jul 27 16:29:03 2017
    On Wed, 26 Jul 2017 12:50:09 +0200, Piet van Oostrum wrote:

    tlvp <misc.tlvp@att.net> writes:

    Wow! As far back as 1952, when I started out as a printer's devil for my
    local high school newspaper, and long before Adobe ever caught its first
    living breath, what I understood by a point was 1/72nd of an inch, no extra >> decimal .27 to the total 72 per inch. When did that .27 get added :-) ?

    That value of the printer's point (0.01383 inch) was established in the
    19th century by the ATA (American Type Founders Association). But the numerical relationship of 1/72.27 of an inch was recognized by Knuth. In
    fact 1/72.27 is not exactly 0.01383, but the size of an inch has changed slightly in the meantime, and 1/72.27 is the relation with the modern
    inch. This is still an approximation, the difference is 0.1µm. I guess
    it was just sloppiness to use 1/72 of an inch, until Adobe started to
    use that as their official value (also called Postscript point), and now
    it is generally used as the value of a point in typesetting.

    Thanks, Piet, for your comprehensive survey of this point business. Little
    did I realize how very rough-and-ready my hal-century-old "72 to the inch" approximation was.

    Cheers, -- tlvp
    --
    Avant de repondre, jeter la poubelle, SVP.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Peter Flynn@21:1/5 to tlvp on Tue Aug 8 20:59:28 2017
    On 27/07/17 21:29, tlvp wrote:
    On Wed, 26 Jul 2017 12:50:09 +0200, Piet van Oostrum wrote:

    Wow! As far back as 1952, when I started out as a printer's
    devil for my local high school newspaper, and long before Adobe
    ever caught its first living breath, what I understood by a point
    was 1/72nd of an inch, no extra decimal .27 to the total 72 per
    inch. When did that .27 get added :-) ?

    It was 72-and-a-bit to the inch when I started composing at high school
    in the UK in the late 60s.

    tlvp <misc.tlvp@att.net> writes:
    [snip useful help]
    I guess it was just sloppiness to use 1/72 of an inch, until Adobe
    started to use that as their official value (also called Postscript
    point), and now it is generally used as the value of a point in
    typesetting.

    I was told that the screen resolution of the day (on a Mac) was exactly
    72dpi, so they made their "big points" 1px = 1pt.

    Thanks, Piet, for your comprehensive survey of this point business.
    Little did I realize how very rough-and-ready my hal-century-old "72
    to the inch" approximation was.

    No, it's very precise, just different. Although I grew up using points
    and picas, I only use points for type size nowadays, as the difference
    between 12pt and 12bp can safely be ignored. For larger dimensions I use
    only cm and mm unless the job has a historical component.

    ///Peter

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From SaGS@21:1/5 to tlvp on Wed Aug 9 00:49:43 2017
    On Sunday, July 2, 2017 at 5:12:08 AM UTC+3, tlvp wrote:
    Two pdftk usage questions, if I may:

    2) given a single-page input PDF, is there a pdftk invocation that will deliver as output a PDF file that is essentially the original, rescaled by
    a scaling factor of my choice, between 0.9 and 1.1, with both inked matter and underlying output sheet scaled (down or up) by that same factor?


    pdftk can be used to do some rescaling, but in a different manner than described above. Its ‘stamp’ and ‘multistamp’ commands scale the stamp(s) to fit the base page. So if you have or create a PDF with blank pages of the desired final size and
    stamp/multistamp the original PDF onto it, you get a new PDF that looks like the original but resized. All without re-authoring the content streams completely as happens with print-to-Postscript-and-then-convert-to-PDF method; for example without
    decompressing-recompressing images which can degrade quality. Other PDF content (bookmarks…) is lost.

    1) given a multipage input PDF … is there a pdftk invocation that will
    crop that to an output PDF file …

    As to cropping, I don't know of any trick to do it with pdftk.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)