Skip to content

Commit

Permalink
fixed #714: use binary mode when generating pdf to stdout on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
zdenop committed Sep 27, 2018
1 parent 5dfce74 commit 971fe50
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/api/tesseractmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@
#include "strngs.h"
#include "tprintf.h"

#if defined(HAVE_TIFFIO_H) && defined(_WIN32)
#if defined(_WIN32)
#include <fcntl.h>
#include <io.h>
#if defined(HAVE_TIFFIO_H)

#include <tiffio.h>

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

#endif /* HAVE_TIFFIO_H && _WIN32 */
#endif /* HAVE_TIFFIO_H */
#endif // _WIN32

static void PrintVersionInfo() {
char* versionStrP;
Expand Down Expand Up @@ -401,6 +405,10 @@ static void PreloadRenderers(

api->GetBoolVariable("tessedit_create_pdf", &b);
if (b) {
#ifdef WIN32
if (_setmode(_fileno(stdout), _O_BINARY) == -1)
tprintf("ERROR: cin to binary: %s", strerror(errno));
#endif // WIN32
bool textonly;
api->GetBoolVariable("textonly_pdf", &textonly);
int jpg_quality;
Expand Down

0 comments on commit 971fe50

Please sign in to comment.