#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 <sys/time.h>
Go to the source code of this file.
Defines | |
#define | AppName "xpdf" |
Functions | |
int | get_cur_time () |
Get current time. | |
int | main (int argc, char *argv[]) |
#define AppName "xpdf" |
Copyright (C) 2008 iRex Technologies B.V. All rights reserved.
Definition at line 43 of file poppler_test.cpp.
int get_cur_time | ( | ) |
Get current time.
Definition at line 56 of file poppler_test.cpp.
Referenced by main().
00057 { 00058 int now; 00059 #ifdef WIN32 00060 now = GetTickCount(); 00061 #else 00062 struct timeval cur_time_struct; 00063 gettimeofday(&cur_time_struct, 0); 00064 now = cur_time_struct.tv_sec; 00065 #endif 00066 return now; 00067 }
int main | ( | int | argc, | |
char * | argv[] | |||
) |
Definition at line 69 of file poppler_test.cpp.
References get_cur_time(), name, and white.
00070 { 00071 00072 printf("open file %s\n", argv[1]); 00073 GooString * name = new GooString(argv[1]); 00074 #ifdef WIN32 00075 globalParams = new GlobalParams(""); 00076 #else 00077 globalParams = new GlobalParams(); 00078 #endif 00079 SplashColor white; 00080 white[0] = 255; 00081 white[1] = 255; 00082 white[2] = 255; 00083 SplashColorMode mode = splashModeMono8; 00084 printf("Use Mono8 mode\n"); 00085 // SplashColorMode mode = splashModeRGB8; 00086 SplashOutputDev * outputDev = new SplashOutputDev(mode/*Packed*/, 4, gFalse, white); 00087 00088 PDFDoc * pdfdoc = new PDFDoc(name); 00089 00090 if (!pdfdoc->isOk()) 00091 { 00092 printf("could not open doc %s\n", argv[1]); 00093 return -1; 00094 } 00095 00096 double zoom = 100.0f; 00097 if (argc >= 3) 00098 { 00099 zoom = atof(argv[2]); 00100 } 00101 00102 double hDPI = zoom * 0.01 * 150; 00103 double vDPI = zoom * 0.01 * 150; 00104 int rotate = 0; 00105 printf("start docuemnt pages %d\n", pdfdoc->getNumPages()); 00106 outputDev->startDoc(pdfdoc->getXRef()); 00107 printf("start document done!\n"); 00108 00109 for(int i = 1; i <= pdfdoc->getNumPages(); ++i) 00110 { 00111 printf("render page %d, zoom:%f, crop width:%f, crop height:%f\n", i 00112 , zoom 00113 , pdfdoc->getPageCropWidth(i) 00114 , pdfdoc->getPageCropHeight(i)); 00115 int cur_time = get_cur_time(); 00116 RenderRet ret = 00117 pdfdoc->displayPage(outputDev, i, hDPI, vDPI, rotate, gFalse, gTrue, gTrue); 00118 00119 00120 printf("consume time:%d, result: %s\n", get_cur_time() - cur_time, ret == Render_Done ? "Done" : "Abort"); 00121 } 00122 00123 return 0; 00124 00125 }