diff --git a/.env.example b/.env.example index ad20566..d19fc1a 100644 --- a/.env.example +++ b/.env.example @@ -1,7 +1,6 @@ PDF2HTMLEX_PATH=/path/to/pdf2htmlex PSTOPDF_PATH=/path/to/ps2pdf EXTRACT_FORMFIELDS=/path/to/extract-formfields # available via cpp directory -HIDE_FORMFIELDS=/path/to/hide-formfields # available via cpp directory PDFLIBS_PORT=8000 HTML_GENERATION_TIMEOUT=7000 HTML_GENERATION_BACKOFF=23000 diff --git a/config.js b/config.js index 1576dba..e396183 100644 --- a/config.js +++ b/config.js @@ -27,8 +27,6 @@ if (!extractFormfieldsPath) { process.exit(1); } -const hideFormfieldsPath = process.env.HIDE_FORMFIELDS; - // 7 seconds (and then 30 seconds) seems like a sensible default I guess? We don't want PDFs // that don't need postscript optimization to be optimized in this way, but we also want to // stay under common reverse proxy timeout configurations so we don't receive a 504 @@ -42,6 +40,5 @@ module.exports = { extractFormfieldsPath, pdf2htmlexPath, psToPdfPath, - hideFormfieldsPath, htmlGenerationTimeoutConfig }; diff --git a/cpp/hide-formfields/CMakeLists.txt b/cpp/hide-formfields/CMakeLists.txt deleted file mode 100644 index f38e0c9..0000000 --- a/cpp/hide-formfields/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -cmake_minimum_required(VERSION 3.10) - -set (CMAKE_CXX_STANDARD 17) - -project(hide-formfields) - -find_library(poppler poppler) -find_library(poppler-qt poppler-qt5) -find_library(qt Qt5Core) - -message("${qt}") -message("${poppler}") -message("${poppler-qt}") - -set(LIB_DIR /lib/x86_64-linux-gnu) - -set(INCLUDE_POPPLER /usr/include/poppler/cpp) -set(INCLUDE_POPPLER_QT /usr/include/poppler/qt5) -set(INCLUDE_QT /usr/include/qt5) -set(INCLUDE_QT_CORE /usr/include/QtCore) - -add_executable(hide-formfields main.cpp) - -include_directories(${INCLUDE_POPPLER} ${INCLUDE_POPPLER_QT} ${INCLUDE_QT} ${INCLUDE_QT_CORE} include) - -target_link_libraries(hide-formfields ${qt} ${poppler} ${poppler-qt}) diff --git a/cpp/hide-formfields/build.sh b/cpp/hide-formfields/build.sh deleted file mode 100755 index 13a681b..0000000 --- a/cpp/hide-formfields/build.sh +++ /dev/null @@ -1,6 +0,0 @@ -mkdir bin -mkdir build -cd build -cmake .. -make -mv hide-formfields ../bin diff --git a/cpp/hide-formfields/main.cpp b/cpp/hide-formfields/main.cpp deleted file mode 100644 index d999e29..0000000 --- a/cpp/hide-formfields/main.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include -#include -#include -#include "poppler-qt5.h" -#include "poppler-form.h" - -bool saveToFile(const QString &filename, const Poppler::Document* doc) { - Poppler::PDFConverter *pdfConv = doc->pdfConverter(); - pdfConv->setOutputFileName(filename); - pdfConv->setPDFOptions(pdfConv->pdfOptions()|Poppler::PDFConverter::WithChanges); - bool success = pdfConv->convert(); - delete pdfConv; - - return success; -} - -int main(int argc, char **argv) { - freopen("dev/null", "w", stderr); - - QString filename, toFile; - filename = QString(argv[1]); - toFile = QString(argv[2]); - - Poppler::Document* doc = Poppler::Document::load(filename); - Poppler::Page* page = doc->page(0); - QList fields = page->formFields(); - - for(int j = 0; j < fields.length(); j++) { - Poppler::FormField *f = fields.at(j); - f->setVisible(false); - } - - saveToFile(toFile, doc); - - delete page; - delete doc; - return 0; -} diff --git a/deployment/docker/Dockerfile b/deployment/docker/Dockerfile index 59ea059..ba39469 100644 --- a/deployment/docker/Dockerfile +++ b/deployment/docker/Dockerfile @@ -55,7 +55,6 @@ ENV APP_ROOT=/usr/src/pdf-libs ARG EXTRACT_FORMFIELDS_ROOT=$APP_ROOT/cpp/extract-formfields WORKDIR $APP_ROOT -# only copy extract-formfields since hide-formfields is broken COPY cpp/extract-formfields $EXTRACT_FORMFIELDS_ROOT WORKDIR $EXTRACT_FORMFIELDS_ROOT RUN $EXTRACT_FORMFIELDS_ROOT/build.sh && \ @@ -79,7 +78,7 @@ RUN apt update && apt upgrade -y && \ ghostscript \ && rm -f /etc/apt/sources.list \ && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + && rm -rf /var/lib/apt/lists/* WORKDIR $APP_ROOT diff --git a/src/handlers/pdf/hide-formfields.js b/src/handlers/pdf/hide-formfields.js deleted file mode 100644 index 55eadb8..0000000 --- a/src/handlers/pdf/hide-formfields.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -const path = require('path'); -const os = require('os'); -const {v4: uuid} = require('uuid'); - -const config = require('../../../config'); -const {exec} = require('../../utils'); - -const hideFormfields = async (req, __res, next) => { - const outputPath = path.join(os.tmpdir(), `${uuid()}.pdf`); - req.cleanup.push(outputPath); - - await exec(`${config.hideFormfieldsPath} ${req.filePath} ${outputPath}`); - req.filePath = outputPath; - next(); -}; - -module.exports = {hideFormfields}; diff --git a/src/handlers/pdf/index.js b/src/handlers/pdf/index.js index 80894d7..d328dff 100644 --- a/src/handlers/pdf/index.js +++ b/src/handlers/pdf/index.js @@ -3,6 +3,5 @@ module.exports = { ...require('./get-formfields'), ...require('./optimize-pdf'), - ...require('./hide-formfields'), ...require('./convert-to-html'), }; diff --git a/src/router.js b/src/router.js index 2be3ea9..517bf39 100644 --- a/src/router.js +++ b/src/router.js @@ -17,7 +17,6 @@ r.use(getFileFromFormData); r.post('/convertToHtml', debug(debugScopes.CONVERT_TO_HTML), - // hideFormfields, convertToHtml, optimizePdf, convertToHtml); @@ -27,7 +26,6 @@ r.post('/getFormfields', debug('pdfLibs.formfields'), getFormfields); // DEPRECATED PATHS r.post('/pdf2html', debug(debugScopes.FORMFIELDS), - // hideFormfields, convertToHtml, optimizePdf, convertToHtml);