Bug 694954 - corrupted data output
Summary: corrupted data output
Status: RESOLVED FIXED
Alias: None
Product: MuPDF
Classification: Unclassified
Component: mupdf (show other bugs)
Version: 1.3
Hardware: PC Windows XP
: P4 critical
Assignee: MuPDF bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-15 20:45 UTC by Suntor
Modified: 2014-04-15 08:19 UTC (History)
1 user (show)

See Also:
Customer:
Word Size: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Suntor 2014-01-15 20:45:52 UTC
Win version mutool.exe from mupdf-1.3-windows.zip.

I tried to extract raw stream data from PDF file with cmd:

'mutool show -b -e src.pdf 7 > 7obj'

but data in 7obj file was corrupted.
All LF symbols were replaced by a pair of CR,LF symbols.
So I decided it was because of the wrong mode of 'stdout'.
By default, 'stdout' mode is _O_TEXT, but for correct output it must be a _O_BINARY.

I downloaded the mupdf-1.3-source.tar.gz source archive and corrected the following in it:

[\mupdf-1.3-source\source\tools\pdfshow.c, line 100]:
In func showstream(int num, int gen), add these lines:

if (showbinary)
	if (-1 == _setmode(_fileno(stdout), _O_BINARY))
		perror("ERROR: Cannot set 'stdout' mode to binary.\n");

As you see, only "-b -e" combination affected. The output for "-b" or "-e" alone wasn't changed. This code for Win version only!

mutool now works properly.

Sorry for my English...
CY, Suntor, Russia
Comment 1 Tor Andersson 2014-04-15 08:19:45 UTC
Use the mutool show -o option (new in version 1.4) to specify an output file instead of using file redirection on windows.