mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-12-04 18:29:06 +08:00
Merge pull request #1813 from stweil/fix
TessPDFRenderer: Improve robustness of API (issue #1804)
This commit is contained in:
commit
10259698d8
@ -182,9 +182,9 @@ static const int kMaxBytesPerCodepoint = 20;
|
|||||||
|
|
||||||
TessPDFRenderer::TessPDFRenderer(const char *outputbase, const char *datadir,
|
TessPDFRenderer::TessPDFRenderer(const char *outputbase, const char *datadir,
|
||||||
bool textonly)
|
bool textonly)
|
||||||
: TessResultRenderer(outputbase, "pdf") {
|
: TessResultRenderer(outputbase, "pdf"),
|
||||||
|
datadir_(datadir) {
|
||||||
obj_ = 0;
|
obj_ = 0;
|
||||||
datadir_ = datadir;
|
|
||||||
textonly_ = textonly;
|
textonly_ = textonly;
|
||||||
offsets_.push_back(0);
|
offsets_.push_back(0);
|
||||||
}
|
}
|
||||||
@ -654,7 +654,7 @@ bool TessPDFRenderer::BeginDocumentHandler() {
|
|||||||
if (n >= sizeof(buf)) return false;
|
if (n >= sizeof(buf)) return false;
|
||||||
AppendPDFObject(buf);
|
AppendPDFObject(buf);
|
||||||
|
|
||||||
n = snprintf(buf, sizeof(buf), "%s/pdf.ttf", datadir_);
|
n = snprintf(buf, sizeof(buf), "%s/pdf.ttf", datadir_.c_str());
|
||||||
if (n >= sizeof(buf)) return false;
|
if (n >= sizeof(buf)) return false;
|
||||||
FILE *fp = fopen(buf, "rb");
|
FILE *fp = fopen(buf, "rb");
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
// To avoid collision with other typenames include the ABSOLUTE MINIMUM
|
// To avoid collision with other typenames include the ABSOLUTE MINIMUM
|
||||||
// complexity of includes here. Use forward declarations wherever possible
|
// complexity of includes here. Use forward declarations wherever possible
|
||||||
// and hide includes of complex types in baseapi.cpp.
|
// and hide includes of complex types in baseapi.cpp.
|
||||||
|
#include <string> // for std::string
|
||||||
#include "genericvector.h"
|
#include "genericvector.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
|
||||||
@ -202,7 +203,7 @@ class TESS_API TessPDFRenderer : public TessResultRenderer {
|
|||||||
long int obj_; // counter for PDF objects
|
long int obj_; // counter for PDF objects
|
||||||
GenericVector<long int> offsets_; // offset of every PDF object in bytes
|
GenericVector<long int> offsets_; // offset of every PDF object in bytes
|
||||||
GenericVector<long int> pages_; // object number for every /Page object
|
GenericVector<long int> pages_; // object number for every /Page object
|
||||||
const char *datadir_; // where to find the custom font
|
std::string datadir_; // where to find the custom font
|
||||||
bool textonly_; // skip images if set
|
bool textonly_; // skip images if set
|
||||||
// Bookkeeping only. DIY = Do It Yourself.
|
// Bookkeeping only. DIY = Do It Yourself.
|
||||||
void AppendPDFObjectDIY(size_t objectsize);
|
void AppendPDFObjectDIY(size_t objectsize);
|
||||||
|
Loading…
Reference in New Issue
Block a user