Merge pull request #525 from xournalpp/pdf_export_no_bg

PDF and PNG export with no background
presentation
morrolinux 7 years ago committed by GitHub
commit 019d32df5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      .gitignore
  2. 8
      src/control/jobs/BaseExportJob.cpp
  3. 1
      src/control/jobs/BaseExportJob.h
  4. 26
      src/control/jobs/CustomExportJob.cpp
  5. 9
      src/control/jobs/CustomExportJob.h
  6. 4
      src/control/jobs/PdfExportJob.cpp
  7. 3
      src/pdf/base/XojCairoPdfExport.cpp
  8. 3
      src/pdf/popplerdirect/PdfExport.cpp
  9. 1
      src/util/XournalTypeList.h

3
.gitignore vendored

@ -2,6 +2,7 @@
.deps
.dirstamp
.libs
*.DS_Store
*.o
*.lo
*.la
@ -48,3 +49,5 @@ cmake-build-release
doc/html
doc/latex
src/view/.DS_Store
src/view/background/.DS_Store

@ -35,6 +35,14 @@ void BaseExportJob::addFileFilterToDialog(string name, string pattern)
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter);
}
string BaseExportJob::getFilterName()
{
XOJ_CHECK_TYPE(BaseExportJob);
GtkFileFilter* filter = gtk_file_chooser_get_filter(GTK_FILE_CHOOSER(dialog));
return gtk_file_filter_get_name(filter);
}
void BaseExportJob::prepareSavePath(path& path)
{
XOJ_CHECK_TYPE(BaseExportJob);

@ -34,6 +34,7 @@ public:
public:
virtual bool showFilechooser();
string getFilterName();
protected:
void initDialog();

@ -11,7 +11,6 @@
#include <i18n.h>
#include <config-features.h>
CustomExportJob::CustomExportJob(Control* control)
: BaseExportJob(control, _("Custom Export")),
pngDpi(300),
@ -41,9 +40,11 @@ void CustomExportJob::addFilterToDialog()
{
XOJ_CHECK_TYPE(CustomExportJob);
addFileFilterToDialog(_C("PDF files"), "*.pdf");
addFileFilterToDialog(_C("PNG graphics"), "*.png");
addFileFilterToDialog(_C("Xournal (Compatibility)"), "*.xoj");
addFileFilterToDialog(EXPORT_PDF, "*.pdf");
addFileFilterToDialog(EXPORT_PDF_NOBG, "*.pdf");
addFileFilterToDialog(EXPORT_PNG, "*.png");
addFileFilterToDialog(EXPORT_PNG_NOBG, "*.png");
addFileFilterToDialog(EXPORT_XOJ, "*.xoj");
}
bool CustomExportJob::isUriValid(string& uri)
@ -55,6 +56,8 @@ bool CustomExportJob::isUriValid(string& uri)
return false;
}
this->chosenFilterName = BaseExportJob::getFilterName();
string ext = filename.extension().string();
if (ext != ".pdf" && ext != ".png" && ext != ".xoj")
{
@ -179,7 +182,14 @@ void CustomExportJob::exportPngPage(int pageId, int id, double zoom, DocumentVie
PdfView::drawPage(NULL, popplerPage, cr, zoom, page->getWidth(), page->getHeight());
}
view.drawPage(page, this->cr, true);
if (this->chosenFilterName == EXPORT_PNG_NOBG)
{
view.drawPage(page, this->cr, true, true);
}
else
{
view.drawPage(page, this->cr, true);
}
if (!freeSurface(id))
{
@ -270,7 +280,11 @@ void CustomExportJob::run()
Document* doc = control->getDocument();
XojPdfExport* pdfe = XojPdfExportFactory::createExport(doc, control);
if (this->chosenFilterName == EXPORT_PDF_NOBG)
{
pdfe->setNoBackgroundExport(true);
}
#ifdef ADVANCED_PDF_EXPORT_POPPLER
// Not working with ADVANCED_PDF_EXPORT_POPPLER

@ -16,6 +16,13 @@
#include "view/DocumentView.h"
#include <PageRange.h>
#include <i18n.h>
const string EXPORT_PDF = _C("PDF files");
const string EXPORT_PDF_NOBG = _C("PDF with plain background");
const string EXPORT_PNG = _C("PNG graphics");
const string EXPORT_PNG_NOBG = _C("PNG with transparent background");
const string EXPORT_XOJ = _C("Xournal (Compatibility)");
class CustomExportJob : public BaseExportJob
{
@ -71,4 +78,6 @@ private:
bool exportTypeXoj;
string lastError;
string chosenFilterName;
};

@ -57,15 +57,17 @@ bool PdfExportJob::isUriValid(string& uri)
Util::showErrorToUser(control->getGtkWindow(), msg);
return false;
}
return true;
}
void PdfExportJob::run()
{
XOJ_CHECK_TYPE(PdfExportJob);
Document* doc = control->getDocument();
doc->lock();
XojPdfExport* pdfe = XojPdfExportFactory::createExport(doc, control);
doc->unlock();

@ -118,8 +118,7 @@ bool XojCairoPdfExport::createPdf(path file, PageRangeVector& range)
{
for (int i = e->getFirst(); i <= e->getLast(); i++)
{
int p = i - 1;
if (p < 0 || p >= (int)doc->getPageCount())
if (i < 0 || i > (int)doc->getPageCount())
{
continue;
}

@ -669,8 +669,7 @@ bool PdfExport::createPdf(path file, PageRangeVector& range)
{
for (int i = e->getFirst(); i <= e->getLast(); i++)
{
int p = i - 1;
if (p < 0 || p >= doc->getPageCount())
if (i < 0 || i > doc->getPageCount())
{
continue;
}

@ -259,4 +259,3 @@ XOJ_DECLARE_TYPE(PopplerGlibAction, 247);
XOJ_DECLARE_TYPE(XojCairoPdfExport, 248);

Loading…
Cancel
Save