00001 #include <stdio.h>
00002 #include "goo/GooList.h"
00003 #include "poppler/GlobalParams.h"
00004 #include "poppler/Object.h"
00005 #include "poppler/Link.h"
00006 #include "goo/GooString.h"
00007 #include "poppler/PDFDoc.h"
00008 #include "poppler/SplashOutputDev.h"
00009 #include "splash/SplashTypes.h"
00010 #include <unistd.h>
00011 #include <sys/time.h>
00012 #include <time.h>
00013
00014 #define AppName "xpdf"
00015
00016 int main(int argc, char * argv[])
00017 {
00018
00019 printf("open file %s\n", argv[1]);
00020 GooString * name = new GooString(argv[1]);
00021
00022
00023
00024 globalParams = new GlobalParams("");
00025
00026 SplashColor white;
00027 white[0] = 255;
00028 white[1] = 255;
00029 white[2] = 255;
00030 SplashColorMode mode = splashModeRGB8;
00031 SplashOutputDev * outputDev = new SplashOutputDev(mode, 4, gFalse, white);
00032 printf("outputdev %d\n",(int)outputDev);
00033
00034 PDFDoc * pdfdoc = new PDFDoc(name);
00035
00036
00037 if (!pdfdoc->isOk())
00038 {
00039 printf("could not open doc %s\n", argv[1]);
00040 return -1;
00041 }
00042
00043
00044
00045 double zoom = 200;
00046 double hDPI = zoom * 0.01 * 72;
00047 double vDPI = zoom * 0.01 * 72;
00048 int rotate = 0;
00049 printf("start docuemnt pages %d\n", pdfdoc->getNumPages());
00050 outputDev->startDoc(pdfdoc->getXRef());
00051 printf("start document done!\n");
00052 struct timeval t1, t2;
00053 for(int i = 1; i <= pdfdoc->getNumPages(); ++i)
00054 {
00055 printf("render page %d\n", i);
00056 gettimeofday(&t1, NULL);
00057 pdfdoc->displayPage(outputDev, i, hDPI, vDPI, rotate, gFalse, gTrue, gTrue);
00058 gettimeofday(&t2, NULL);
00059
00060 float cost = (float)(((t2.tv_sec - t1.tv_sec) * 1000 * 1000) + (t2.tv_usec - t1.tv_usec));
00061 printf("page %d time %lf\n", i, cost/(1000*1000));
00062 }
00063
00064 return 0;
00065
00066 }