Skip to content

Commit 971fe50

Browse files
committed
fixed #714: use binary mode when generating pdf to stdout on Windows
1 parent 5dfce74 commit 971fe50

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/api/tesseractmain.cpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@
3535
#include "strngs.h"
3636
#include "tprintf.h"
3737

38-
#if defined(HAVE_TIFFIO_H) && defined(_WIN32)
38+
#if defined(_WIN32)
39+
#include <fcntl.h>
40+
#include <io.h>
41+
#if defined(HAVE_TIFFIO_H)
3942

4043
#include <tiffio.h>
4144

@@ -49,7 +52,8 @@ static void Win32WarningHandler(const char* module, const char* fmt,
4952
fprintf(stderr, ".\n");
5053
}
5154

52-
#endif /* HAVE_TIFFIO_H && _WIN32 */
55+
#endif /* HAVE_TIFFIO_H */
56+
#endif // _WIN32
5357

5458
static void PrintVersionInfo() {
5559
char* versionStrP;
@@ -401,6 +405,10 @@ static void PreloadRenderers(
401405

402406
api->GetBoolVariable("tessedit_create_pdf", &b);
403407
if (b) {
408+
#ifdef WIN32
409+
if (_setmode(_fileno(stdout), _O_BINARY) == -1)
410+
tprintf("ERROR: cin to binary: %s", strerror(errno));
411+
#endif // WIN32
404412
bool textonly;
405413
api->GetBoolVariable("textonly_pdf", &textonly);
406414
int jpg_quality;

0 commit comments

Comments
 (0)