How to use the paperwork-backend.paperwork_backend.common.export.Exporter function in paperwork-backend

To help you get started, we’ve selected a few paperwork-backend examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openpaperwork / paperwork / paperwork-backend / paperwork_backend / common / page.py View on Github external
import logging
import os
import os.path
import tempfile

import PIL.Image

from ..common.export import Exporter
from ..common.export import dummy_export_progress_cb
from ..util import strip_accents
from ..util import split_words

logger = logging.getLogger(__name__)


class PageExporter(Exporter):
    def __init__(self, page, img_format='PNG', mime='image/png',
                 valid_exts=['png']):
        super().__init__(page, img_format)
        self.can_change_quality = True
        self.can_select_format = False
        self.page = page
        self.img_format = img_format
        self.mime = mime
        self.valid_exts = valid_exts
        self.__quality = 75
        self.__img = None
        self.__postprocess_func = None

    def get_mime_type(self):
        return self.mime
github openpaperwork / paperwork / paperwork-backend / paperwork_backend / pdf / doc.py View on Github external
import logging

from gi.repository import GLib
from gi.repository import Gio
from gi.repository import Poppler

from ..common.doc import BasicDoc
from ..common.export import Exporter
from ..common.export import dummy_export_progress_cb
from ..pdf.page import PdfPage

PDF_FILENAME = "doc.pdf"
logger = logging.getLogger(__name__)


class PdfDocExporter(Exporter):
    def __init__(self, doc, page_nb):
        super().__init__(doc, 'PDF')
        self.can_select_format = False
        self.can_change_quality = False
        self.doc = doc
        self.page = doc.pages[page_nb]
        self.pdfpath = doc.fs.join(doc.path, PDF_FILENAME)

    def get_mime_type(self):
        return 'application/pdf'

    def get_file_extensions(self):
        return ['pdf']

    def save(self, target_path, progress_cb=dummy_export_progress_cb):
        target_path = self.doc.fs.safe(target_path)
github openpaperwork / paperwork / paperwork-backend / paperwork_backend / docexport.py View on Github external
from .common.export import Exporter
from .common.export import dummy_export_progress_cb
from . import fs


FS = fs.GioFileSystem()


class MultipleDocExporter(Exporter):
    can_select_format = False
    can_change_quality = False

    def __init__(self, doclist):
        super().__init__(doclist, 'PDF')
        global FS
        self.fs = FS
        self.doclist = doclist
        self.exporters = [doc.build_exporter() for doc in doclist]
        self.ref_exporter = self.exporters[0]
        self.ref_doc = doclist[0]

        self.nb_pages = 0
        for doc in self.doclist:
            self.nb_pages += doc.nb_pages
github openpaperwork / paperwork / paperwork-backend / paperwork_backend / img / doc.py View on Github external
except:
    PANGO_AVAILABLE = False
from gi.repository import Gio
from gi.repository import Poppler

from ..common.doc import BasicDoc
from ..common.export import dummy_export_progress_cb
from ..common.export import Exporter
from ..img.page import ImgPage
from ..util import image2surface
from ..util import surface2image

logger = logging.getLogger(__name__)


class ImgToPdfDocExporter(Exporter):
    def __init__(self, doc, page_nb):
        super().__init__(doc, 'PDF')
        self.can_change_quality = True
        self.can_select_format = True
        self.valid_exts = ['pdf']
        self.doc = doc
        self.page_nb = page_nb
        self.__quality = 50
        self.__preview = None  # will just contain the first page
        self.__page_format = (0, 0)
        self.__process_func = None

    def get_mime_type(self):
        return 'application/pdf'

    def get_file_extensions(self):