1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-12-22 04:50:09 +00:00

Added ability to explicitly specify page name format when splitting

output across multiple pages. Can include page number position
in the output file name.

Examples:
pdf2htmlEX --split-pages 1 foo.pdf bar%d.html
pdf2htmlEX --split-pages 1 foo.pdf bar%02d.page
This commit is contained in:
Ryan Morlok 2013-02-27 23:59:07 -06:00
parent 81934107e0
commit ff59857ef4
2 changed files with 10 additions and 3 deletions

View File

@ -101,7 +101,8 @@ void HTMLRenderer::process(PDFDoc *doc)
if(param->split_pages)
{
auto page_fn = str_fmt("%s/%s%d.page", param->dest_dir.c_str(), param->output_filename.c_str(), i);
auto page_template_fn = str_fmt("%s/%s", param->dest_dir.c_str(), param->output_filename.c_str());
auto page_fn = str_fmt(page_template_fn, i);
f_pages.fs.open((char*)page_fn, ofstream::binary);
if(!f_pages.fs)
throw string("Cannot open ") + (char*)page_fn + " for writing";

View File

@ -10,6 +10,7 @@
#include <string>
#include <limits>
#include <iostream>
#include <regex>
#include <getopt.h>
#include <poppler-config.h>
@ -213,7 +214,7 @@ int main(int argc, char **argv)
if(get_suffix(param.input_filename) == ".pdf")
{
if(param.split_pages)
param.output_filename = s.substr(0, s.size() - 4);
param.output_filename = s.substr(0, s.size() - 4) + "%d.page";
else
param.output_filename = s.substr(0, s.size() - 4) + ".html";
@ -221,11 +222,16 @@ int main(int argc, char **argv)
else
{
if(param.split_pages)
param.output_filename = s;
param.output_filename = s + "%d.page";
else
param.output_filename = s + ".html";
}
}
else if(param.split_pages && !std::regex_match(param.output_filename, std::regex("^.*%[0-9]*d.*$")))
{
const string suffix = get_suffix(param.output_filename);
param.output_filename = param.output_filename.substr(0, param.output_filename.size() - suffix.size()) + "%d" + suffix;
}
if(param.css_filename.empty())
{