2 implements a pdf output device (OutputDev).
4 This file is part of swftools.
6 Swftools is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 Swftools is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with swftools; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
25 #include "../config.h"
40 #include "OutputDev.h"
43 #include "CharCodeToUnicode.h"
44 #include "NameToUnicodeTable.h"
46 #include "GlobalParams.h"
47 //swftools header files
48 #include "swfoutput.h"
49 #include "../lib/log.h"
53 static PDFDoc*doc = 0;
54 static char* swffilename = 0;
56 static int currentpage;
58 static char*fonts[2048];
59 static int fontnum = 0;
63 static int pagebuflen = 0;
64 static int pagepos = 0;
66 static double caplinewidth = 3.0;
68 static void printInfoString(Dict *infoDict, char *key, char *fmt);
69 static void printInfoDate(Dict *infoDict, char *key, char *fmt);
71 static double fontsizes[] =
73 0.833,0.833,0.889,0.889,
74 0.788,0.722,0.833,0.778,
75 0.600,0.600,0.600,0.600,
76 0.576,0.576,0.576,0.576,
79 static char*fontnames[]={
82 "Helvetica-BoldOblique",
90 "Courier-BoldOblique",
104 {"Times-Roman", "n021003l"},
105 {"Times-Italic", "n021023l"},
106 {"Times-Bold", "n021004l"},
107 {"Times-BoldItalic", "n021024l"},
108 {"Helvetica", "n019003l"},
109 {"Helvetica-Oblique", "n019023l"},
110 {"Helvetica-Bold", "n019004l"},
111 {"Helvetica-BoldOblique", "n019024l"},
112 {"Courier", "n022003l"},
113 {"Courier-Oblique", "n022023l"},
114 {"Courier-Bold", "n022004l"},
115 {"Courier-BoldOblique", "n022024l"},
116 {"Symbol", "s050000l"},
117 {"ZapfDingbats", "d050000l"}};
120 class GfxImageColorMap;
122 class SWFOutputDev: public OutputDev {
123 struct swfoutput output;
131 virtual ~SWFOutputDev() ;
133 //----- get info about output device
135 // Does this device use upside-down coordinates?
136 // (Upside-down means (0,0) is the top left corner of the page.)
137 virtual GBool upsideDown();
139 // Does this device use drawChar() or drawString()?
140 virtual GBool useDrawChar();
142 virtual GBool interpretType3Chars() {return gTrue;}
144 //----- initialization and control
146 void startDoc(XRef *xref);
149 virtual void startPage(int pageNum, GfxState *state, double x1, double y1, double x2, double y2) ;
152 virtual void drawLink(Link *link, Catalog *catalog) ;
154 //----- save/restore graphics state
155 virtual void saveState(GfxState *state) ;
156 virtual void restoreState(GfxState *state) ;
158 //----- update graphics state
160 virtual void updateFont(GfxState *state);
161 virtual void updateFillColor(GfxState *state);
162 virtual void updateStrokeColor(GfxState *state);
163 virtual void updateLineWidth(GfxState *state);
164 virtual void updateLineJoin(GfxState *state);
165 virtual void updateLineCap(GfxState *state);
167 virtual void updateAll(GfxState *state)
170 updateFillColor(state);
171 updateStrokeColor(state);
172 updateLineWidth(state);
173 updateLineJoin(state);
174 updateLineCap(state);
177 //----- path painting
178 virtual void stroke(GfxState *state) ;
179 virtual void fill(GfxState *state) ;
180 virtual void eoFill(GfxState *state) ;
182 //----- path clipping
183 virtual void clip(GfxState *state) ;
184 virtual void eoClip(GfxState *state) ;
187 virtual void beginString(GfxState *state, GString *s) ;
188 virtual void endString(GfxState *state) ;
189 virtual void drawChar(GfxState *state, double x, double y,
190 double dx, double dy,
191 double originX, double originY,
192 CharCode code, Unicode *u, int uLen);
194 //----- image drawing
195 virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
196 int width, int height, GBool invert,
198 virtual void drawImage(GfxState *state, Object *ref, Stream *str,
199 int width, int height, GfxImageColorMap *colorMap,
200 int *maskColors, GBool inlineImg);
202 virtual GBool beginType3Char(GfxState *state,
203 CharCode code, Unicode *u, int uLen);
204 virtual void endType3Char(GfxState *state);
207 void drawGeneralImage(GfxState *state, Object *ref, Stream *str,
208 int width, int height, GfxImageColorMap*colorMap, GBool invert,
209 GBool inlineImg, int mask);
215 char* searchFont(char*name);
216 char* substituteFont(GfxFont*gfxFont, char*oldname);
217 char* writeEmbeddedFontToFile(XRef*ref, GfxFont*font);
219 int jpeginfo; // did we write "File contains jpegs" yet?
220 int pbminfo; // did we write "File contains jpegs" yet?
221 int linkinfo; // did we write "File contains links" yet?
222 int ttfinfo; // did we write "File contains TrueType Fonts" yet?
224 int type3active; // are we between beginType3()/endType3()?
229 char*getFontName(GfxFont*font)
231 GString*gstr = font->getName();
232 char* fontname = gstr==0?0:gstr->getCString();
236 sprintf(buf, "UFONT%d", r->num);
239 char* plus = strchr(fontname, '+');
240 if(plus && plus < &fontname[strlen(fontname)-1])
246 char* gfxstate2str(GfxState *state)
250 bufpos+=sprintf(bufpos,"CTM[%.3f/%.3f/%.3f/%.3f/%.3f/%.3f] ",
257 if(state->getX1()!=0.0)
258 bufpos+=sprintf(bufpos,"X1-%.1f ",state->getX1());
259 if(state->getY1()!=0.0)
260 bufpos+=sprintf(bufpos,"Y1-%.1f ",state->getY1());
261 bufpos+=sprintf(bufpos,"X2-%.1f ",state->getX2());
262 bufpos+=sprintf(bufpos,"Y2-%.1f ",state->getY2());
263 bufpos+=sprintf(bufpos,"PW%.1f ",state->getPageWidth());
264 bufpos+=sprintf(bufpos,"PH%.1f ",state->getPageHeight());
265 /*bufpos+=sprintf(bufpos,"FC[%.1f/%.1f] ",
266 state->getFillColor()->c[0], state->getFillColor()->c[1]);
267 bufpos+=sprintf(bufpos,"SC[%.1f/%.1f] ",
268 state->getStrokeColor()->c[0], state->getFillColor()->c[1]);*/
269 /* bufpos+=sprintf(bufpos,"FC[%.1f/%.1f/%.1f/%.1f/%.1f/%.1f/%.1f/%.1f]",
270 state->getFillColor()->c[0], state->getFillColor()->c[1],
271 state->getFillColor()->c[2], state->getFillColor()->c[3],
272 state->getFillColor()->c[4], state->getFillColor()->c[5],
273 state->getFillColor()->c[6], state->getFillColor()->c[7]);
274 bufpos+=sprintf(bufpos,"SC[%.1f/%.1f/%.1f/%.1f/%.1f/%.1f/%.1f/%.1f]",
275 state->getStrokeColor()->c[0], state->getFillColor()->c[1],
276 state->getStrokeColor()->c[2], state->getFillColor()->c[3],
277 state->getStrokeColor()->c[4], state->getFillColor()->c[5],
278 state->getStrokeColor()->c[6], state->getFillColor()->c[7]);*/
279 state->getFillRGB(&rgb);
280 if(rgb.r || rgb.g || rgb.b)
281 bufpos+=sprintf(bufpos,"FR[%.1f/%.1f/%.1f] ", rgb.r,rgb.g,rgb.b);
282 state->getStrokeRGB(&rgb);
283 if(rgb.r || rgb.g || rgb.b)
284 bufpos+=sprintf(bufpos,"SR[%.1f/%.1f/%.1f] ", rgb.r,rgb.g,rgb.b);
285 if(state->getFillColorSpace()->getNComps()>1)
286 bufpos+=sprintf(bufpos,"CS[[%d]] ",state->getFillColorSpace()->getNComps());
287 if(state->getStrokeColorSpace()->getNComps()>1)
288 bufpos+=sprintf(bufpos,"SS[[%d]] ",state->getStrokeColorSpace()->getNComps());
289 if(state->getFillPattern())
290 bufpos+=sprintf(bufpos,"FP%08x ", state->getFillPattern());
291 if(state->getStrokePattern())
292 bufpos+=sprintf(bufpos,"SP%08x ", state->getStrokePattern());
294 if(state->getFillOpacity()!=1.0)
295 bufpos+=sprintf(bufpos,"FO%.1f ", state->getFillOpacity());
296 if(state->getStrokeOpacity()!=1.0)
297 bufpos+=sprintf(bufpos,"SO%.1f ", state->getStrokeOpacity());
299 bufpos+=sprintf(bufpos,"LW%.1f ", state->getLineWidth());
304 state->getLineDash(&dash, &length, &start);
308 bufpos+=sprintf(bufpos,"DASH%.1f[",start);
309 for(t=0;t<length;t++) {
310 bufpos+=sprintf(bufpos,"D%.1f",dash[t]);
312 bufpos+=sprintf(bufpos,"]");
315 if(state->getFlatness()!=1)
316 bufpos+=sprintf(bufpos,"F%d ", state->getFlatness());
317 if(state->getLineJoin()!=0)
318 bufpos+=sprintf(bufpos,"J%d ", state->getLineJoin());
319 if(state->getLineJoin()!=0)
320 bufpos+=sprintf(bufpos,"C%d ", state->getLineCap());
321 if(state->getLineJoin()!=0)
322 bufpos+=sprintf(bufpos,"ML%d ", state->getMiterLimit());
324 if(state->getFont() && getFontName(state->getFont()))
325 bufpos+=sprintf(bufpos,"F\"%s\" ",getFontName(state->getFont()));
326 bufpos+=sprintf(bufpos,"FS%.1f ", state->getFontSize());
327 bufpos+=sprintf(bufpos,"MAT[%.1f/%.1f/%.1f/%.1f/%.1f/%.1f] ", state->getTextMat()[0],state->getTextMat()[1],state->getTextMat()[2],
328 state->getTextMat()[3],state->getTextMat()[4],state->getTextMat()[5]);
329 if(state->getCharSpace())
330 bufpos+=sprintf(bufpos,"CS%.5f ", state->getCharSpace());
331 if(state->getWordSpace())
332 bufpos+=sprintf(bufpos,"WS%.5f ", state->getWordSpace());
333 if(state->getHorizScaling()!=1.0)
334 bufpos+=sprintf(bufpos,"SC%.1f ", state->getHorizScaling());
335 if(state->getLeading())
336 bufpos+=sprintf(bufpos,"L%.1f ", state->getLeading());
338 bufpos+=sprintf(bufpos,"R%.1f ", state->getRise());
339 if(state->getRender())
340 bufpos+=sprintf(bufpos,"R%d ", state->getRender());
341 bufpos+=sprintf(bufpos,"P%08x ", state->getPath());
342 bufpos+=sprintf(bufpos,"CX%.1f ", state->getCurX());
343 bufpos+=sprintf(bufpos,"CY%.1f ", state->getCurY());
344 if(state->getLineX())
345 bufpos+=sprintf(bufpos,"LX%.1f ", state->getLineX());
346 if(state->getLineY())
347 bufpos+=sprintf(bufpos,"LY%.1f ", state->getLineY());
348 bufpos+=sprintf(bufpos," ");
354 void dumpFontInfo(char*loglevel, GfxFont*font);
361 void showFontError(GfxFont*font, int nr)
365 for(t=0;t<lastdumppos;t++)
366 if(lastdumps[t] == r->num)
370 if(lastdumppos<sizeof(lastdumps)/sizeof(int))
371 lastdumps[lastdumppos++] = r->num;
373 msg("<warning> The following font caused problems:");
375 msg("<warning> The following font caused problems (substituting):");
377 msg("<warning> The following Type 3 Font will be rendered as bitmap:");
378 dumpFontInfo("<warning>", font);
381 void dumpFontInfo(char*loglevel, GfxFont*font)
383 char* name = getFontName(font);
384 Ref* r=font->getID();
385 msg("%s=========== %s (ID:%d,%d) ==========\n", loglevel, name, r->num,r->gen);
387 GString*gstr = font->getTag();
389 msg("%sTag: %s\n", loglevel, name);
391 if(font->isCIDFont()) msg("%sis CID font\n", loglevel);
393 GfxFontType type=font->getType();
395 case fontUnknownType:
396 msg("%sType: unknown\n",loglevel);
399 msg("%sType: 1\n",loglevel);
402 msg("%sType: 1C\n",loglevel);
405 msg("%sType: 3\n",loglevel);
408 msg("%sType: TrueType\n",loglevel);
411 msg("%sType: CIDType0\n",loglevel);
414 msg("%sType: CIDType0C\n",loglevel);
417 msg("%sType: CIDType2\n",loglevel);
422 GBool embedded = font->getEmbeddedFontID(&embRef);
423 if(font->getEmbeddedFontName())
424 name = font->getEmbeddedFontName()->getCString();
426 msg("%sEmbedded name: %s id: %d\n",loglevel, FIXNULL(name), embRef.num);
428 gstr = font->getExtFontFile();
430 msg("%sExternal Font file: %s\n", loglevel, FIXNULL(gstr->getCString()));
432 // Get font descriptor flags.
433 if(font->isFixedWidth()) msg("%sis fixed width\n", loglevel);
434 if(font->isSerif()) msg("%sis serif\n", loglevel);
435 if(font->isSymbolic()) msg("%sis symbolic\n", loglevel);
436 if(font->isItalic()) msg("%sis italic\n", loglevel);
437 if(font->isBold()) msg("%sis bold\n", loglevel);
440 //void SWFOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, GBool invert, GBool inlineImg) {printf("void SWFOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, GBool invert, GBool inlineImg) \n");}
441 //void SWFOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, GBool inlineImg) {printf("void SWFOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, GBool inlineImg) \n");}
443 SWFOutputDev::SWFOutputDev()
451 clipping[clippos] = 0;
454 // printf("SWFOutputDev::SWFOutputDev() \n");
457 SWF_OUTLINE* gfxPath_to_SWF_OUTLINE(GfxState*state, GfxPath*path)
459 int num = path->getNumSubpaths();
461 bezierpathsegment*start,*last=0;
462 bezierpathsegment*outline = start = new bezierpathsegment();
464 double lastx=0,lasty=0;
466 msg("<warning> empty path");
467 outline->type = SWF_PATHTYPE_MOVE;
471 return (SWF_OUTLINE*)outline;
473 for(t = 0; t < num; t++) {
474 GfxSubpath *subpath = path->getSubpath(t);
475 int subnum = subpath->getNumPoints();
477 for(s=0;s<subnum;s++) {
479 state->transform(subpath->getX(s),subpath->getY(s),&nx,&ny);
480 int x = (int)((nx-lastx)*0xffff);
481 int y = (int)((ny-lasty)*0xffff);
485 outline->type = SWF_PATHTYPE_MOVE;
488 outline->link = (SWF_OUTLINE*)new bezierpathsegment();
489 outline = (bezierpathsegment*)outline->link;
494 else if(subpath->getCurve(s) && !cpos)
500 else if(subpath->getCurve(s) && cpos)
511 outline->type = cpos?SWF_PATHTYPE_BEZIER:SWF_PATHTYPE_LINE;
513 outline->link = (SWF_OUTLINE*)new bezierpathsegment();
514 outline = (bezierpathsegment*)outline->link;
522 return (SWF_OUTLINE*)start;
524 /*----------------------------------------------------------------------------
525 * Primitive Graphic routines
526 *----------------------------------------------------------------------------*/
528 void SWFOutputDev::stroke(GfxState *state)
530 msg("<debug> stroke\n");
531 GfxPath * path = state->getPath();
532 int lineCap = state->getLineCap(); // 0=butt, 1=round 2=square
533 int lineJoin = state->getLineJoin(); // 0=miter, 1=round 2=bevel
534 double miterLimit = state->getMiterLimit();
535 double width = state->getTransformedLineWidth();
538 double opaq = state->getStrokeOpacity();
539 state->getStrokeRGB(&rgb);
541 m.m11 = 1; m.m21 = 0; m.m22 = 1;
542 m.m12 = 0; m.m13 = 0; m.m23 = 0;
543 SWF_OUTLINE*outline = gfxPath_to_SWF_OUTLINE(state, path);
545 lineJoin = 1; // other line joins are not yet supported by the swf encoder
546 // TODO: support bevel joints
548 if(((lineCap==1) && (lineJoin==1)) || width<=caplinewidth) {
549 /* FIXME- if the path is smaller than 2 segments, we could ignore
551 swfoutput_setdrawmode(&output, DRAWMODE_STROKE);
552 swfoutput_drawpath(&output, outline, &m);
554 swfoutput_setfillcolor(&output, (char)(rgb.r*255), (char)(rgb.g*255),
555 (char)(rgb.b*255), (char)(opaq*255));
557 //swfoutput_setlinewidth(&output, 1.0); //only for debugging
558 //swfoutput_setstrokecolor(&output, 0, 255, 0, 255); //likewise, see below
559 //swfoutput_setfillcolor(&output, 255, 0, 0, 255); //likewise, see below
561 swfoutput_drawpath2poly(&output, outline, &m, lineJoin, lineCap, width, miterLimit);
562 updateLineWidth(state); //reset
563 updateStrokeColor(state); //reset
564 updateFillColor(state); //reset
567 void SWFOutputDev::fill(GfxState *state)
569 msg("<debug> fill\n");
570 GfxPath * path = state->getPath();
572 m.m11 = 1; m.m21 = 0; m.m22 = 1;
573 m.m12 = 0; m.m13 = 0; m.m23 = 0;
574 SWF_OUTLINE*outline = gfxPath_to_SWF_OUTLINE(state, path);
575 swfoutput_setdrawmode(&output, DRAWMODE_FILL);
576 swfoutput_drawpath(&output, outline, &m);
578 void SWFOutputDev::eoFill(GfxState *state)
580 msg("<debug> eofill\n");
581 GfxPath * path = state->getPath();
583 m.m11 = 1; m.m21 = 0; m.m22 = 1;
584 m.m12 = 0; m.m13 = 0; m.m23 = 0;
585 SWF_OUTLINE*outline = gfxPath_to_SWF_OUTLINE(state, path);
586 swfoutput_setdrawmode(&output, DRAWMODE_EOFILL);
587 swfoutput_drawpath(&output, outline, &m);
589 void SWFOutputDev::clip(GfxState *state)
591 msg("<debug> clip\n");
592 GfxPath * path = state->getPath();
594 m.m11 = 1; m.m22 = 1;
595 m.m12 = 0; m.m21 = 0;
596 m.m13 = 0; m.m23 = 0;
597 SWF_OUTLINE*outline = gfxPath_to_SWF_OUTLINE(state, path);
598 swfoutput_startclip(&output, outline, &m);
599 clipping[clippos] ++;
601 void SWFOutputDev::eoClip(GfxState *state)
603 msg("<debug> eoclip\n");
604 GfxPath * path = state->getPath();
606 m.m11 = 1; m.m21 = 0; m.m22 = 1;
607 m.m12 = 0; m.m13 = 0; m.m23 = 0;
608 SWF_OUTLINE*outline = gfxPath_to_SWF_OUTLINE(state, path);
609 swfoutput_startclip(&output, outline, &m);
610 clipping[clippos] ++;
613 SWFOutputDev::~SWFOutputDev()
615 swfoutput_destroy(&output);
618 GBool SWFOutputDev::upsideDown()
620 msg("<debug> upsidedown?");
623 GBool SWFOutputDev::useDrawChar()
625 msg("<debug> usedrawchar?");
629 void SWFOutputDev::beginString(GfxState *state, GString *s)
631 double m11,m21,m12,m22;
632 // msg("<debug> %s beginstring \"%s\"\n", gfxstate2str(state), s->getCString());
633 state->getFontTransMat(&m11, &m12, &m21, &m22);
634 m11 *= state->getHorizScaling();
635 m21 *= state->getHorizScaling();
636 swfoutput_setfontmatrix(&output, m11, -m21, m12, -m22);
640 void SWFOutputDev::drawChar(GfxState *state, double x, double y,
641 double dx, double dy,
642 double originX, double originY,
643 CharCode c, Unicode *_u, int uLen)
645 // check for invisible text -- this is used by Acrobat Capture
646 if ((state->getRender() & 3) == 3)
649 GfxFont*font = state->getFont();
651 if(font->getType() == fontType3) {
652 /* type 3 chars are passed primarily as graphics */
658 state->transform(x, y, &x1, &y1);
664 msg("<debug> drawChar(%f,%f,%f,%f,c='%c' (%d),u=%d) CID=%d\n",x,y,dx,dy,c,c,u, font->isCIDFont());
666 if(font->isCIDFont()) {
667 GfxCIDFont*cfont = (GfxCIDFont*)font;
671 for(t=0;t<sizeof(nameToUnicodeTab)/sizeof(nameToUnicodeTab[0]);t++)
672 /* todo: should be precomputed */
673 if(nameToUnicodeTab[t].u == u) {
674 name = nameToUnicodeTab[t].name;
680 swfoutput_drawchar(&output, x1, y1, name, c, u);
682 swfoutput_drawchar(&output, x1, y1, 0, c, u);
686 font8 = (Gfx8BitFont*)font;
687 char**enc=font8->getEncoding();
690 swfoutput_drawchar(&output, x1, y1, enc[c], c, u);
692 swfoutput_drawchar(&output, x1, y1, 0, c, u);
697 void SWFOutputDev::endString(GfxState *state)
699 msg("<debug> endstring\n");
703 GBool SWFOutputDev::beginType3Char(GfxState *state,
704 CharCode code, Unicode *u, int uLen)
706 msg("<debug> beginType3Char %d, %08x, %d", code, *u, uLen);
708 /* the character itself is going to be passed using
710 return gFalse; /* gTrue= is_in_cache? */
713 void SWFOutputDev::endType3Char(GfxState *state)
716 msg("<debug> endType3Char");
719 void SWFOutputDev::startPage(int pageNum, GfxState *state, double crop_x1, double crop_y1, double crop_x2, double crop_y2)
723 msg("<verbose> startPage %d (%f,%f,%f,%f)\n", pageNum, crop_x1, crop_y1, crop_x2, crop_y2);
724 msg("<notice> processing page %d", pageNum);
726 /* state->transform(state->getX1(),state->getY1(),&x1,&y1);
727 state->transform(state->getX2(),state->getY2(),&x2,&y2);
728 Use CropBox, not MediaBox, as page size
735 if(x2<x1) {double x3=x1;x1=x2;x2=x3;}
736 if(y2<y1) {double y3=y1;y1=y2;y2=y3;}
739 msg("<verbose> Bounding box is (%f,%f)-(%f,%f)", x1,y1,x2,y2);
740 swfoutput_init(&output, swffilename,(int)x1,(int)y1,(int)x2,(int)y2);
744 swfoutput_newpage(&output);
747 void SWFOutputDev::drawLink(Link *link, Catalog *catalog)
749 msg("<debug> drawlink\n");
750 double x1, y1, x2, y2, w;
755 link->getBorder(&x1, &y1, &x2, &y2, &w);
761 cvtUserToDev(x1, y1, &x, &y);
762 points[0].x = points[4].x = (int)x;
763 points[0].y = points[4].y = (int)y;
764 cvtUserToDev(x2, y1, &x, &y);
765 points[1].x = (int)x;
766 points[1].y = (int)y;
767 cvtUserToDev(x2, y2, &x, &y);
768 points[2].x = (int)x;
769 points[2].y = (int)y;
770 cvtUserToDev(x1, y2, &x, &y);
771 points[3].x = (int)x;
772 points[3].y = (int)y;
774 LinkAction*action=link->getAction();
781 switch(action->getKind())
785 LinkGoTo *ha=(LinkGoTo *)link->getAction();
787 if (ha->getDest()==NULL)
788 dest=catalog->findDest(ha->getNamedDest());
789 else dest=ha->getDest();
791 if (dest->isPageRef()){
792 Ref pageref=dest->getPageRef();
793 page=catalog->findPage(pageref.num,pageref.gen);
795 else page=dest->getPageNum();
796 sprintf(buf, "%d", page);
803 LinkGoToR*l = (LinkGoToR*)action;
804 GString*g = l->getNamedDest();
811 LinkNamed*l = (LinkNamed*)action;
812 GString*name = l->getName();
814 s = name->lowerCase()->getCString();
815 named = name->getCString();
818 if(strstr(s, "next") || strstr(s, "forward"))
820 page = currentpage + 1;
822 else if(strstr(s, "prev") || strstr(s, "back"))
824 page = currentpage - 1;
826 else if(strstr(s, "last") || strstr(s, "end"))
828 page = pages[pagepos-1]; //:)
830 else if(strstr(s, "first") || strstr(s, "top"))
840 LinkLaunch*l = (LinkLaunch*)action;
841 GString * str = new GString(l->getFileName());
842 str->append(l->getParams());
843 s = str->getCString();
848 LinkURI*l = (LinkURI*)action;
849 GString*g = l->getURI();
851 url = g->getCString();
856 case actionUnknown: {
858 LinkUnknown*l = (LinkUnknown*)action;
863 msg("<error> Unknown link type!\n");
867 if(!linkinfo && (page || url))
869 msg("<notice> File contains links");
875 for(t=0;t<pagepos;t++)
879 swfoutput_linktopage(&output, t, points);
883 swfoutput_linktourl(&output, url, points);
887 swfoutput_namedlink(&output, named, points);
889 msg("<verbose> \"%s\" link to \"%s\" (%d)\n", type, FIXNULL(s), page);
893 void SWFOutputDev::saveState(GfxState *state) {
894 msg("<debug> saveState\n");
899 msg("<error> Too many nested states in pdf.");
900 clipping[clippos] = 0;
903 void SWFOutputDev::restoreState(GfxState *state) {
904 msg("<debug> restoreState\n");
906 while(clipping[clippos]) {
907 swfoutput_endclip(&output);
915 char* SWFOutputDev::searchFont(char*name)
920 msg("<verbose> SearchT1Font(%s)", name);
922 /* see if it is a pdf standard font */
923 for(i=0;i<sizeof(pdf2t1map)/sizeof(mapping);i++)
925 if(!strcmp(name, pdf2t1map[i].pdffont))
927 name = pdf2t1map[i].filename;
931 /* look in all font files */
932 for(i=0;i<fontnum;i++)
934 if(!strstr(fonts[i], name))
942 void SWFOutputDev::updateLineWidth(GfxState *state)
944 double width = state->getTransformedLineWidth();
945 swfoutput_setlinewidth(&output, width);
948 void SWFOutputDev::updateLineCap(GfxState *state)
950 int c = state->getLineCap();
953 void SWFOutputDev::updateLineJoin(GfxState *state)
955 int j = state->getLineJoin();
958 void SWFOutputDev::updateFillColor(GfxState *state)
961 double opaq = state->getFillOpacity();
962 state->getFillRGB(&rgb);
964 swfoutput_setfillcolor(&output, (char)(rgb.r*255), (char)(rgb.g*255),
965 (char)(rgb.b*255), (char)(opaq*255));
968 void SWFOutputDev::updateStrokeColor(GfxState *state)
971 double opaq = state->getStrokeOpacity();
972 state->getStrokeRGB(&rgb);
974 swfoutput_setstrokecolor(&output, (char)(rgb.r*255), (char)(rgb.g*255),
975 (char)(rgb.b*255), (char)(opaq*255));
978 char*SWFOutputDev::writeEmbeddedFontToFile(XRef*ref, GfxFont*font)
980 char*tmpFileName = NULL;
986 Object refObj, strObj;
988 tmpFileName = mktmpname(namebuf);
991 ret = font->getEmbeddedFontID(&embRef);
993 msg("<verbose> Didn't get embedded font id");
994 /* not embedded- the caller should now search the font
995 directories for this font */
999 f = fopen(tmpFileName, "wb");
1001 msg("<error> Couldn't create temporary Type 1 font file");
1004 if (font->getType() == fontType1C ||
1005 font->getType() == fontCIDType0C) {
1006 if (!(fontBuf = font->readEmbFontFile(xref, &fontLen))) {
1008 msg("<error> Couldn't read embedded font file");
1011 Type1CFontFile *cvt = new Type1CFontFile(fontBuf, fontLen);
1012 cvt->convertToType1(f);
1015 } else if(font->getType() == fontTrueType) {
1016 msg("<verbose> writing font using TrueTypeFontFile::writeTTF");
1017 if (!(fontBuf = font->readEmbFontFile(xref, &fontLen))) {
1019 msg("<error> Couldn't read embedded font file");
1022 TrueTypeFontFile *cvt = new TrueTypeFontFile(fontBuf, fontLen);
1027 font->getEmbeddedFontID(&embRef);
1028 refObj.initRef(embRef.num, embRef.gen);
1029 refObj.fetch(ref, &strObj);
1031 strObj.streamReset();
1036 f4[t] = strObj.streamGetChar();
1037 f4c[t] = (char)f4[t];
1042 if(!strncmp(f4c, "true", 4)) {
1043 /* some weird TTF fonts don't start with 0,1,0,0 but with "true".
1044 Change this on the fly */
1045 f4[0] = f4[2] = f4[3] = 0;
1053 while ((c = strObj.streamGetChar()) != EOF) {
1057 strObj.streamClose();
1062 return strdup(tmpFileName);
1066 char* substitutetarget[256];
1067 char* substitutesource[256];
1068 int substitutepos = 0;
1070 char* SWFOutputDev::substituteFont(GfxFont*gfxFont, char* oldname)
1072 char*fontname = "Times-Roman";
1073 msg("<verbose> substituteFont(,%s)", FIXNULL(oldname));
1074 char*filename = searchFont(fontname);
1075 if(substitutepos>=sizeof(substitutesource)/sizeof(char*)) {
1076 msg("<fatal> Too many fonts in file.");
1080 substitutesource[substitutepos] = oldname;
1081 substitutetarget[substitutepos] = fontname;
1082 msg("<notice> substituting %s -> %s", FIXNULL(oldname), FIXNULL(fontname));
1088 void unlinkfont(char* filename)
1095 if(!strncmp(&filename[l-4],".afm",4)) {
1096 memcpy(&filename[l-4],".pfb",4);
1098 memcpy(&filename[l-4],".pfa",4);
1100 memcpy(&filename[l-4],".afm",4);
1103 if(!strncmp(&filename[l-4],".pfa",4)) {
1104 memcpy(&filename[l-4],".afm",4);
1106 memcpy(&filename[l-4],".pfa",4);
1109 if(!strncmp(&filename[l-4],".pfb",4)) {
1110 memcpy(&filename[l-4],".afm",4);
1112 memcpy(&filename[l-4],".pfb",4);
1117 void SWFOutputDev::startDoc(XRef *xref)
1123 void SWFOutputDev::updateFont(GfxState *state)
1125 GfxFont*gfxFont = state->getFont();
1130 char * fontname = getFontName(gfxFont);
1133 /* first, look if we substituted this font before-
1134 this way, we don't initialize the T1 Fonts
1136 for(t=0;t<substitutepos;t++) {
1137 if(!strcmp(fontname, substitutesource[t])) {
1138 fontname = substitutetarget[t];
1143 /* second, see if swfoutput already has this font
1144 cached- if so, we are done */
1145 if(swfoutput_queryfont(&output, fontname))
1147 swfoutput_setfont(&output, fontname, 0);
1149 msg("<debug> updateFont(%s) [cached]", fontname);
1153 // look for Type 3 font
1154 if (!type3Warning && gfxFont->getType() == fontType3) {
1155 type3Warning = gTrue;
1156 showFontError(gfxFont, 2);
1159 /* now either load the font, or find a substitution */
1162 GBool embedded = gfxFont->getEmbeddedFontID(&embRef);
1167 (gfxFont->getType() == fontType1 ||
1168 gfxFont->getType() == fontCIDType0C ||
1169 gfxFont->getType() == fontType1C ||
1170 gfxFont->getType() == fontTrueType ||
1171 gfxFont->getType() == fontCIDType2
1174 fileName = writeEmbeddedFontToFile(xref, gfxFont);
1175 if(!fileName) showFontError(gfxFont,0);
1178 fileName = searchFont(fontname);
1179 if(!fileName) showFontError(gfxFont,0);
1182 fileName = substituteFont(gfxFont, fontname);
1185 msg("<error> Couldn't set font %s\n", fontname);
1189 msg("<verbose> updateFont(%s) -> %s", fontname, fileName);
1191 swfoutput_setfont(&output, fontname, fileName);
1194 unlinkfont(fileName);
1200 int pic_width[1024];
1201 int pic_height[1024];
1205 #define SQR(x) ((x)*(x))
1207 unsigned char* antialize(unsigned char*data, int width, int height, int newwidth, int newheight, int palettesize)
1209 if((newwidth<2 || newheight<2) ||
1210 (width<=newwidth || height<=newheight))
1212 unsigned char*newdata;
1214 newdata= (unsigned char*)malloc(newwidth*newheight);
1216 double fx = (double)(width)/newwidth;
1217 double fy = (double)(height)/newheight;
1219 int blocksize = (int)(8192/(fx*fy));
1220 int r = 8192*256/palettesize;
1221 for(x=0;x<newwidth;x++) {
1222 double ex = px + fx;
1223 int fromx = (int)px;
1225 int xweight1 = (int)(((fromx+1)-px)*256);
1226 int xweight2 = (int)((ex-tox)*256);
1228 for(y=0;y<newheight;y++) {
1229 double ey = py + fy;
1230 int fromy = (int)py;
1232 int yweight1 = (int)(((fromy+1)-py)*256);
1233 int yweight2 = (int)((ey-toy)*256);
1236 for(xx=fromx;xx<=tox;xx++)
1237 for(yy=fromy;yy<=toy;yy++) {
1238 int b = 1-data[width*yy+xx];
1240 if(xx==fromx) weight = (weight*xweight1)/256;
1241 if(xx==tox) weight = (weight*xweight2)/256;
1242 if(yy==fromy) weight = (weight*yweight1)/256;
1243 if(yy==toy) weight = (weight*yweight2)/256;
1246 //if(a) a=(palettesize-1)*r/blocksize;
1247 newdata[y*newwidth+x] = (a*blocksize)/r;
1255 void SWFOutputDev::drawGeneralImage(GfxState *state, Object *ref, Stream *str,
1256 int width, int height, GfxImageColorMap*colorMap, GBool invert,
1257 GBool inlineImg, int mask)
1262 double x1,y1,x2,y2,x3,y3,x4,y4;
1263 ImageStream *imgStr;
1270 ncomps = colorMap->getNumPixelComps();
1271 bits = colorMap->getBits();
1273 imgStr = new ImageStream(str, width, ncomps,bits);
1276 if(!width || !height || (height<=1 && width<=1))
1278 msg("<verbose> Ignoring %d by %d image", width, height);
1279 unsigned char buf[8];
1281 for (y = 0; y < height; ++y)
1282 for (x = 0; x < width; ++x) {
1283 imgStr->getPixel(buf);
1289 state->transform(0, 1, &x1, &y1);
1290 state->transform(0, 0, &x2, &y2);
1291 state->transform(1, 0, &x3, &y3);
1292 state->transform(1, 1, &x4, &y4);
1294 if(!pbminfo && !(str->getKind()==strDCT)) {
1296 msg("<notice> file contains pbm pictures %s",mask?"(masked)":"");
1300 msg("<verbose> drawing %d by %d masked picture\n", width, height);
1302 if(!jpeginfo && (str->getKind()==strDCT)) {
1303 msg("<notice> file contains jpeg pictures");
1309 unsigned char buf[8];
1313 unsigned char*pic = new unsigned char[width*height];
1316 state->getFillRGB(&rgb);
1317 memset(pal,255,sizeof(pal));
1318 pal[0].r = (int)(rgb.r*255); pal[0].g = (int)(rgb.g*255);
1319 pal[0].b = (int)(rgb.b*255); pal[0].a = 255;
1320 pal[1].r = 0; pal[1].g = 0; pal[1].b = 0; pal[1].a = 0;
1322 xid += pal[1].r*3 + pal[1].g*11 + pal[1].b*17;
1323 yid += pal[1].r*7 + pal[1].g*5 + pal[1].b*23;
1324 int realwidth = (int)sqrt(SQR(x2-x3) + SQR(y2-y3));
1325 int realheight = (int)sqrt(SQR(x1-x2) + SQR(y1-y2));
1326 for (y = 0; y < height; ++y)
1327 for (x = 0; x < width; ++x)
1329 imgStr->getPixel(buf);
1332 pic[width*y+x] = buf[0];
1337 /* the size of the drawn image is added to the identifier
1338 as the same image may require different bitmaps if displayed
1339 at different sizes (due to antialiasing): */
1345 for(t=0;t<picpos;t++)
1347 if(pic_xids[t] == xid &&
1348 pic_yids[t] == yid) {
1349 /* if the image was antialiased, the size has changed: */
1350 width = pic_width[t];
1351 height = pic_height[t];
1358 unsigned char*pic2 = 0;
1360 pic2 = antialize(pic,width,height,realwidth,realheight, numpalette);
1364 height = realheight;
1367 /* make a black/white palette */
1374 float r = 255/(numpalette-1);
1375 for(t=0;t<numpalette;t++) {
1376 /*pal[t].r = (U8)(t*r*rgb.r+(numpalette-1-t)*r*rgb2.r);
1377 pal[t].g = (U8)(t*r*rgb.g+(numpalette-1-t)*r*rgb2.g);
1378 pal[t].b = (U8)(t*r*rgb.b+(numpalette-1-t)*r*rgb2.b);
1380 pal[t].r = (U8)(255*rgb.r);
1381 pal[t].g = (U8)(255*rgb.g);
1382 pal[t].b = (U8)(255*rgb.b);
1383 pal[t].a = (U8)(t*r);
1387 pic_ids[picpos] = swfoutput_drawimagelosslessN(&output, pic, pal, width, height,
1388 x1,y1,x2,y2,x3,y3,x4,y4, numpalette);
1389 pic_xids[picpos] = xid;
1390 pic_yids[picpos] = yid;
1391 pic_width[picpos] = width;
1392 pic_height[picpos] = height;
1396 swfoutput_drawimageagain(&output, pic_ids[found], width, height,
1397 x1,y1,x2,y2,x3,y3,x4,y4);
1406 if(colorMap->getNumPixelComps()!=1 || str->getKind()==strDCT)
1408 RGBA*pic=new RGBA[width*height];
1411 for (y = 0; y < height; ++y) {
1412 for (x = 0; x < width; ++x) {
1414 imgStr->getPixel(pixBuf);
1415 colorMap->getRGB(pixBuf, &rgb);
1416 pic[width*y+x].r = r = (U8)(rgb.r * 255 + 0.5);
1417 pic[width*y+x].g = g = (U8)(rgb.g * 255 + 0.5);
1418 pic[width*y+x].b = b = (U8)(rgb.b * 255 + 0.5);
1419 pic[width*y+x].a = a = 255;//(U8)(rgb.a * 255 + 0.5);
1420 xid += x*r+x*b*3+x*g*7+x*a*11;
1421 yid += y*r*3+y*b*17+y*g*19+y*a*11;
1425 for(t=0;t<picpos;t++)
1427 if(pic_xids[t] == xid &&
1428 pic_yids[t] == yid) {
1433 if(str->getKind()==strDCT)
1434 pic_ids[picpos] = swfoutput_drawimagejpeg(&output, pic, width, height,
1435 x1,y1,x2,y2,x3,y3,x4,y4);
1437 pic_ids[picpos] = swfoutput_drawimagelossless(&output, pic, width, height,
1438 x1,y1,x2,y2,x3,y3,x4,y4);
1439 pic_xids[picpos] = xid;
1440 pic_yids[picpos] = yid;
1441 pic_width[picpos] = width;
1442 pic_height[picpos] = height;
1446 swfoutput_drawimageagain(&output, pic_ids[found], width, height,
1447 x1,y1,x2,y2,x3,y3,x4,y4);
1455 U8*pic = new U8[width*height];
1463 colorMap->getRGB(pixBuf, &rgb);
1464 pal[t].r = r = (U8)(rgb.r * 255 + 0.5);
1465 pal[t].g = g = (U8)(rgb.g * 255 + 0.5);
1466 pal[t].b = b = (U8)(rgb.b * 255 + 0.5);
1467 pal[t].a = a = 255;//(U8)(rgb.b * 255 + 0.5);
1468 xid += t*r+t*b*3+t*g*7+t*a*11;
1469 xid += (~t)*r+t*b*3+t*g*7+t*a*11;
1471 for (y = 0; y < height; ++y) {
1472 for (x = 0; x < width; ++x) {
1473 imgStr->getPixel(pixBuf);
1474 pic[width*y+x] = pixBuf[0];
1475 xid += x*pixBuf[0]*7;
1476 yid += y*pixBuf[0]*3;
1480 for(t=0;t<picpos;t++)
1482 if(pic_xids[t] == xid &&
1483 pic_yids[t] == yid) {
1488 pic_ids[picpos] = swfoutput_drawimagelosslessN(&output, pic, pal, width, height,
1489 x1,y1,x2,y2,x3,y3,x4,y4,256);
1490 pic_xids[picpos] = xid;
1491 pic_yids[picpos] = yid;
1492 pic_width[picpos] = width;
1493 pic_height[picpos] = height;
1497 swfoutput_drawimageagain(&output, pic_ids[found], width, height,
1498 x1,y1,x2,y2,x3,y3,x4,y4);
1506 void SWFOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
1507 int width, int height, GBool invert,
1510 msg("<verbose> drawImageMask %dx%d, invert=%d inline=%d", width, height, invert, inlineImg);
1511 drawGeneralImage(state,ref,str,width,height,0,invert,inlineImg,1);
1514 void SWFOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
1515 int width, int height, GfxImageColorMap *colorMap,
1516 int *maskColors, GBool inlineImg)
1518 msg("<verbose> drawImage %dx%d, %s %s, inline=%d", width, height,
1519 colorMap?"colorMap":"no colorMap",
1520 maskColors?"maskColors":"no maskColors",
1523 msg("<verbose> colorMap pixcomps:%d bits:%d mode:%d\n", colorMap->getNumPixelComps(),
1524 colorMap->getBits(),colorMap->getColorSpace()->getMode());
1525 drawGeneralImage(state,ref,str,width,height,colorMap,0,inlineImg,0);
1528 SWFOutputDev*output = 0;
1530 static void printInfoString(Dict *infoDict, char *key, char *fmt) {
1535 if (infoDict->lookup(key, &obj)->isString()) {
1536 s1 = obj.getString();
1537 if ((s1->getChar(0) & 0xff) == 0xfe &&
1538 (s1->getChar(1) & 0xff) == 0xff) {
1540 for (i = 2; i < obj.getString()->getLength(); i += 2) {
1541 if (s1->getChar(i) == '\0') {
1542 s2->append(s1->getChar(i+1));
1545 s2 = new GString("<unicode>");
1549 printf(fmt, s2->getCString());
1552 printf(fmt, s1->getCString());
1558 static void printInfoDate(Dict *infoDict, char *key, char *fmt) {
1562 if (infoDict->lookup(key, &obj)->isString()) {
1563 s = obj.getString()->getCString();
1564 if (s[0] == 'D' && s[1] == ':') {
1572 void pdfswf_init(char*filename, char*userPassword)
1574 GString *fileName = new GString(filename);
1579 globalParams = new GlobalParams("");
1582 if (userPassword && userPassword[0]) {
1583 userPW = new GString(userPassword);
1587 doc = new PDFDoc(fileName, userPW);
1596 doc->getDocInfo(&info);
1597 if (info.isDict() &&
1598 (screenloglevel>=LOGLEVEL_NOTICE)) {
1599 printInfoString(info.getDict(), "Title", "Title: %s\n");
1600 printInfoString(info.getDict(), "Subject", "Subject: %s\n");
1601 printInfoString(info.getDict(), "Keywords", "Keywords: %s\n");
1602 printInfoString(info.getDict(), "Author", "Author: %s\n");
1603 printInfoString(info.getDict(), "Creator", "Creator: %s\n");
1604 printInfoString(info.getDict(), "Producer", "Producer: %s\n");
1605 printInfoDate(info.getDict(), "CreationDate", "CreationDate: %s\n");
1606 printInfoDate(info.getDict(), "ModDate", "ModDate: %s\n");
1607 printf("Pages: %d\n", doc->getNumPages());
1608 printf("Linearized: %s\n", doc->isLinearized() ? "yes" : "no");
1609 printf("Encrypted: ");
1610 if (doc->isEncrypted()) {
1611 printf("yes (print:%s copy:%s change:%s addNotes:%s)\n",
1612 doc->okToPrint() ? "yes" : "no",
1613 doc->okToCopy() ? "yes" : "no",
1614 doc->okToChange() ? "yes" : "no",
1615 doc->okToAddNotes() ? "yes" : "no");
1622 numpages = doc->getNumPages();
1623 if (doc->isEncrypted()) {
1624 /*ERROR: This pdf is encrypted, and disallows copying.
1625 Due to the DMCA, paragraph 1201, (2) A-C, circumventing
1626 a technological measure that efficively controls access to
1627 a protected work is violating American law.
1628 See www.eff.org for more information about DMCA issues.
1630 if(!doc->okToCopy()) {
1631 printf("PDF disallows copying. Bailing out.\n");
1634 if(!doc->okToChange() || !doc->okToAddNotes())
1635 swfoutput_setprotected();
1638 output = new SWFOutputDev();
1639 output->startDoc(doc->getXRef());
1642 void pdfswf_setparameter(char*name, char*value)
1644 if(!strcmp(name, "drawonlyshapes")) {
1645 drawonlyshapes = atoi(value);
1646 } else if(!strcmp(name, "ignoredraworder")) {
1647 ignoredraworder = atoi(value);
1648 } else if(!strcmp(name, "linksopennewwindow")) {
1649 opennewwindow = atoi(value);
1650 } else if(!strcmp(name, "storeallcharacters")) {
1651 storeallcharacters = atoi(value);
1652 } else if(!strcmp(name, "enablezlib")) {
1653 enablezlib = atoi(value);
1654 } else if(!strcmp(name, "insertstop")) {
1655 insertstoptag = atoi(value);
1656 } else if(!strcmp(name, "flashversion")) {
1657 flashversion = atoi(value);
1658 } else if(!strcmp(name, "jpegquality")) {
1659 int val = atoi(value);
1661 if(val>100) val=100;
1663 } else if(!strcmp(name, "outputfilename")) {
1664 swffilename = value;
1665 } else if(!strcmp(name, "caplinewidth")) {
1666 caplinewidth = atof(value);
1667 } else if(!strcmp(name, "splinequality")) {
1668 int v = atoi(value);
1669 v = 500-(v*5); // 100% = 0.25 pixel, 0% = 25 pixel
1672 } else if(!strcmp(name, "fontquality")) {
1673 int v = atoi(value);
1674 v = 500-(v*5); // 100% = 0.25 pixel, 0% = 25 pixel
1676 fontsplinemaxerror = v;
1678 fprintf(stderr, "unknown parameter: %s (=%s)\n", name, value);
1682 void pdfswf_addfont(char*filename)
1684 fonts[fontnum++] = filename;
1687 void pdfswf_drawonlyshapes()
1692 void pdfswf_ignoredraworder()
1694 ignoredraworder = 1;
1697 void pdfswf_linksopennewwindow()
1702 void pdfswf_storeallcharacters()
1704 storeallcharacters = 1;
1707 void pdfswf_enablezlib()
1712 void pdfswf_jpegquality(int val)
1715 if(val>100) val=100;
1719 void pdfswf_setoutputfilename(char*_filename)
1721 swffilename = _filename;
1724 void pdfswf_insertstop()
1729 void pdfswf_setversion(int n)
1735 void pdfswf_convertpage(int page)
1739 pages = (int*)malloc(1024*sizeof(int));
1742 if(pagepos == pagebuflen)
1745 pages = (int*)realloc(pages, pagebuflen);
1748 pages[pagepos++] = page;
1751 void pdfswf_performconversion()
1754 for(t=0;t<pagepos;t++)
1756 currentpage = pages[t];
1757 doc->displayPage((OutputDev*)output, currentpage, /*dpi*/72, /*rotate*/0, /*doLinks*/(int)1);
1761 int pdfswf_numpages()
1763 return doc->getNumPages();
1768 msg("<debug> pdfswf.cc: pdfswf_close()");
1772 // check for memory leaks
1773 Object::memCheck(stderr);