+ pdf_page_internal_t*i= (pdf_page_internal_t*)pdf_page->internal;
+ free(pdf_page->internal);pdf_page->internal = 0;
+ free(pdf_page);pdf_page=0;
+}
+
+swf_output_t* swf_output_init()
+{
+ swf_output_t*swf_output = (swf_output_t*)malloc(sizeof(swf_output_t));
+ memset(swf_output, 0, sizeof(swf_output_t));
+ swf_output_internal_t*i= (swf_output_internal_t*)malloc(sizeof(swf_output_internal_t));
+ memset(i, 0, sizeof(swf_output_internal_t));
+ swf_output->internal = i;
+
+ i->outputDev = new SWFOutputDev();
+ return swf_output;
+}
+
+void swf_output_setparameter(swf_output_t*swf_output, char*name, char*value)
+{
+ /* FIXME */
+ pdfswf_setparameter(name, value);
+}
+
+void swf_output_pagefeed(swf_output_t*swf)
+{
+ swf_output_internal_t*i= (swf_output_internal_t*)swf->internal;
+ i->outputDev->pagefeed();
+ i->outputDev->getDimensions(&swf->x1, &swf->y1, &swf->x2, &swf->y2);
+}
+
+int swf_output_save(swf_output_t*swf, char*filename)
+{
+ swf_output_internal_t*i= (swf_output_internal_t*)swf->internal;
+ int ret = i->outputDev->save(filename);
+ i->outputDev->getDimensions(&swf->x1, &swf->y1, &swf->x2, &swf->y2);
+ return ret;
+}
+
+void* swf_output_get(swf_output_t*swf)
+{
+ swf_output_internal_t*i= (swf_output_internal_t*)swf->internal;
+ void* ret = i->outputDev->getSWF();
+ i->outputDev->getDimensions(&swf->x1, &swf->y1, &swf->x2, &swf->y2);
+ return ret;
+}
+
+void swf_output_destroy(swf_output_t*output)
+{
+ swf_output_internal_t*i = (swf_output_internal_t*)output->internal;
+ delete i->outputDev; i->outputDev=0;
+ free(output->internal);output->internal=0;
+ free(output);
+}
+
+void pdf_page_render2(pdf_page_t*page, swf_output_t*swf)
+{
+ pdf_doc_internal_t*pi = (pdf_doc_internal_t*)page->parent->internal;
+ swf_output_internal_t*si = (swf_output_internal_t*)swf->internal;
+
+ if(pi->protect) {
+ swfoutput_setparameter("protect", "1");
+ }
+ si->outputDev->setXRef(pi->doc, pi->doc->getXRef());
+#ifdef XPDF_101
+ pi->doc->displayPage((OutputDev*)si->outputDev, page->nr, /*zoom*/zoom, /*rotate*/0, /*doLinks*/(int)1);
+#else
+ pi->doc->displayPage((OutputDev*)si->outputDev, page->nr, zoom, zoom, /*rotate*/0, true, /*doLinks*/(int)1);
+#endif
+ si->outputDev->getDimensions(&swf->x1, &swf->y1, &swf->x2, &swf->y2);
+}
+
+void pdf_page_rendersection(pdf_page_t*page, swf_output_t*output, int x, int y, int x1, int y1, int x2, int y2)
+{
+ pdf_doc_internal_t*pi = (pdf_doc_internal_t*)page->parent->internal;
+ swf_output_internal_t*si = (swf_output_internal_t*)output->internal;
+
+ si->outputDev->setMove(x,y);
+ if((x1|y1|x2|y2)==0) x2++;
+ si->outputDev->setClip(x1,y1,x2,y2);
+
+ pdf_page_render2(page, output);
+}
+void pdf_page_render(pdf_page_t*page, swf_output_t*output)
+{
+ pdf_doc_internal_t*pi = (pdf_doc_internal_t*)page->parent->internal;
+ swf_output_internal_t*si = (swf_output_internal_t*)output->internal;
+
+ si->outputDev->setMove(0,0);
+ si->outputDev->setClip(0,0,0,0);
+
+ pdf_page_render2(page, output);
+}
+
+
+pdf_page_info_t* pdf_page_getinfo(pdf_page_t*page)
+{
+ pdf_doc_internal_t*pi = (pdf_doc_internal_t*)page->parent->internal;
+ pdf_page_internal_t*i= (pdf_page_internal_t*)page->internal;
+ pdf_page_info_t*info = (pdf_page_info_t*)malloc(sizeof(pdf_page_info_t));
+ memset(info, 0, sizeof(pdf_page_info_t));
+
+ InfoOutputDev*output = new InfoOutputDev;
+
+#ifdef XPDF_101
+ pi->doc->displayPage((OutputDev*)output, page->nr, /*zoom*/zoom, /*rotate*/0, /*doLinks*/(int)1);
+#else
+ pi->doc->displayPage((OutputDev*)output, page->nr, zoom, zoom, /*rotate*/0, true, /*doLinks*/(int)1);
+#endif
+
+ info->xMin = output->x1;
+ info->yMin = output->y1;
+ info->xMax = output->x2;
+ info->yMax = output->y2;
+ info->number_of_images = output->num_images;
+ info->number_of_links = output->num_links;
+ info->number_of_fonts = output->num_fonts;
+