+
+ char type3Warning;
+
+ char* substitutetarget[256];
+ char* substitutesource[256];
+ int substitutepos;
+
+ int user_movex,user_movey;
+ int user_clipx1,user_clipx2,user_clipy1,user_clipy2;
+
+ gfxline_t* current_text_stroke;
+ gfxline_t* current_text_clip;
+ char* current_font_id;
+ gfxfont_t* current_gfxfont;
+ gfxmatrix_t current_font_matrix;
+
+ fontlist_t* fontlist;
+
+ int*pages;
+ int pagebuflen;
+ int pagepos;
+
+ friend void swf_output_preparepage(swf_output_t*swf, int pdfpage, int outputpage);
+};
+
+typedef struct _drawnchar
+{
+ gfxcoord_t x,y;
+ int charid;
+ gfxcolor_t color;
+} drawnchar_t;
+
+class CharBuffer
+{
+ drawnchar_t * chars;
+ int buf_size;
+ int num_chars;
+
+public:
+
+ CharBuffer()
+ {
+ buf_size = 32;
+ chars = (drawnchar_t*)malloc(sizeof(drawnchar_t)*buf_size);
+ memset(chars, 0, sizeof(drawnchar_t)*buf_size);
+ num_chars = 0;
+ }
+ ~CharBuffer()
+ {
+ free(chars);chars = 0;
+ }
+
+ void grow(int size)
+ {
+ if(size>=buf_size) {
+ buf_size += 32;
+ chars = (drawnchar_t*)realloc(chars, sizeof(drawnchar_t)*buf_size);
+ }
+ }
+
+ void addChar(int charid, gfxcoord_t x, gfxcoord_t y, gfxcolor_t color)
+ {
+ grow(num_chars);
+ chars[num_chars].x = x;
+ chars[num_chars].y = y;
+ chars[num_chars].color = color;
+ chars[num_chars].charid = charid;
+ }
+};
+
+static char*getFontID(GfxFont*font);
+
+struct FontInfo
+{
+ GfxFont*font;
+ double max_size;
+};
+
+class InfoOutputDev: public OutputDev
+{
+ GHash* id2font;
+ FontInfo* currentfont;
+ public:
+ int x1,y1,x2,y2;
+ int num_links;
+ int num_images;
+ int num_fonts;
+
+ InfoOutputDev()
+ {
+ num_links = 0;
+ num_images = 0;
+ num_fonts = 0;
+ id2font = new GHash();
+ }
+ virtual ~InfoOutputDev()
+ {
+ delete id2font;
+ }
+ virtual GBool upsideDown() {return gTrue;}
+ virtual GBool useDrawChar() {return gTrue;}
+ virtual GBool useGradients() {return gTrue;}
+ virtual GBool interpretType3Chars() {return gTrue;}
+ virtual void startPage(int pageNum, GfxState *state, double crop_x1, double crop_y1, double crop_x2, double crop_y2)
+ {
+ double x1,y1,x2,y2;
+ state->transform(crop_x1,crop_y1,&x1,&y1);
+ state->transform(crop_x2,crop_y2,&x2,&y2);
+ if(x2<x1) {double x3=x1;x1=x2;x2=x3;}
+ if(y2<y1) {double y3=y1;y1=y2;y2=y3;}
+ this->x1 = (int)x1;
+ this->y1 = (int)y1;
+ this->x2 = (int)x2;
+ this->y2 = (int)y2;
+ }
+ virtual void drawLink(Link *link, Catalog *catalog)
+ {
+ num_links++;
+ }
+ virtual double getMaximumFontSize(char*id)
+ {
+ FontInfo*info = (FontInfo*)id2font->lookup(id);
+ if(!info) {
+ msg("<error> Unknown font id: %s", id);
+ return 0.0;
+ }
+ return info->max_size;
+ }
+
+ virtual void updateFont(GfxState *state)
+ {
+ GfxFont*font = state->getFont();
+ if(!font)
+ return;
+ char*id = getFontID(font);
+
+ FontInfo*info = (FontInfo*)id2font->lookup(id);
+ if(!info) {
+ GString* idStr = new GString(id);
+ info = new FontInfo;
+ info->font = font;
+ info->max_size = 0;
+ id2font->add(idStr, (void*)info);
+ free(id);
+ num_fonts++;
+ }
+ currentfont = info;
+ }
+
+ virtual void drawChar(GfxState *state, double x, double y,
+ double dx, double dy,
+ double originX, double originY,
+ CharCode code, int nBytes, Unicode *u, int uLen)
+ {
+ int render = state->getRender();
+ if (render == 3)
+ return;
+ double m11,m21,m12,m22;
+ state->getFontTransMat(&m11, &m12, &m21, &m22);
+ m11 *= state->getHorizScaling();
+ m21 *= state->getHorizScaling();
+ double lenx = sqrt(m11*m11 + m12*m12);
+ double leny = sqrt(m21*m21 + m22*m22);
+ double len = lenx>leny?lenx:leny;
+ if(currentfont && currentfont->max_size < len) {
+ currentfont->max_size = len;
+ }
+ }
+ virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
+ int width, int height, GBool invert,
+ GBool inlineImg)
+ {
+ num_images++;
+ }
+ virtual void drawImage(GfxState *state, Object *ref, Stream *str,
+ int width, int height, GfxImageColorMap *colorMap,
+ int *maskColors, GBool inlineImg)
+ {
+ num_images++;
+ }