1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-12-21 20:50:07 +00:00

Merge pull request #4 from pdf2htmlEX/master

bring stephengaito project inline with the master project
This commit is contained in:
stephengaito 2019-09-23 16:44:43 +01:00 committed by GitHub
commit 00480afec5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 84 additions and 56 deletions

View File

@ -10,7 +10,7 @@ option(ENABLE_SVG "Enable SVG support, for generating SVG background images and
include_directories(${CMAKE_SOURCE_DIR}/src)
set(PDF2HTMLEX_VERSION "0.16.0")
set(PDF2HTMLEX_VERSION "0.18.0")
set(ARCHIVE_NAME pdf2htmlex-${PDF2HTMLEX_VERSION})
add_custom_target(dist
COMMAND git archive --prefix=${ARCHIVE_NAME}/ HEAD

View File

@ -107,8 +107,8 @@ void CairoBackgroundRenderer::init(PDFDoc * doc)
startDoc(doc);
}
static GBool annot_cb(Annot *, void * pflag) {
return (*((bool*)pflag)) ? gTrue : gFalse;
static bool annot_cb(Annot *, void * pflag) {
return (*((bool*)pflag)) ? true : false;
};
bool CairoBackgroundRenderer::render_page(PDFDoc * doc, int pageno)

View File

@ -37,7 +37,7 @@ public:
// Does this device use beginType3Char/endType3Char? Otherwise,
// text in Type 3 fonts will be drawn with drawChar/drawString.
virtual GBool interpretType3Chars() { return !param.process_type3; }
virtual bool interpretType3Chars() { return !param.process_type3; }
virtual void drawChar(GfxState *state, double x, double y,
double dx, double dy,

View File

@ -29,7 +29,7 @@ using std::unique_ptr;
const SplashColor SplashBackgroundRenderer::white = {255,255,255};
SplashBackgroundRenderer::SplashBackgroundRenderer(const string & imgFormat, HTMLRenderer * html_renderer, const Param & param)
: SplashOutputDev(splashModeRGB8, 4, gFalse, (SplashColorPtr)(&white), gTrue, splashThinLineSolid) // DCRH: Make thin line mode = solid
: SplashOutputDev(splashModeRGB8, 4, false, (SplashColorPtr)(&white), true, splashThinLineSolid) // DCRH: Make thin line mode = solid
, html_renderer(html_renderer)
, param(param)
, format(imgFormat)
@ -106,8 +106,8 @@ void SplashBackgroundRenderer::init(PDFDoc * doc)
startDoc(doc);
}
static GBool annot_cb(Annot *, void * pflag) {
return (*((bool*)pflag)) ? gTrue : gFalse;
static bool annot_cb(Annot *, void * pflag) {
return (*((bool*)pflag)) ? true : false;
};
bool SplashBackgroundRenderer::render_page(PDFDoc * doc, int pageno)

View File

@ -37,7 +37,7 @@ public:
// Does this device use beginType3Char/endType3Char? Otherwise,
// text in Type 3 fonts will be drawn with drawChar/drawString.
virtual GBool interpretType3Chars() { return !param.process_type3; }
virtual bool interpretType3Chars() { return !param.process_type3; }
virtual void startPage(int pageNum, GfxState *state, XRef *xrefA);

View File

@ -16,7 +16,34 @@
#include <GfxState.h>
#include <Stream.h>
#include <PDFDoc.h>
#include <goo/gtypes.h>
/************ from goo/gtypes.h ***************/
// #include <goo/gtypes.h>
/*
* These have stupid names to avoid conflicts with some (but not all)
* C++ compilers which define them.
*/
//typedef bool GBool;
//#define gTrue true
//#define gFalse false
//#ifdef _MSC_VER
//#pragma warning(disable: 4800) /* 'type' : forcing value to bool 'true' or 'false' (performance warning) */
//#endif
/*
* These have stupid names to avoid conflicts with <sys/types.h>,
* which on various systems defines some random subset of these.
*/
//typedef unsigned char Guchar;
//typedef unsigned short Gushort;
//typedef unsigned int Guint;
//typedef unsigned long Gulong;
//typedef long long Goffset;
/**********************************************/
#include <Object.h>
#include <GfxFont.h>
#include <Annot.h>
@ -58,28 +85,28 @@ struct HTMLRenderer : OutputDev
// Does this device use upside-down coordinates?
// (Upside-down means (0,0) is the top left corner of the page.)
virtual GBool upsideDown() { return gFalse; }
virtual bool upsideDown() { return false; }
// Does this device use drawChar() or drawString()?
virtual GBool useDrawChar() { return gFalse; }
virtual bool useDrawChar() { return false; }
// Does this device use functionShadedFill(), axialShadedFill(), and
// radialShadedFill()? If this returns false, these shaded fills
// will be reduced to a series of other drawing operations.
virtual GBool useShadedFills(int type) { return (type == 2) ? gTrue: gFalse; }
virtual bool useShadedFills(int type) { return (type == 2) ? true: false; }
// Does this device use beginType3Char/endType3Char? Otherwise,
// text in Type 3 fonts will be drawn with drawChar/drawString.
virtual GBool interpretType3Chars() { return gFalse; }
virtual bool interpretType3Chars() { return false; }
// Does this device need non-text content?
virtual GBool needNonText() { return (param.process_nontext) ? gTrue: gFalse; }
virtual bool needNonText() { return (param.process_nontext) ? true: false; }
// Does this device need to clip pages to the crop box even when the
// box is the crop box?
virtual GBool needClipToCropBox() { return gTrue; }
virtual bool needClipToCropBox() { return true; }
virtual void setDefaultCTM(double *ctm);
virtual void setDefaultCTM(const double *ctm);
// Start a page.
virtual void startPage(int pageNum, GfxState *state, XRef * xref);
@ -128,26 +155,26 @@ struct HTMLRenderer : OutputDev
virtual void drawString(GfxState * state, const GooString * s);
virtual void drawImage(GfxState * state, Object * ref, Stream * str, int width, int height, GfxImageColorMap * colorMap, GBool interpolate, int *maskColors, GBool inlineImg);
virtual void drawImage(GfxState * state, Object * ref, Stream * str, int width, int height, GfxImageColorMap * colorMap, bool interpolate, int *maskColors, bool inlineImg);
virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
int width, int height,
GfxImageColorMap *colorMap,
GBool interpolate,
bool interpolate,
Stream *maskStr,
int maskWidth, int maskHeight,
GfxImageColorMap *maskColorMap,
GBool maskInterpolate);
bool maskInterpolate);
virtual void stroke(GfxState *state);
virtual void fill(GfxState *state);
virtual void eoFill(GfxState *state);
virtual GBool axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax);
virtual bool axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax);
virtual void beginTransparencyGroup(GfxState * /*state*/, double * /*bbox*/,
virtual void beginTransparencyGroup(GfxState * /*state*/, const double * /*bbox*/,
GfxColorSpace * /*blendingColorSpace*/,
GBool /*isolated*/, GBool /*knockout*/,
GBool /*forSoftMask*/);
bool /*isolated*/, bool /*knockout*/,
bool /*forSoftMask*/);
virtual void endTransparencyGroup(GfxState * /*state*/);
@ -319,7 +346,7 @@ protected:
// for font reencoding
std::vector<int32_t> cur_mapping;
std::vector<char*> cur_mapping2;
std::vector<const char*> cur_mapping2;
std::vector<int> width_list; // width of each char
Preprocessor preprocessor;

