Question

Solution is in last comment, but just in case if anyone is looking for workaround I summarized it here: http://sourceforge.net/mailarchive/message.php?msg_id=30391589


I managed to build GSDjVu with MinGW and current stable GhostScript (9.06). Quest in transforming Bash scripts to CMD wasn't so hard, but I was surprised that gsdjvu (gs interpreter with gsdjvu driver) doesn't accept PDF for input as expected. It accepts only PostScript. To avoid writing huge temp files I thought to make a pipeline, and here is example:

set args=-sstdout=nul -dSAFER -dNOPAUSE -dBATCH

gs %args% -sDEVICE=pswrite -sOutputFile=- test.pdf |^
   gsdjvu %args% -sDEVICE=djvusep -sOutputFile=- - |^
   csepdjvu - test.djvu

Which results in error:

*** csepdjvu: corrupted input file (lost RLE sync.)
*** (..\..\..\tools\csepdjvu.cpp:647)

Internal error at ./base/gdevdjvu.c:2831

 
If I output the result of gsdjvu to a file instead pipe, then there is no error:

gs %args% -sDEVICE=pswrite -sOutputFile=- test.pdf |^
   gsdjvu %args% -sDEVICE=djvusep -sOutputFile=test.sep -

csepdjvu test.sep test.djvu

 
Now if I compare file output from gsdjvu (test.sep) and pipe output from same (test2.sep):

gs %args% -sDEVICE=pswrite -sOutputFile=- test.pdf |^
   gsdjvu %args% -sDEVICE=djvusep -sOutputFile=- - > test2.sep

I get this diff:

screenshot

which after trivial analyses reveals that 0A is represented in piped output as 0D0A, or "line endings" are changed from Unix LF to Windows CRLF.

Why can this be, and is there a way to remedy it?
Or maybe it is a bug?

Was it helpful?

Solution

I'm not sure how DjVuLibre can fail to accept PDF as an input, since as far as I know it is a Ghostscript device. Do you have some documentation that says this can't be done ? If so, I would complain to the maintainers, I can't see any reason for this.

Since this works with file output, the logical answer is that there is some newline translation going on.

Some quick googling reveals that there is a lot of discussion about this, but I can't see anything which precisely matches your experience. You should probably tag this for MingW or more sensibly take it to a MingW support forum.

Or just stop piping the I/O around.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top