X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=pdf2swf%2FSWFOutputDev.cc;h=8e8c1f7a0dba822a72e9a886882570bbe6264d3f;hb=4bfcb7ae5fe91167cfce574142c7acd100745459;hp=ad411a934d0d39f9d8ada82d5dfa3685f1345500;hpb=864398ba4b887122ae6fa04f8eb2e9d630b990a5;p=swftools.git diff --git a/pdf2swf/SWFOutputDev.cc b/pdf2swf/SWFOutputDev.cc index ad411a9..8e8c1f7 100644 --- a/pdf2swf/SWFOutputDev.cc +++ b/pdf2swf/SWFOutputDev.cc @@ -45,11 +45,18 @@ #include "GfxFont.h" #include "CharCodeToUnicode.h" #include "NameToUnicodeTable.h" -#include "FontFile.h" #include "GlobalParams.h" +//#define XPDF_101 +#ifdef XPDF_101 +#include "FontFile.h" +#else +#include "FoFiType1C.h" +#include "FoFiTrueType.h" +#endif +#include "SWFOutputDev.h" + //swftools header files #include "swfoutput.h" -#include "SWFOutputDev.h" #include "../lib/log.h" #include @@ -650,9 +657,6 @@ void SWFOutputDev::beginString(GfxState *state, GString *s) m11 *= state->getHorizScaling(); m21 *= state->getHorizScaling(); swfoutput_setfontmatrix(&output, m11, -m21, m12, -m22); - - msg(" fontmatrix %7.3f %7.3f\n", m11,-m21); - msg(" fontmatrix %7.3f %7.3f\n", m12,-m22); } void SWFOutputDev::drawChar(GfxState *state, double x, double y, @@ -736,8 +740,6 @@ void SWFOutputDev::startPage(int pageNum, GfxState *state, double crop_x1, doubl if(rot!=0) msg(" page is rotated %d degrees\n", rot); - msg(" processing page %d", pageNum); - /* state->transform(state->getX1(),state->getY1(),&x1,&y1); state->transform(state->getX2(),state->getY2(),&x2,&y2); Use CropBox, not MediaBox, as page size @@ -755,11 +757,11 @@ void SWFOutputDev::startPage(int pageNum, GfxState *state, double crop_x1, doubl if(!outputstarted) { msg(" Bounding box is (%f,%f)-(%f,%f)", x1,y1,x2,y2); - swfoutput_init(&output, swffilename,(int)x1,(int)y1,(int)x2,(int)y2); + swfoutput_init(&output, swffilename); outputstarted = 1; } - else - swfoutput_newpage(&output); + + swfoutput_newpage(&output, pageNum, (int)x1, (int)y1, (int)x2, (int)y2); } void SWFOutputDev::drawLink(Link *link, Catalog *catalog) @@ -770,7 +772,11 @@ void SWFOutputDev::drawLink(Link *link, Catalog *catalog) swfcoord points[5]; int x, y; +#ifdef XPDF_101 link->getBorder(&x1, &y1, &x2, &y2, &w); +#else + link->getRect(&x1, &y1, &x2, &y2); +#endif // if (w > 0) { rgb.r = 0; @@ -1001,6 +1007,11 @@ void SWFOutputDev::updateStrokeColor(GfxState *state) (char)(rgb.b*255), (char)(opaq*255)); } +void FoFiWrite(void *stream, char *data, int len) +{ + fwrite(data, len, 1, (FILE*)stream); +} + char*SWFOutputDev::writeEmbeddedFontToFile(XRef*ref, GfxFont*font) { char*tmpFileName = NULL; @@ -1041,8 +1052,13 @@ char*SWFOutputDev::writeEmbeddedFontToFile(XRef*ref, GfxFont*font) msg(" Couldn't read embedded font file"); return 0; } +#ifdef XPDF_101 Type1CFontFile *cvt = new Type1CFontFile(fontBuf, fontLen); cvt->convertToType1(f); +#else + FoFiType1C *cvt = FoFiType1C::make(fontBuf, fontLen); + cvt->convertToType1(NULL, gTrue, FoFiWrite, f); +#endif //cvt->convertToCIDType0("test", f); //cvt->convertToType0("test", f); delete cvt; @@ -1054,8 +1070,13 @@ char*SWFOutputDev::writeEmbeddedFontToFile(XRef*ref, GfxFont*font) msg(" Couldn't read embedded font file"); return 0; } +#ifdef XPDF_101 TrueTypeFontFile *cvt = new TrueTypeFontFile(fontBuf, fontLen); cvt->writeTTF(f); +#else + FoFiTrueType *cvt = FoFiTrueType::make(fontBuf, fontLen); + cvt->writeTTF(FoFiWrite, f); +#endif delete cvt; gfree(fontBuf); } else { @@ -1795,27 +1816,7 @@ void pdfswf_addfont(char*filename) fonts[fontnum++] = f; } -/* TODO: get rid of this */ -void pdfswf_drawonlyshapes() { pdfswf_setparameter("drawonlyshapes", "1"); } -void pdfswf_ignoredraworder() { pdfswf_setparameter("ignoredraworder", "1"); } -void pdfswf_linksopennewwindow() { pdfswf_setparameter("opennewwindow", "1"); } -void pdfswf_storeallcharacters() { pdfswf_setparameter("storeallcharacters", "1"); } -void pdfswf_enablezlib() { pdfswf_setparameter("enablezlib", "1"); } void pdfswf_setoutputfilename(char*_filename) { swffilename = _filename; } -void pdfswf_insertstop() { pdfswf_setparameter("insertstoptag", "1"); } - -void pdfswf_jpegquality(int val) { - char tmp[32]; - sprintf(tmp, "%d", val); - pdfswf_setparameter("jpegquality", tmp); -} -void pdfswf_setversion(int n) { - char tmp[32]; - sprintf(tmp, "%d", n); - pdfswf_setparameter("flashversion", tmp); -} - - void pdfswf_convertpage(int page) { @@ -1839,7 +1840,11 @@ void pdfswf_performconversion() for(t=0;tdisplayPage((OutputDev*)output, currentpage, /*zoom*/zoom, /*rotate*/0, /*doLinks*/(int)1); +#else + doc->displayPage((OutputDev*)output, currentpage, zoom, zoom, /*rotate*/0, true, /*doLinks*/(int)1); +#endif } } int pdfswf_numpages()