View File

@ -56,16 +56,16 @@ void HTMLRenderer::eoFill(GfxState * state)
tracer.fill(state, true);
}
GBool HTMLRenderer::axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax)
bool HTMLRenderer::axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax)
{
tracer.fill(state); //TODO correct?
return true;
}
void HTMLRenderer::beginTransparencyGroup(GfxState *state, double *bbox,
void HTMLRenderer::beginTransparencyGroup(GfxState *state, const double *bbox,
GfxColorSpace *blendingColorSpace,
GBool isolated, GBool knockout,
GBool forSoftMask) {
bool isolated, bool knockout,
bool forSoftMask) {
inTransparencyGroup++;
}
void HTMLRenderer::endTransparencyGroup(GfxState *state) {

View File

@ -169,7 +169,7 @@ string HTMLRenderer::dump_embedded_font (GfxFont * font, FontInfo & info)
char buf[1024];
int len;
while((len = obj.streamGetChars(1024, (Guchar*)buf)) > 0)
while((len = obj.streamGetChars(1024, (unsigned char*)buf)) > 0)
{
outf.write(buf, len);
}
@ -205,8 +205,8 @@ string HTMLRenderer::dump_type3_font (GfxFont * font, FontInfo & info)
auto used_map = preprocessor.get_code_map(hash_ref(font->getID()));
//calculate transformed metrics
double * font_bbox = font->getFontBBox();
double * font_matrix = font->getFontMatrix();
const double * font_bbox = font->getFontBBox();
const double * font_matrix = font->getFontMatrix();
double transformed_bbox[4];
memcpy(transformed_bbox, font_bbox, 4 * sizeof(double));
/*
@ -337,7 +337,7 @@ string HTMLRenderer::dump_type3_font (GfxFont * font, FontInfo & info)
&box, nullptr);
output_dev->startDoc(cur_doc, &font_engine);
output_dev->startPage(1, gfx->getState(), gfx->getXRef());
output_dev->setInType3Char(gTrue);
output_dev->setInType3Char(true);
auto char_procs = ((Gfx8BitFont*)font)->getCharProcs();
Object char_proc_obj;
auto glyph_index = cur_font->getGlyph(code, nullptr, 0);
@ -640,8 +640,8 @@ void HTMLRenderer::embed_font(const string & filepath, GfxFont * font, FontInfo
if(info.use_tounicode)
{
int n = ctu ?
(((CharCodeToUnicode *)ctu)->mapToUnicode(cur_code, &pu)) :
0;
(((CharCodeToUnicode *)ctu)->mapToUnicode(cur_code, &pu)) :
0;
u = check_unicode(pu, n, cur_code, font);
}
else
@ -877,7 +877,7 @@ const FontInfo * HTMLRenderer::install_font(GfxFont * font)
{
cerr << "Install font " << hex << new_fn_id << dec
<< ": (" << (font->getID()->num) << ' ' << (font->getID()->gen) << ") "
<< (font->getName() ? font->getName()->getCString() : "")
<< (font->getName() ? font->getName()->toStr() : "")
<< endl;
}
@ -907,7 +907,7 @@ const FontInfo * HTMLRenderer::install_font(GfxFont * font)
/*
* The 2nd parameter of locateFont should be true only for PS
* which does not make much sense in our case
* If we specify gFalse here, font_loc->locType cannot be gfxFontLocResident
* If we specify false here, font_loc->locType cannot be gfxFontLocResident
*/
if(auto * font_loc = font->locateFont(xref, nullptr))
{
@ -954,7 +954,7 @@ void HTMLRenderer::install_embedded_font(GfxFont * font, FontInfo & info)
void HTMLRenderer::install_external_font(GfxFont * font, FontInfo & info)
{
string fontname(font->getName()->getCString());
string fontname(font->getName()->toStr());
// resolve bad encodings in GB
auto iter = GB_ENCODED_FONT_NAME_MAP.find(fontname);
@ -970,7 +970,7 @@ void HTMLRenderer::install_external_font(GfxFont * font, FontInfo & info)
{
if(localfontloc != nullptr)
{
embed_font(string(localfontloc->path->getCString()), font, info);
embed_font(string(localfontloc->path->toStr()), font, info);
export_remote_font(info, param.font_format, font);
delete localfontloc;
return;
@ -986,7 +986,7 @@ void HTMLRenderer::install_external_font(GfxFont * font, FontInfo & info)
if(localfontloc != nullptr)
{
// fill in ascent/descent only, do not embed
embed_font(string(localfontloc->path->getCString()), font, info, true);
embed_font(string(localfontloc->path->toStr()), font, info, true);
delete localfontloc;
}
else

View File

@ -53,7 +53,7 @@ HTMLRenderer::HTMLRenderer(Param & param)
if(!(param.debug))
{
//disable error messages of poppler
globalParams->setErrQuiet(gTrue);
globalParams->setErrQuiet(true);
}
ffw_init(param.debug);
@ -190,7 +190,7 @@ void HTMLRenderer::process(PDFDoc *doc)
cerr << endl;
}
void HTMLRenderer::setDefaultCTM(double *ctm)
void HTMLRenderer::setDefaultCTM(const double *ctm)
{
memcpy(default_ctm, ctm, sizeof(default_ctm));
}

View File

@ -12,7 +12,7 @@
namespace pdf2htmlEX {
void HTMLRenderer::drawImage(GfxState * state, Object * ref, Stream * str, int width, int height, GfxImageColorMap * colorMap, GBool interpolate, int *maskColors, GBool inlineImg)
void HTMLRenderer::drawImage(GfxState * state, Object * ref, Stream * str, int width, int height, GfxImageColorMap * colorMap, bool interpolate, int *maskColors, bool inlineImg)
{
tracer.draw_image(state);
@ -67,11 +67,11 @@ void HTMLRenderer::drawImage(GfxState * state, Object * ref, Stream * str, int w
void HTMLRenderer::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
int width, int height,
GfxImageColorMap *colorMap,
GBool interpolate,
bool interpolate,
Stream *maskStr,
int maskWidth, int maskHeight,
GfxImageColorMap *maskColorMap,
GBool maskInterpolate)
bool maskInterpolate)
{
tracer.draw_image(state);

View File

@ -164,7 +164,7 @@ string HTMLRenderer::get_linkaction_str(const LinkAction * action, string & deta
{
auto * real_action = dynamic_cast<const LinkURI*>(action);
assert(real_action != nullptr);
dest_str = real_action->getURI()->getCString();
dest_str = real_action->getURI()->toStr();
}
break;
case actionLaunch:

View File

@ -58,7 +58,7 @@ void HTMLRenderer::drawString(GfxState * state, const GooString * s)
// Now ready to output
// get the unicodes
const char *p = s->getCString();
const char *p = (s->toStr()).c_str();
int len = s->getLength();
//accumulated displacement of chars in this string, in text object space

View File

@ -30,11 +30,11 @@ public:
void process(PDFDoc * doc);
virtual GBool upsideDown() { return gFalse; }
virtual GBool useDrawChar() { return gTrue; }
virtual GBool interpretType3Chars() { return gFalse; }
virtual GBool needNonText() { return gFalse; }
virtual GBool needClipToCropBox() { return gTrue; }
virtual bool upsideDown() { return false; }
virtual bool useDrawChar() { return true; }
virtual bool interpretType3Chars() { return false; }
virtual bool needNonText() { return false; }
virtual bool needClipToCropBox() { return true; }
virtual void drawChar(GfxState *state, double x, double y,
double dx, double dy,

View File

@ -438,8 +438,9 @@ int main(int argc, char **argv)
delete globalParams;
// check for memory leaks
Object::memCheck(stderr);
gMemReport(stderr);
// Poppler Object class (Object.h) no longer has memCheck
//Object::memCheck(stderr);
//gMemReport(stderr);
exit(finished ? (EXIT_SUCCESS) : (EXIT_FAILURE));

View File

@ -275,7 +275,7 @@ void ffw_reencode_raw(int32 * mapping, int mapping_len, int force)
ffw_do_reencode(enc, force);
}
void ffw_reencode_raw2(char ** mapping, int mapping_len, int force)
void ffw_reencode_raw2(const char ** mapping, int mapping_len, int force)
{
Encoding * enc = calloc(1, sizeof(Encoding));
enc->enc_name = strcopy("");

View File

@ -39,7 +39,7 @@ void ffw_close(void);
void ffw_reencode_glyph_order(void);
void ffw_reencode_unicode_full(void);
void ffw_reencode_raw(int32_t * mapping, int mapping_len, int force);
void ffw_reencode_raw2(char ** mapping, int mapping_len, int force);
void ffw_reencode_raw2(const char ** mapping, int mapping_len, int force);
void ffw_cidflatten(void);
// add a new empty char into the font

View File

@ -42,7 +42,7 @@ Unicode unicode_from_font (CharCode code, GfxFont * font)
{
auto * font2 = dynamic_cast<Gfx8BitFont*>(font);
assert(font2 != nullptr);
char * cname = font2->getCharName(code);
const char * cname = font2->getCharName(code);
// may be untranslated ligature
if(cname)
{