X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=pdf2swf%2FSWFOutputDev.cc;h=6af41024cb1fae099ab5facb6ea714980e097fc5;hb=d78d39d495201b40537d2c38d42ab34c60467865;hp=5d53fbdf8c0c0d5f505c58c540b63ebaa0b51375;hpb=0e916263b32f4920c2f5581caa77985bf1992081;p=swftools.git diff --git a/pdf2swf/SWFOutputDev.cc b/pdf2swf/SWFOutputDev.cc index 5d53fbd..6af4102 100644 --- a/pdf2swf/SWFOutputDev.cc +++ b/pdf2swf/SWFOutputDev.cc @@ -23,6 +23,7 @@ #include #include //xpdf header files +#include "gfile.h" #include "GString.h" #include "gmem.h" #include "Object.h" @@ -408,7 +409,7 @@ T1_OUTLINE* gfxPath_to_T1_OUTLINE(GfxState*state, GfxPath*path) { int num = path->getNumSubpaths(); int s,t; - bezierpathsegment*start,*last; + bezierpathsegment*start,*last=0; bezierpathsegment*outline = start = new bezierpathsegment(); int cpos = 0; double lastx=0,lasty=0; @@ -547,7 +548,7 @@ void SWFOutputDev::beginString(GfxState *state, GString *s) state->getFontTransMat(&m11, &m12, &m21, &m22); m11 *= state->getHorizScaling(); m21 *= state->getHorizScaling(); - swfoutput_setfontmatrix(&output, m11, -m12, m21, -m22); + swfoutput_setfontmatrix(&output, m11, -m21, m12, -m22); } int charcounter = 0; @@ -630,6 +631,7 @@ void SWFOutputDev::drawLink(Link *link, Catalog *catalog) char*s = "-?-"; char*type = "-?-"; char*url = 0; + char*named = 0; int page = -1; switch(action->getKind()) { @@ -665,6 +667,7 @@ void SWFOutputDev::drawLink(Link *link, Catalog *catalog) GString*name = l->getName(); if(name) { s = name->lowerCase()->getCString(); + named = name->getCString(); if(strstr(s, "next") || strstr(s, "forward")) { page = currentpage + 1; @@ -731,6 +734,10 @@ void SWFOutputDev::drawLink(Link *link, Catalog *catalog) { swfoutput_linktourl(&output, url, points); } + else if(named) + { + swfoutput_namedlink(&output, named, points); + } logf(" \"%s\" link to \"%s\" (%d)\n", type, s, page); } } @@ -860,14 +867,14 @@ char*SWFOutputDev::writeEmbeddedFontToFile(GfxFont*font) ttfinfo = 1; } char name2[80]; - int r1 = lrand48(); - int r2 = lrand48(); - sprintf(name2,"%04x%04x",r1,r2); + char*tmp; + tmp = strdup(mktmpname((char*)name2)); + sprintf(name2, "%s", tmp); char*a[] = {"./ttf2pt1","-pttf","-b", tmpFileName, name2}; logf(" Invoking ttf2pt1..."); ttf2pt1_main(5,a); unlink(tmpFileName); - sprintf(name2,"%04x%04x.pfb",r1,r2); + sprintf(name2,"%s.pfb",tmp); tmpFileName = strdup(name2); } @@ -973,10 +980,12 @@ char* SWFOutputDev::substituteFont(GfxFont*gfxFont, char* oldname) logf(" Too many fonts in file."); exit(1); } - substitutesource[substitutepos] = oldname; - substitutetarget[substitutepos] = fontname; - logf(" substituting %s -> %s", oldname, fontname); - substitutepos ++; + if(oldname) { + substitutesource[substitutepos] = oldname; + substitutetarget[substitutepos] = fontname; + logf(" substituting %s -> %s", oldname, fontname); + substitutepos ++; + } return fontname; } @@ -1080,6 +1089,7 @@ void SWFOutputDev::updateFont(GfxState *state) if(t1id<0) { showFontError(gfxFont,0); + return; } /* we may have done some substitutions here, so check @@ -1135,7 +1145,7 @@ void SWFOutputDev::drawGeneralImage(GfxState *state, Object *ref, Stream *str, if (str->getKind() == strDCT && (colorMap->getNumPixelComps() == 3 || !mask) ) { - sprintf(fileName, "/tmp/tmp%08x.jpg",lrand48()); + sprintf(fileName, "%s.jpg",mktmpname(0)); logf(" Found jpeg. Temporary storage is %s", fileName); if(!jpeginfo) { @@ -1192,7 +1202,7 @@ void SWFOutputDev::drawGeneralImage(GfxState *state, Object *ref, Stream *str, if(mask) { imgStr = new ImageStream(str, width, 1, 1); imgStr->reset(); - return; + //return; int yes=0,i,j; unsigned char buf[8]; int xid = 0; @@ -1524,7 +1534,7 @@ void pdfswf_performconversion() for(t=0;tdisplayPage((OutputDev*)output, currentpage, /*zoom*/100, /*rotate*/0, /*doLinks*/(int)1); + doc->displayPage((OutputDev*)output, currentpage, /*dpi*/72, /*rotate*/0, /*doLinks*/(int)1); } }