mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-22 13:00:08 +00:00
As suggested by Lu Wand, merging the adobe-form branch into the incoming branch
This commit is contained in:
commit
9fd1ba37de
@ -119,6 +119,7 @@ set(PDF2HTMLEX_SRC ${PDF2HTMLEX_SRC}
|
|||||||
src/HTMLRenderer/general.cc
|
src/HTMLRenderer/general.cc
|
||||||
src/HTMLRenderer/image.cc
|
src/HTMLRenderer/image.cc
|
||||||
src/HTMLRenderer/font.cc
|
src/HTMLRenderer/font.cc
|
||||||
|
src/HTMLRenderer/form.cc
|
||||||
src/HTMLRenderer/link.cc
|
src/HTMLRenderer/link.cc
|
||||||
src/HTMLRenderer/outline.cc
|
src/HTMLRenderer/outline.cc
|
||||||
src/HTMLRenderer/state.cc
|
src/HTMLRenderer/state.cc
|
||||||
|
@ -138,6 +138,10 @@ Whether to show outline in the generated HTML
|
|||||||
.B \-\-process-annotation <0|1> (Default: 0)
|
.B \-\-process-annotation <0|1> (Default: 0)
|
||||||
Whether to show annotation in the generated HTML
|
Whether to show annotation in the generated HTML
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B \-\-process-form <0|1> (Default: 0)
|
||||||
|
Whether to include text fields and radio buttons in the generated HTML
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B \-\-printing <0|1> (Default: 1)
|
.B \-\-printing <0|1> (Default: 1)
|
||||||
Enable printing support. Disabling this option may reduce the size of CSS.
|
Enable printing support. Disabling this option may reduce the size of CSS.
|
||||||
|
@ -190,4 +190,14 @@
|
|||||||
-ms-transform-origin:0% 100%;
|
-ms-transform-origin:0% 100%;
|
||||||
-webkit-transform-origin:0% 100%;
|
-webkit-transform-origin:0% 100%;
|
||||||
}
|
}
|
||||||
|
/* for the forms */
|
||||||
|
.@CSS_INPUT_TEXT_CN@ {
|
||||||
|
border: none;
|
||||||
|
background-color: rgba(255, 255, 255, 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.@CSS_INPUT_RADIO_CN@:hover {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
/* Base CSS END */
|
/* Base CSS END */
|
||||||
|
@ -81,5 +81,8 @@
|
|||||||
-webkit-animation: swing 1.5s ease-in-out 0.01s infinite alternate none;
|
-webkit-animation: swing 1.5s ease-in-out 0.01s infinite alternate none;
|
||||||
animation: swing 1.5s ease-in-out 0.01s infinite alternate none;
|
animation: swing 1.5s ease-in-out 0.01s infinite alternate none;
|
||||||
}
|
}
|
||||||
|
.@CSS_RADIO_CHECKED_CN@ {
|
||||||
|
background: no-repeat url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3goQDSYgDiGofgAAAslJREFUOMvtlM9LFGEYx7/vvOPM6ywuuyPFihWFBUsdNnA6KLIh+QPx4KWExULdHQ/9A9EfUodYmATDYg/iRewQzklFWxcEBcGgEplDkDtI6sw4PzrIbrOuedBb9MALD7zv+3m+z4/3Bf7bZS2bzQIAcrmcMDExcTeXy10DAFVVAQDksgFUVZ1ljD3yfd+0LOuFpmnvVVW9GHhkZAQcxwkNDQ2FSCQyRMgJxnVdy7KstKZpn7nwha6urqqfTqfPBAJAuVymlNLXoigOhfd5nmeiKL5TVTV+lmIKwAOA7u5u6Lped2BsbOwjY6yf4zgQQkAIAcedaPR9H67r3uYBQFEUFItFtLe332lpaVkUBOHK3t5eRtf1DwAwODiIubk5DA8PM8bYW1EU+wEgCIJqsCAIQAiB7/u253k2BQDDMJBKpa4mEon5eDx+UxAESJL0uK2t7XosFlvSdf0QAEmlUnlRFJ9Waho2Qghc1/U9z3uWz+eX+Wr+lL6SZfleEAQIggA8z6OpqSknimIvYyybSCReMsZ6TislhCAIAti2Dc/zejVNWwCAavN8339j27YbTg0AGGM3WltbP4WhlRWq6Q/btrs1TVsYHx+vNgqKoqBUKn2NRqPFxsbGJzzP05puUlpt0ukyOI6z7zjOwNTU1OLo6CgmJyf/gA3DgKIoWF1d/cIY24/FYgOU0pp0z/Ityzo8Pj5OTk9PbwHA+vp6zWghDC+VSiuRSOQgGo32UErJ38CO42wdHR09LBQK3zKZDDY2NupmFmF4R0cHVlZWlmRZ/iVJUn9FeWWcCCE4ODjYtG27Z2Zm5juAOmgdGAB2d3cBADs7O8uSJN2SZfl+WKlpmpumaT6Yn58vn/fs6XmbhmHMNjc3tzDGFI7jYJrm5vb29sDa2trPC/9aiqJUy5pOp4f6+vqeJ5PJBAB0dnZe/t8NBajx/z37Df5OGX8d13xzAAAAAElFTkSuQmCC);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* Fancy CSS END */
|
/* Fancy CSS END */
|
||||||
|
@ -260,7 +260,24 @@ Viewer.prototype = {
|
|||||||
this.pre_hide_pages();
|
this.pre_hide_pages();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
initialize_radio_button : function() {
|
||||||
|
var elements = document.getElementsByClassName('ir');
|
||||||
|
|
||||||
|
for(var i = 0; i < elements.length; i++) {
|
||||||
|
var r = elements[i];
|
||||||
|
|
||||||
|
r.addEventListener('click', function() {
|
||||||
|
if(this.className.search("checked") == -1)
|
||||||
|
this.className += " checked";
|
||||||
|
else
|
||||||
|
this.className = "ir";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
init_after_loading_content : function() {
|
init_after_loading_content : function() {
|
||||||
|
this.initialize_radio_button();
|
||||||
|
|
||||||
this.sidebar = document.getElementById(this.config['sidebar_id']);
|
this.sidebar = document.getElementById(this.config['sidebar_id']);
|
||||||
this.outline = document.getElementById(this.config['outline_id']);
|
this.outline = document.getElementById(this.config['outline_id']);
|
||||||
this.container = document.getElementById(this.config['container_id']);
|
this.container = document.getElementById(this.config['container_id']);
|
||||||
|
@ -21,6 +21,10 @@
|
|||||||
#include <GfxFont.h>
|
#include <GfxFont.h>
|
||||||
#include <Annot.h>
|
#include <Annot.h>
|
||||||
|
|
||||||
|
// for form.cc
|
||||||
|
#include <Page.h>
|
||||||
|
#include <Form.h>
|
||||||
|
|
||||||
#include "pdf2htmlEX-config.h"
|
#include "pdf2htmlEX-config.h"
|
||||||
|
|
||||||
#include "Param.h"
|
#include "Param.h"
|
||||||
@ -161,6 +165,8 @@ protected:
|
|||||||
void process_outline(void);
|
void process_outline(void);
|
||||||
void process_outline_items(GooList * items);
|
void process_outline_items(GooList * items);
|
||||||
|
|
||||||
|
void process_form(std::ofstream & out);
|
||||||
|
|
||||||
void set_stream_flags (std::ostream & out);
|
void set_stream_flags (std::ostream & out);
|
||||||
|
|
||||||
void dump_css(void);
|
void dump_css(void);
|
||||||
|
75
src/HTMLRenderer/form.cc
Normal file
75
src/HTMLRenderer/form.cc
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
* form.cc
|
||||||
|
*
|
||||||
|
* Handling Forms
|
||||||
|
*
|
||||||
|
* by Simon Chenard
|
||||||
|
* 2014.07.25
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "HTMLRenderer.h"
|
||||||
|
#include "util/namespace.h"
|
||||||
|
#include "util/misc.h"
|
||||||
|
|
||||||
|
namespace pdf2htmlEX {
|
||||||
|
|
||||||
|
using std::ofstream;
|
||||||
|
using std::cerr;
|
||||||
|
|
||||||
|
void HTMLRenderer::process_form(ofstream & out)
|
||||||
|
{
|
||||||
|
FormPageWidgets * widgets = cur_catalog->getPage(pageNum)->getFormWidgets();
|
||||||
|
int num = widgets->getNumWidgets();
|
||||||
|
|
||||||
|
for(int i = 0; i < num; i++)
|
||||||
|
{
|
||||||
|
FormWidget * w = widgets->getWidget(i);
|
||||||
|
double x1, y1, x2, y2, width, font_size;
|
||||||
|
int height;
|
||||||
|
|
||||||
|
w->getRect(&x1, &y1, &x2, &y2);
|
||||||
|
x1 = x1 * param.zoom;
|
||||||
|
x2 = x2 * param.zoom;
|
||||||
|
y1 = y1 * param.zoom;
|
||||||
|
y2 = y2 * param.zoom;
|
||||||
|
|
||||||
|
width = x2 - x1;
|
||||||
|
height = y2 - y1;
|
||||||
|
|
||||||
|
if(w->getType() == formText)
|
||||||
|
{
|
||||||
|
font_size = height / 2;
|
||||||
|
|
||||||
|
out
|
||||||
|
<< "<input id=\"text-" << pageNum << "-"
|
||||||
|
<< i << "\" type=\"text\" value=\"\""
|
||||||
|
<< " style=\"position: absolute; left: " << x1
|
||||||
|
<< "px; bottom: " << y1 << "px;"
|
||||||
|
<< " width: " << width << "px; height: " << std::to_string(height)
|
||||||
|
<< "px; line-height: " << std::to_string(height) << "px; font-size: "
|
||||||
|
<< font_size << "px;\" class=\""
|
||||||
|
<< CSS::INPUT_TEXT_CN << "\" />" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(w->getType() == formButton)
|
||||||
|
{
|
||||||
|
width += 3;
|
||||||
|
height += 3;
|
||||||
|
|
||||||
|
out
|
||||||
|
<< "<div id=\"cb-" << pageNum << "-" << i << "\""
|
||||||
|
<< " style=\"position: absolute; left: " << x1
|
||||||
|
<< "px; bottom: " << y1 << "px;"
|
||||||
|
<< " width: " << width << "px; height: "
|
||||||
|
<< std::to_string(height) << "px; background-size: cover;\" class=\""
|
||||||
|
<< CSS::INPUT_RADIO_CN << "\"></div>" << endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -239,6 +239,10 @@ void HTMLRenderer::endPage() {
|
|||||||
html_text_page.dump_css(f_css.fs);
|
html_text_page.dump_css(f_css.fs);
|
||||||
html_text_page.clear();
|
html_text_page.clear();
|
||||||
|
|
||||||
|
// process form
|
||||||
|
if(param.process_form)
|
||||||
|
process_form(*f_curpage);
|
||||||
|
|
||||||
// process links before the page is closed
|
// process links before the page is closed
|
||||||
cur_doc->processLinks(this, pageNum);
|
cur_doc->processLinks(this, pageNum);
|
||||||
|
|
||||||
@ -380,6 +384,7 @@ void HTMLRenderer::pre_process(PDFDoc * doc)
|
|||||||
void HTMLRenderer::post_process(void)
|
void HTMLRenderer::post_process(void)
|
||||||
{
|
{
|
||||||
dump_css();
|
dump_css();
|
||||||
|
|
||||||
// close files if they opened
|
// close files if they opened
|
||||||
if (param.process_outline)
|
if (param.process_outline)
|
||||||
{
|
{
|
||||||
|
@ -38,6 +38,7 @@ struct Param
|
|||||||
int process_nontext;
|
int process_nontext;
|
||||||
int process_outline;
|
int process_outline;
|
||||||
int process_annotation;
|
int process_annotation;
|
||||||
|
int process_form;
|
||||||
int correct_text_visibility;
|
int correct_text_visibility;
|
||||||
int printing;
|
int printing;
|
||||||
int fallback;
|
int fallback;
|
||||||
|
@ -34,3 +34,6 @@ set(CSS_WIDTH_CN "w") # Width
|
|||||||
set(CSS_BOTTTOM_CN "y") # Y
|
set(CSS_BOTTTOM_CN "y") # Y
|
||||||
set(CSS_CSS_DRAW_CN "d") # Draw
|
set(CSS_CSS_DRAW_CN "d") # Draw
|
||||||
set(CSS_LINK_CN "l") # Link
|
set(CSS_LINK_CN "l") # Link
|
||||||
|
set(CSS_INPUT_TEXT_CN "it") # Text input
|
||||||
|
set(CSS_INPUT_RADIO_CN "ir") # Radio button
|
||||||
|
set(CSS_RADIO_CHECKED_CN "checked") # Show picture of checked out radio button
|
||||||
|
@ -164,6 +164,7 @@ void parse_options (int argc, char **argv)
|
|||||||
.add("process-nontext", ¶m.process_nontext, 1, "render graphics in addition to text")
|
.add("process-nontext", ¶m.process_nontext, 1, "render graphics in addition to text")
|
||||||
.add("process-outline", ¶m.process_outline, 1, "show outline in HTML")
|
.add("process-outline", ¶m.process_outline, 1, "show outline in HTML")
|
||||||
.add("process-annotation", ¶m.process_annotation, 0, "show annotation in HTML")
|
.add("process-annotation", ¶m.process_annotation, 0, "show annotation in HTML")
|
||||||
|
.add("process-form", ¶m.process_form, 0, "include text fields and radio buttons")
|
||||||
.add("printing", ¶m.printing, 1, "enable printing support")
|
.add("printing", ¶m.printing, 1, "enable printing support")
|
||||||
.add("fallback", ¶m.fallback, 0, "output in fallback mode")
|
.add("fallback", ¶m.fallback, 0, "output in fallback mode")
|
||||||
.add("tmp-file-size-limit", ¶m.tmp_file_size_limit, -1, "Maximum size (in KB) used by temporary files, -1 for no limit.")
|
.add("tmp-file-size-limit", ¶m.tmp_file_size_limit, -1, "Maximum size (in KB) used by temporary files, -1 for no limit.")
|
||||||
|
@ -56,6 +56,10 @@ const char * const BOTTOM_CN = "@CSS_BOTTTOM_CN@";
|
|||||||
const char * const CSS_DRAW_CN = "@CSS_CSS_DRAW_CN@";
|
const char * const CSS_DRAW_CN = "@CSS_CSS_DRAW_CN@";
|
||||||
const char * const LINK_CN = "@CSS_LINK_CN@";
|
const char * const LINK_CN = "@CSS_LINK_CN@";
|
||||||
|
|
||||||
|
const char * const INPUT_TEXT_CN = "@CSS_INPUT_TEXT_CN@";
|
||||||
|
const char * const INPUT_RADIO_CN = "@CSS_INPUT_RADIO_CN@";
|
||||||
|
const char * const RADIO_CHECKED_CN = "@CSS_RADIO_CHECKED_CN@";
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user