mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-10-05 19:41:40 +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:
parent
81934107e0
commit
ff59857ef4
@ -101,7 +101,8 @@ void HTMLRenderer::process(PDFDoc *doc)
|
|||||||
|
|
||||||
if(param->split_pages)
|
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);
|
f_pages.fs.open((char*)page_fn, ofstream::binary);
|
||||||
if(!f_pages.fs)
|
if(!f_pages.fs)
|
||||||
throw string("Cannot open ") + (char*)page_fn + " for writing";
|
throw string("Cannot open ") + (char*)page_fn + " for writing";
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <regex>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
|
||||||
#include <poppler-config.h>
|
#include <poppler-config.h>
|
||||||
@ -213,7 +214,7 @@ int main(int argc, char **argv)
|
|||||||
if(get_suffix(param.input_filename) == ".pdf")
|
if(get_suffix(param.input_filename) == ".pdf")
|
||||||
{
|
{
|
||||||
if(param.split_pages)
|
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
|
else
|
||||||
param.output_filename = s.substr(0, s.size() - 4) + ".html";
|
param.output_filename = s.substr(0, s.size() - 4) + ".html";
|
||||||
|
|
||||||
@ -221,11 +222,16 @@ int main(int argc, char **argv)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(param.split_pages)
|
if(param.split_pages)
|
||||||
param.output_filename = s;
|
param.output_filename = s + "%d.page";
|
||||||
else
|
else
|
||||||
param.output_filename = s + ".html";
|
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())
|
if(param.css_filename.empty())
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user