add trim page option

pull/2/merge
chrox 12 years ago
parent f4e542306f
commit 3a7535d350

@ -490,9 +490,11 @@ static int reflowPage(lua_State *L) {
int rotation = luaL_checkint(L, 16);
double quality = luaL_checknumber(L, 17);
double defect_size = luaL_checknumber(L, 18);
int trim_page = luaL_checkint(L, 19);
k2pdfopt_set_params(width, height, font_size, page_margin, line_spacing, word_spacing, \
text_wrap, straighten, justification, detect_indent, columns, contrast, rotation, quality, defect_size);
text_wrap, straighten, justification, detect_indent, columns, contrast, rotation, \
quality, defect_size, trim_page);
k2pdfopt_djvu_reflow(page->page_ref, page->doc->context, mode, page->doc->pixelformat);
k2pdfopt_rfbmp_size(&width, &height);
k2pdfopt_rfbmp_zoom(&dc->zoom);

@ -560,7 +560,7 @@ void k2pdfopt_set_params(int bb_width, int bb_height, \
int justification, int detect_indent,\
int columns, double contrast, \
int rotation, double quality, \
double defect_size) {
double defect_size, int trim_page) {
dst_userwidth = bb_width; // dst_width is adjusted in adjust_params_init
dst_userheight = bb_height;
zoom_value = font_size;
@ -575,6 +575,18 @@ void k2pdfopt_set_params(int bb_width, int bb_height, \
src_dpi = (int)300*quality;
defect_size_pts = defect_size;
if (trim_page == 0) {
mar_left = 0;
mar_top = 0;
mar_right = 0;
mar_bot = 0;
} else {
mar_left = -1;
mar_top = -1;
mar_right = -1;
mar_bot = -1;
}
// margin
dst_mar = page_margin;
dst_martop = -1.0;

@ -33,7 +33,7 @@ void k2pdfopt_set_params(int bb_width, int bb_height, \
int justification, int detect_indent, \
int columns, double contrast, \
int rotation, double quality, \
double defect_size);
double defect_size, int trim_page);
void k2pdfopt_mupdf_reflow(fz_document *doc, fz_page *page, fz_context *ctx);
void k2pdfopt_djvu_reflow(ddjvu_page_t *page, ddjvu_context_t *ctx, ddjvu_render_mode_t mode, ddjvu_format_t *fmt);
void k2pdfopt_rfbmp_size(int *width, int *height);

@ -530,9 +530,11 @@ static int reflowPage(lua_State *L) {
int rotation = luaL_checkint(L, 16);
double quality = luaL_checknumber(L, 17);
double defect_size = luaL_checknumber(L, 18);
int trim_page = luaL_checkint(L, 19);
k2pdfopt_set_params(width, height, font_size, page_margin, line_spacing, word_spacing, \
text_wrap, straighten, justification, detect_indent, columns, contrast, rotation, quality, defect_size);
text_wrap, straighten, justification, detect_indent, columns, contrast, rotation, \
quality, defect_size, trim_page);
k2pdfopt_mupdf_reflow(page->doc->xref, page->page, page->doc->context);
k2pdfopt_rfbmp_size(&width, &height);
k2pdfopt_rfbmp_zoom(&dc->zoom);

Loading…
Cancel
Save