Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
andiwand committed Jan 5, 2025
1 parent 657d371 commit b64ab7c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def requirements(self):
self.requires("uchardet/0.0.8")
self.requires("utfcpp/4.0.4")
if self.options.get_safe("with_pdf2htmlEX", False):
self.requires("pdf2htmlex/0.18.8.rc1-git-6f85c88-odr")
self.requires("pdf2htmlex/0.18.8.rc1-odr-pr1")
if self.options.get_safe("with_wvWare", False):
self.requires("wvware/1.2.9-odr")

Expand Down
2 changes: 2 additions & 0 deletions src/odr/html_service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ class HtmlFragment;
class HtmlResource;

enum class HtmlResourceType {
html_fragment,
css,
js,
image,
font,
};

using HtmlResourceLocation = std::optional<std::string>;
Expand Down
41 changes: 19 additions & 22 deletions src/odr/internal/html/pdf2htmlex_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,22 @@ pdf2htmlEX::Param create_params(PDFDoc &pdf_doc, const HtmlConfig &config,
// output
param.embed_css = 1;
param.embed_font = 1;
param.embed_image = 1;
param.embed_image = 0;
param.embed_javascript = 1;
param.embed_outline = 1;
param.split_pages = 1;
param.split_pages = 0;
param.dest_dir = output_path;
param.css_filename = "";
param.css_filename = "style.css";
param.page_filename = "page%i.html";
param.outline_filename = "";
param.process_nontext = 0;
param.outline_filename = "outline.html";
param.process_nontext = 1;
param.process_outline = 1;
param.process_annotation = 0;
param.process_form = 0;
param.printing = 1;
param.fallback = 0;
param.tmp_file_size_limit = -1;
param.delay_background = 1;

// font
param.embed_external_font = 0; // TODO 1
Expand Down Expand Up @@ -87,7 +88,7 @@ pdf2htmlEX::Param create_params(PDFDoc &pdf_doc, const HtmlConfig &config,

// misc
param.clean_tmp = 1;
param.tmp_dir = "/tmp";
param.tmp_dir = output_path;
param.data_dir = config.pdf2htmlex_data_path;
param.poppler_data_dir = config.poppler_data_path;
param.debug = 0;
Expand Down Expand Up @@ -124,24 +125,14 @@ class StaticHtmlService : public abstract::HtmlService {
const std::vector<std::shared_ptr<abstract::HtmlFragment>> m_fragments;
};

class PdfHtmlFragment : public abstract::HtmlFragment {
public:
PdfHtmlFragment(PopplerPdfFile pdf_file, std::size_t page)
: m_pdf_file{std::move(pdf_file)}, m_page{page} {}

void
write_html_document(HtmlWriter &out, const HtmlConfig &config,
const HtmlResourceLocator &resourceLocator) const final {}

protected:
PopplerPdfFile m_pdf_file;
std::size_t m_page;
};

} // namespace odr::internal::html

namespace odr::internal {

HtmlService html::translate_poppler_pdf_file(const PopplerPdfFile &pdf_file) {
return HtmlService(nullptr);
}

Html html::translate_poppler_pdf_file(const PopplerPdfFile &pdf_file,
const std::string &output_path,
const HtmlConfig &config) {
Expand All @@ -161,8 +152,14 @@ Html html::translate_poppler_pdf_file(const PopplerPdfFile &pdf_file,

// TODO not sure what the `progPath` is used for. it cannot be `nullptr`
// TODO potentially just a cache dir?
pdf2htmlEX::HTMLRenderer(config.fontforge_data_path.c_str(), param)
.process(&pdf_doc);
pdf2htmlEX::HTMLRenderer html_renderer(config.fontforge_data_path.c_str(),
param);
html_renderer.process(&pdf_doc);
if (param.delay_background != 0) {
for (int i = 1; i <= pdf_doc.getNumPages(); ++i) {
html_renderer.renderPage(&pdf_doc, i);
}
}

globalParams.reset();

Expand Down
2 changes: 1 addition & 1 deletion src/odr/internal/html/pdf2htmlex_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class PopplerPdfFile;

namespace odr::internal::html {

HtmlService translate_document(const PopplerPdfFile &pdf_file);
HtmlService translate_poppler_pdf_file(const PopplerPdfFile &pdf_file);

Html translate_poppler_pdf_file(const PopplerPdfFile &pdf_file,
const std::string &output_path,
Expand Down

0 comments on commit b64ab7c

Please sign in to comment.