Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

A problem about oberdiek's pdfcrop.pl

6 views
Skip to first unread message

Hsiao-nan Cheung

unread,
Jul 21, 2008, 12:42:23 PM7/21/08
to
Hi, when I use oberdiek's powerfull perl script "pdfcrop" I've met a
problem. The script gives a prompt as

PDFCROP 1.10, 2008/07/16 - Copyright (c) 2002-2008 by Heiko Oberdiek.
'-' is not recognized as an internal or external command,
operable program or batch file.
!!! Error: Execution of ghostscript failed: 256

What do these mean? I cannot use the tool totally.

Thanks.

Heiko Oberdiek

unread,
Jul 21, 2008, 5:21:09 PM7/21/08
to
Hsiao-nan Cheung <nihe...@gmail.com> wrote:

Get a better Perl port. The implementation of open("-|") is broken,
if I understand the Perl documentation correctly.
My developing environment is Linux, thus it's difficult for me
to try alternatives for the broken Perl ports on Windows.

Yours sincerely
Heiko <ober...@uni-freiburg.de>

Hsiao-nan Cheung

unread,
Jul 22, 2008, 12:32:43 AM7/22/08
to
On Jul 22, 5:21 am, Heiko Oberdiek <oberd...@uni-freiburg.de> wrote:
>   Heiko <oberd...@uni-freiburg.de>

Thanks Heiko~

But I still cannot get it works after my reinstalling Perl port. I use
ActivePeal v5.10.0.1003 as my port, and this is the recommand port in
CPAN. Is there any better alternatives for this distribution?
BTW, your former PDFCROPER v1.5.1 works pretty fine here, though lack
of some usefull functions, it's a good alternative for this newer
pdfcrop.pl.

Yours
Hsiao-nan Cheung

Christian Stapfer

unread,
Jul 22, 2008, 2:43:10 AM7/22/08
to
"Heiko Oberdiek" <ober...@uni-freiburg.de> schrieb im Newsbeitrag
news:g62uk5$ct6$1...@news.belwue.de...

> Hsiao-nan Cheung <nihe...@gmail.com> wrote:
>
>> Hi, when I use oberdiek's powerfull perl script "pdfcrop" I've met a
>> problem. The script gives a prompt as
>>
>> PDFCROP 1.10, 2008/07/16 - Copyright (c) 2002-2008 by Heiko Oberdiek.
>> '-' is not recognized as an internal or external command,
>> operable program or batch file.
>> !!! Error: Execution of ghostscript failed: 256
>>
>> What do these mean? I cannot use the tool totally.
>
> Get a better Perl port.

