#include "../lib/rfxswf.h"
#include "../lib/devices/swf.h"
#include "../lib/devices/arts.h"
-#include "../lib/xpdf/pdf.h"
+#include "../lib/devices/record.h"
+#include "../lib/pdf/pdf.h"
#include "../lib/log.h"
#define SWFDIR concatPaths(getInstallationPath(), "swfs")
static int xnup = 1;
static int ynup = 1;
+static int info_only = 0;
+
static int flatten = 0;
char* fontpaths[256];
driver->set_parameter("opennewwindow", "1");
return 0;
}
+ else if (!strcmp(name, "I"))
+ {
+ info_only = 1;
+ return 0;
+ }
else if (!strcmp(name, "t"))
{
driver->set_parameter("insertstop", "1");
{"q","quiet"},
{"V","version"},
{"i","ignore"},
+ {"I","info"},
{"z","zlib"},
{"s","set"},
{"S","shapes"},
return swf.frameRate / 256.0;
}
+void show_info(gfxsource_t*driver, char*filename)
+{
+ gfxdocument_t* pdf = driver->open(filename);
+ int pagenr;
+ FILE*fo=0;
+ if(!pdf) {
+ msg("<error> Couldn't open %s", filename);
+ exit(1);
+ }
+ if(outputname) {
+ fo = fopen(outputname, "wb");
+ if(!fo) {
+ perror(outputname);exit(1);;
+ }
+ } else {
+ fo = stdout;
+ }
+
+ for(pagenr = 1; pagenr <= pdf->num_pages; pagenr++)
+ {
+ gfxpage_t*page = pdf->getpage(pdf,pagenr);
+ if(is_in_range(pagenr, pagerange)) {
+ fprintf(fo, "page=%d width=%.2f height=%.2f\n", pagenr, page->width, page->height);
+ }
+ }
+ pdf->destroy(pdf);
+}
+
int main(int argn, char *argv[])
{
int ret;
initLog(0,-1,0,0,-1,loglevel);
- driver = gfxsource_pdf_create();
-
#if defined(WIN32) && defined(HAVE_STAT) && defined(HAVE_SYS_STAT_H)
if(installPath) {
fontdir = concatPaths(installPath, "fonts");
srand(time(0));
#endif
#endif
- processargs(argn, argv);
+ driver = gfxsource_pdf_create();
+ processargs(argn, argv);
+
if(!filename)
{
fprintf(stderr, "Please specify an input file\n");
exit(1);
}
+ if(info_only) {
+ show_info(driver, filename);
+ return 0;
+ }
+
if(!outputname)
{
if(filename) {
// test if the page range is o.k.
is_in_range(0x7fffffff, pagerange);
+ if(pagerange)
+ driver->set_parameter("pages", pagerange);
+
if (!filename) {
args_callback_usage(argv[0]);
exit(0);
gfxdevice_t*out;
if(flatten) {
- gfxdevice_arts_init(&wrap, &swf);
+ gfxdevice_removeclippings_init(&wrap, &swf);
out = &wrap;
} else {
out = &swf;
int t = y*xnup + x;
if(pages[t].page->width > xmax[x])
- xmax[x] = pages[t].page->width;
+ xmax[x] = (int)pages[t].page->width;
if(pages[t].page->height > ymax[y])
- ymax[y] = pages[t].page->height;
+ ymax[y] = (int)pages[t].page->height;
}
for(x=0;x<xnup;x++) {
width += xmax[x];
}
gfxresult_t*result = out->finish(out);
+
if(result->save(result, outputname) < 0) {
exit(1);
}