#include <stdio.h>
#include "goo/GooList.h"
#include "poppler/GlobalParams.h"
#include "poppler/Object.h"
#include "poppler/Link.h"
#include "goo/GooString.h"
#include "poppler/PDFDoc.h"
#include "poppler/SplashOutputDev.h"
#include "splash/SplashTypes.h"
#include <unistd.h>
#include <sys/time.h>
#include <time.h>
Go to the source code of this file.
Defines | |
#define | AppName "xpdf" |
Functions | |
int | main (int argc, char *argv[]) |
int main | ( | int | argc, | |
char * | argv[] | |||
) |
Definition at line 16 of file test.cc.
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/*Packed*/, 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 // const int SCREEN_WIDTH = 768; 00044 // const int SCREEN_HEIGHT = 1024; 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 }