How can the *port* be considered to be broken if the Perl
documentation itself (*not* the documentation of the port)
acknowledges the limitation (see: http://perldoc.perl.org/perlfork.html)?

> The implementation of open("-|") is broken,

According to http://perldoc.perl.org/perlfork.html Perl 5.10.0 does
*not* implement open("-|") at all. Maybe one needs a later version
of Perl, not just another port of Perl 5.10.0?

Heiko Oberdiek

unread,
Jul 22, 2008, 4:24:08 AM7/22/08
to
"Christian Stapfer" <nob...@nowhere.nil> wrote:

open("-|") is described in my very old book of Perl:
L. Wall, T. Christiansen, R.L. Schwartz, "Programming Perl", O'Reilly
& Associates, Inc., 2nd edition, 1996.

Many thanks for pointing me to the perlfork documentation.
It says:

| Forking pipe open() not yet implemented
|
| The open(FOO, "|-") and open(BAR, "-|") constructs
| are not yet implemented.

Thus it *is* a deficiency of the "newer" Perl versions
since 5.8.0.

But the page describes a workaround;

| This limitation can be easily worked around in new code
| by creating a pipe explicitly.

I will look at it, thus there is hope for pdfcrop.
And if I fail, there is another hope:

| Forking pipe open() constructs will be supported in future.

Yours sincerely
Heiko <ober...@uni-freiburg.de>

Heiko Oberdiek

unread,
Jul 22, 2008, 5:16:17 AM7/22/08
to
Heiko Oberdiek <ober...@uni-freiburg.de> wrote:

> "Christian Stapfer" <nob...@nowhere.nil> wrote:
>
> > (see: http://perldoc.perl.org/perlfork.html)?

> Many thanks for pointing me to the perlfork documentation.
> It says:

> But the page describes a workaround;
>
> | This limitation can be easily worked around in new code
> | by creating a pipe explicitly.
>
> I will look at it, thus there is hope for pdfcrop.

Update of pdfcrop v1.11 is on its way to CTAN, please test.

Yours sincerely
Heiko <ober...@uni-freiburg.de>

Martin Heller

unread,
Jul 22, 2008, 5:37:41 AM7/22/08
to
Heiko Oberdiek skrev:

>
> Thus it *is* a deficiency of the "newer" Perl versions
> since 5.8.0.

pdfcrop seems to work fine with Perl 5.10.0 shipping with Cygwin:


C:\DOCUME~1\mhe\Desktop\test>perl -v

This is perl, v5.10.0 built for cygwin-thread-multi-64int
(with 6 registered patches, see perl -V for more detail)

Copyright 1987-2007, Larry Wall

C:\DOCUME~1\mhe\Desktop\test>perl pdfcrop.pl --help


PDFCROP 1.10, 2008/07/16 - Copyright (c) 2002-2008 by Heiko Oberdiek.

C:\test>perl pdfcrop.pl test.pdf


PDFCROP 1.10, 2008/07/16 - Copyright (c) 2002-2008 by Heiko Oberdiek.

==> 1 page written on `test-crop.pdf'.

Hsiao-nan Cheung

unread,
Jul 22, 2008, 11:59:30 AM7/22/08
to
On Jul 22, 5:16 pm, Heiko Oberdiek <oberd...@uni-freiburg.de> wrote:
>   Heiko <oberd...@uni-freiburg.de>

This time it halts during its run.... No output, no end, but only a
tmp-pdfcrop-xxxxx.tex ^_^

Heiko Oberdiek

unread,
Jul 22, 2008, 12:32:46 PM7/22/08
to
Hsiao-nan Cheung <nihe...@gmail.com> wrote:

Result of --verbose and --debug?
Ghostscript can process the PDF file?

Yours sincerely
Heiko <ober...@uni-freiburg.de>

Message has been deleted

Hsiao-nan Cheung

unread,
Jul 22, 2008, 2:22:00 PM7/22/08
to
On Jul 23, 12:32 am, Heiko Oberdiek <oberd...@uni-freiburg.de> wrote:
>   Heiko <oberd...@uni-freiburg.de>- Hide quoted text -
>
> - Show quoted text -

None of these parameters.... It just like

D:\MiKTeX 2.7\scripts\pdfcrop\perl>pdfcrop xmu.pdf
PDFCROP 1.11, 2008/07/22 - Copyright (c) 2002-2008 by Heiko Oberdiek.


And then no response.

I've test my gs, it's okay.

Yours
Hsiao-nan


Heiko Oberdiek

unread,
Jul 22, 2008, 6:12:32 PM7/22/08
to
Hsiao-nan Cheung <nihe...@gmail.com> wrote:

> > Result of --verbose and --debug?
> > Ghostscript can process the PDF file?
>

> None of these parameters.... It just like

These parameters are *VERY* important, because
they provide additional information for finding the
cause of your problem.

> D:\MiKTeX 2.7\scripts\pdfcrop\perl>pdfcrop xmu.pdf
> PDFCROP 1.11, 2008/07/22 - Copyright (c) 2002-2008 by Heiko Oberdiek.
>
>
> And then no response.
>
> I've test my gs, it's okay.

Option --debug prints the comand line call of ghostscript.
Try it. Does it work and prints %%BoundingBox lines?

Anyway, the workaround has lots of disadvantages (error
detection, ...). I had to add workarounds for the workaround. :-(

pdfcrop 1.12 is on its way to CTAN, please test again.

Yours sincerely
Heiko <ober...@uni-freiburg.de>

Hsiao-nan Cheung

unread,
Jul 22, 2008, 9:44:27 PM7/22/08
to
On Jul 23, 6:12 am, Heiko Oberdiek <oberd...@uni-freiburg.de> wrote:
>   Heiko <oberd...@uni-freiburg.de>

I'm really sorry.... Due to my misunderstanding, I didn't add those
parameters...
I cannot find pdfcrop v1.12 on CTAN yet, maybe I'm looking at it on a
wrong mirror?

Here is v1.11's screen print:

D:\MiKTeX 2.7\scripts\pdfcrop\perl>pdfcrop --verbose --debug xmu.pdf


PDFCROP 1.11, 2008/07/22 - Copyright (c) 2002-2008 by Heiko Oberdiek.

* Input file: xmu.pdf
* Output file: xmu-crop.pdf
* Margins: 0 0 0 0
* Running ghostscript for BoundingBox calculation ...
* Ghostscript call: mgs -sDEVICE=bbox -dBATCH -dNOPAUSE -c save pop -f
xmu.pdf

When I call pdfcrop --verbose --debug --gscmd gswin32c xmu.pdf, it is

PDFCROP 1.11, 2008/07/22 - Copyright (c) 2002-2008 by Heiko Oberdiek.

* Input file: xmu.pdf
* Output file: xmu-crop.pdf
* Margins: 0 0 0 0
* Running ghostscript for BoundingBox calculation ...
* Ghostscript call: gswin32c -sDEVICE=bbox -dBATCH -dNOPAUSE -c save
pop -f xmu.pdf

Sincerely Greeting
Hsiao-nan

Heiko Oberdiek

unread,
Jul 22, 2008, 10:35:29 PM7/22/08
to
Hsiao-nan Cheung <nihe...@gmail.com> wrote:

> I cannot find pdfcrop v1.12 on CTAN yet, maybe I'm looking at it on a
> wrong mirror?

The upload procedure for CTAN is too slow. For a short time pdfcrop.pl
is now available at:
http://www.informatik.uni-freiburg.de/~oberdiek/tmp/pdfcrop.pl

> * Running ghostscript for BoundingBox calculation ...
> * Ghostscript call: mgs -sDEVICE=bbox -dBATCH -dNOPAUSE -c save pop -f
> xmu.pdf
>
> When I call pdfcrop --verbose --debug --gscmd gswin32c xmu.pdf, it is

> * Running ghostscript for BoundingBox calculation ...


> * Ghostscript call: gswin32c -sDEVICE=bbox -dBATCH -dNOPAUSE -c save
> pop -f xmu.pdf

Thanks. I have added a "waitpid" in v1.12, perhaps this helps.

Yours sincerely
Heiko <ober...@uni-freiburg.de>

Hsiao-nan Cheung

unread,
Jul 22, 2008, 11:49:14 PM7/22/08
to
On Jul 23, 10:35 am, Heiko Oberdiek <oberd...@uni-freiburg.de> wrote:
>   Heiko <oberd...@uni-freiburg.de>

It still halts at the same place. Maybe I've mentioned before, the
pdfcroper v1.5.1 works fine. From changelog,
2005/03/11 v1.7: Support of spaces in file names
(open("-|") is used for ghostscript call).
And is it the prob?

Thanks a lot^_^

Yours
Hsiao-nan

Heiko Oberdiek

unread,
Jul 23, 2008, 1:43:26 AM7/23/08
to
Hsiao-nan Cheung <nihe...@gmail.com> wrote:

> It still halts at the same place. Maybe I've mentioned before, the
> pdfcroper v1.5.1 works fine. From changelog,
> 2005/03/11 v1.7: Support of spaces in file names
> (open("-|") is used for ghostscript call).
> And is it the prob?

No, Perl is the problem, newer versions do not support
open("-|") any more in a portable way. And obviously
the workaround, given in the documenation isn't working.

Yours sincerely
Heiko <ober...@uni-freiburg.de>

Hsiao-nan Cheung

unread,
Jul 23, 2008, 10:47:38 AM7/23/08
to
On Jul 23, 1:43 pm, Heiko Oberdiek <oberd...@uni-freiburg.de> wrote:
>   Heiko <oberd...@uni-freiburg.de>

Then what should I do is waiting for a newer Perl that support
open("-|")? Then now let me turn back to the v1.51...

Thanks a lot, Heiko ^_^

Yours
Hsiao-nan

Heiko Oberdiek

unread,
Jul 23, 2008, 1:28:58 PM7/23/08
to
Hsiao-nan Cheung <nihe...@gmail.com> wrote:

> On Jul 23, 1:43 pm, Heiko Oberdiek <oberd...@uni-freiburg.de> wrote:
> > Hsiao-nan Cheung <nihea...@gmail.com> wrote:
> > > It still halts at the same place. Maybe I've mentioned before, the
> > > pdfcroper v1.5.1 works fine. From changelog,
> > > 2005/03/11 v1.7:  Support of spaces in file names
> > >                   (open("-|") is used for ghostscript call).
> > > And is it the prob?
> >
> > No, Perl is the problem, newer versions do not support
> > open("-|") any more in a portable way. And obviously
> > the workaround, given in the documenation isn't working.
> >

> Then what should I do is waiting for a newer Perl that support
> open("-|")? Then now let me turn back to the v1.51...

No need, next version v1.13 is on its way to CTAN
(the temporary place is already updated, see one of
my previous postings).

I have removed the open("-|") and fork() stuff and replaced it by
the method of 1.5. The problems there (spaces, unknown shell
behaviour in open-pipe call, ...) are solved by linking/copying
unsafe file names to a temporary file with safe file name.

Yours sincerely
Heiko <ober...@uni-freiburg.de>

Hsiao-nan Cheung

unread,
Jul 24, 2008, 12:18:46 AM7/24/08
to
>   Heiko <oberd...@uni-freiburg.de>

lol, it finally works~~
Thank you VERY VERY much, for solving my such a problem.

Yours
Hsiao-nan

Christian Stapfer

unread,
Jul 24, 2008, 3:52:53 AM7/24/08
to
"Heiko Oberdiek" <ober...@uni-freiburg.de> schrieb im Newsbeitrag
news:g67poo$1h6$1...@news.belwue.de...

Oh, great, .. yes it works on my system (Vista/ActivePerl/MikTeX), too:
many thanks! (And my apologies for having provided the link
to the open("-|")-fix that apparently does not work).

Regards,
Christian Stapfer

Joseph Wright

unread,
Jul 24, 2008, 4:14:19 AM7/24/08
to
Christian Stapfer wrote:
>
> Oh, great, .. yes it works on my system (Vista/ActivePerl/MikTeX), too:
> many thanks! (And my apologies for having provided the link
> to the open("-|")-fix that apparently does not work).

Also now working here: WinXP Pro, MikTeX 2.7, perl 5.10.0 (ActivePerl)
--
Joseph Wright

Heiko Oberdiek

unread,
Jul 24, 2008, 6:03:08 AM7/24/08
to
"Christian Stapfer" <nob...@nowhere.nil> wrote:

Thanks to all for their feedback.

> many thanks! (And my apologies for having provided the link
> to the open("-|")-fix that apparently does not work).

That's not your fault. Thanks anyway.
Portability is a very difficult matter and
file names with special characters are evil.

Yours sincerely
Heiko <ober...@uni-freiburg.de>

Victor Ivrii

unread,
Jul 24, 2008, 9:58:00 PM7/24/08
to
On Jul 24, 7:03 pm, Heiko Oberdiek <oberd...@uni-freiburg.de> wrote:

> Portability is a very difficult matter and
> file names with special characters are evil.
>

And Evil has too many Priests and Followers and they are very
resourceful :-)
I feel a kind of guilt that pdfcrop never broke for me :-)

Victor

0 new messages