diff --git a/filters/karbon/pdf/CMakeLists.txt b/filters/karbon/pdf/CMakeLists.txt index 8f462b7b597..cbd12c1dbb3 100644 --- a/filters/karbon/pdf/CMakeLists.txt +++ b/filters/karbon/pdf/CMakeLists.txt @@ -1,26 +1,30 @@ if(Poppler_VERSION VERSION_LESS "0.64.0") add_definitions("-DHAVE_POPPLER_PRE_0_64") endif() if(Poppler_VERSION VERSION_LESS "0.72.0") add_definitions("-DHAVE_POPPLER_PRE_0_72") endif() +if(Poppler_VERSION VERSION_LESS "0.83.0") + add_definitions("-DHAVE_POPPLER_PRE_0_83") +endif() + set(pdf2svg_PART_SRCS PdfImportDebug.cpp PdfImport.cpp SvgOutputDev.cpp ) add_library(calligra_filter_pdf2svg MODULE ${pdf2svg_PART_SRCS}) calligra_filter_desktop_to_json(calligra_filter_pdf2svg calligra_filter_pdf2svg.desktop) target_link_libraries(calligra_filter_pdf2svg komain Poppler::Core) install(TARGETS calligra_filter_pdf2svg DESTINATION ${PLUGIN_INSTALL_DIR}/calligra/formatfilters) # pdf to odg set(pdf2odg_PART_SRCS PdfImportDebug.cpp Pdf2OdgImport.cpp SvgOutputDev.cpp) add_library(calligra_filter_pdf2odg MODULE ${pdf2odg_PART_SRCS}) calligra_filter_desktop_to_json(calligra_filter_pdf2odg calligra_filter_pdf2odg.desktop) target_link_libraries(calligra_filter_pdf2odg kopageapp karbonui Poppler::Core) install(TARGETS calligra_filter_pdf2odg DESTINATION ${PLUGIN_INSTALL_DIR}/calligra/formatfilters) diff --git a/filters/karbon/pdf/PdfImport.cpp b/filters/karbon/pdf/PdfImport.cpp index f88719d4554..73e68ec5b70 100644 --- a/filters/karbon/pdf/PdfImport.cpp +++ b/filters/karbon/pdf/PdfImport.cpp @@ -1,109 +1,117 @@ /* This file is part of the KDE project * Copyright (C) 2008 Jan Hambrecht * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "PdfImport.h" #include "PdfImportDebug.h" #include "SvgOutputDev.h" #include #include #include #include #include // Don't show this warning: it's an issue in poppler #ifdef __GNUC__ #pragma GCC diagnostic ignored "-Wunused-parameter" #endif // poppler includes #include #include +#ifndef HAVE_POPPLER_PRE_0_83 +#include +#endif + K_PLUGIN_FACTORY_WITH_JSON(PdfImportFactory, "calligra_filter_pdf2svg.json", registerPlugin();) PdfImport::PdfImport(QObject*parent, const QVariantList&) : KoFilter(parent) { debugPdf << "PDF Import Filter"; } PdfImport::~PdfImport() { } KoFilter::ConversionStatus PdfImport::convert(const QByteArray& from, const QByteArray& to) { debugPdf << "to:" << to << " from:" << from; if (from != "application/pdf" || to != "image/svg+xml") { return KoFilter::NotImplemented; } // read config file +#ifdef HAVE_POPPLER_PRE_0_83 globalParams = new GlobalParams(); +#else + globalParams = std::unique_ptr(new GlobalParams); +#endif if (! globalParams) return KoFilter::NotImplemented; GooString * fname = new GooString(QFile::encodeName(m_chain->inputFile()).data()); PDFDoc * pdfDoc = new PDFDoc(fname, 0, 0, 0); if (! pdfDoc) { delete globalParams; return KoFilter::StupidError; } if (! pdfDoc->isOk()) { delete globalParams; delete pdfDoc; return KoFilter::StupidError; } double hDPI = 72.0; double vDPI = 72.0; int firstPage = 1; int lastPage = pdfDoc->getNumPages(); debugPdf << "converting pages" << firstPage << "-" << lastPage; SvgOutputDev * dev = new SvgOutputDev(m_chain->outputFile()); if (dev->isOk()) { int rotate = 0; bool useMediaBox = true; bool crop = false; bool printing = false; pdfDoc->displayPages(dev, firstPage, lastPage, hDPI, vDPI, rotate, useMediaBox, crop, printing); dev->dumpContent(); } debugPdf << "wrote file to" << m_chain->outputFile(); delete dev; delete pdfDoc; delete globalParams; globalParams = 0; return KoFilter::OK; } #include "PdfImport.moc"