X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=pdf2swf%2Fpdf2swf.cc;fp=pdf2swf%2Fpdf2swf.cc;h=84bd1feab64e20ad22e24c54c4998f76fcdb691b;hp=fc6bad18826bc8548a09e16b95cb39d55da79a0b;hb=d6224470857155687b11b1e3d4cfa13c6aba8b95;hpb=3c35bf20441ec1fec554a085e1b29a1dadf8b46d diff --git a/pdf2swf/pdf2swf.cc b/pdf2swf/pdf2swf.cc index fc6bad1..84bd1fe 100644 --- a/pdf2swf/pdf2swf.cc +++ b/pdf2swf/pdf2swf.cc @@ -34,6 +34,8 @@ #include "../lib/args.h" #include "../lib/os.h" #include "../lib/rfxswf.h" +#include "../lib/devices/swf.h" +//#include "../lib/devices/render.h" #include "SWFOutputDev.h" #include "log.h" @@ -55,6 +57,12 @@ static int ynup = 1; char* fontpaths[256]; int fontpathpos = 0; +int move_x=0; +int move_y=0; +int custom_move = 0; +int clip_x1=0,clip_y1=0,clip_x2=0,clip_y2=0; +int custom_clip = 0; + static int system_quiet=0; int systemf(const char* format, ...) @@ -135,6 +143,40 @@ int args_callback_option(char*name,char*val) { password = val; return 1; } + else if (!strcmp(name, "c")) + { + char*s = strdup(val); + char*x1 = strtok(s, ":"); + char*y1 = strtok(0, ":"); + char*x2 = strtok(0, ":"); + char*y2 = strtok(0, ":"); + if(!(x1 && y1 && x2 && y2)) { + fprintf(stderr, "-m option requires four arguments, :::\n"); + exit(1); + } + custom_clip = 1; + clip_x1 = atoi(x1); + clip_y1 = atoi(y1); + clip_x2 = atoi(x2); + clip_y2 = atoi(y2); + free(s); + return 1; + } + else if (!strcmp(name, "m")) + { + char*s = strdup(val); + char*c = strchr(s, ':'); + if(!c) { + fprintf(stderr, "-m option requires two arguments, :\n"); + exit(1); + } + *c = 0; + custom_move = 1; + move_x = atoi(val); + move_y = atoi(c+1); + free(s); + return 1; + } else if (!strcmp(name, "s")) { char*s = strdup(val); @@ -459,7 +501,10 @@ int main(int argn, char *argv[]) exit(1); } - swf_output_t* swf = swf_output_init(); + gfxdevice_t swfdev; + gfxdevice_swf_init(&swfdev); + //gfxdevice_render_init(&swfdev); + dev_output_t* swf = dev_output_init(&swfdev); struct mypage_t { int x; @@ -474,7 +519,7 @@ int main(int argn, char *argv[]) for(int pagenr = 1; pagenr <= pdf->num_pages; pagenr++) { if(is_in_range(pagenr, pagerange)) { - swf_output_preparepage(swf, pagenr, frame); + dev_output_preparepage(swf, pagenr, frame); pagenum++; } if(pagenum == xnup*ynup || (pagenr == pdf->num_pages && pagenum>1)) { @@ -523,7 +568,7 @@ int main(int argn, char *argv[]) height += ymax[y]; ymax[y] = height; } - swf_output_startframe(swf, width, height); + dev_output_startframe(swf, width, height); for(t=0;tyMin + ypos, info->xMax + xpos, info->yMax + ypos, xpos, ypos); - pdf_page_rendersection(pages[t].page, swf, xpos, - ypos, - info->xMin + xpos, - info->yMin + ypos, - info->xMax + xpos, - info->yMax + ypos); + pdf_page_rendersection(pages[t].page, swf, custom_move? move_x : xpos, + custom_move? move_y : ypos, + custom_clip? clip_x1 : info->xMin + xpos, + custom_clip? clip_y1 : info->yMin + ypos, + custom_clip? clip_x2 : info->xMax + xpos, + custom_clip? clip_y2 : info->yMax + ypos); } - swf_output_endframe(swf); + dev_output_endframe(swf); for(t=0;tsave(result, outputname) < 0) { exit(1); } - int width = (int)swf_output_get(swf, "width"); - int height = (int)swf_output_get(swf, "height"); + + int width = (int)result->get(result, "width"); + int height = (int)result->get(result, "height"); msg(" SWF written"); - swf_output_destroy(swf); + + result->destroy(result); + + dev_output_destroy(swf); pdf_destroy(pdf);