diff options
| author | jvoisin | 2011-12-04 13:53:04 +0100 |
|---|---|---|
| committer | jvoisin | 2011-12-04 13:53:04 +0100 |
| commit | 2ba7a313fd0dd3d5e61927e93be4ed71e2fbaee1 (patch) | |
| tree | 366ab80fa188ce436f264d5b2baf13971a0d2de1 /mat | |
| parent | 697cf6187671c92bf9a81572e5329a1dea3c21e7 (diff) | |
"PDF" and not "pdf"
Diffstat (limited to 'mat')
| -rw-r--r-- | mat/office.py | 10 | ||||
| -rw-r--r-- | mat/strippers.py | 4 |
2 files changed, 7 insertions, 7 deletions
diff --git a/mat/office.py b/mat/office.py index d1e781e..d6ad367 100644 --- a/mat/office.py +++ b/mat/office.py | |||
| @@ -112,7 +112,7 @@ class OpenDocumentStripper(archive.GenericArchiveStripper): | |||
| 112 | 112 | ||
| 113 | class PdfStripper(parser.GenericParser): | 113 | class PdfStripper(parser.GenericParser): |
| 114 | ''' | 114 | ''' |
| 115 | Represent a pdf file | 115 | Represent a PDF file |
| 116 | ''' | 116 | ''' |
| 117 | def __init__(self, filename, parser, mime, backup, add2archive): | 117 | def __init__(self, filename, parser, mime, backup, add2archive): |
| 118 | super(PdfStripper, self).__init__(filename, parser, mime, backup, | 118 | super(PdfStripper, self).__init__(filename, parser, mime, backup, |
| @@ -143,7 +143,7 @@ class PdfStripper(parser.GenericParser): | |||
| 143 | 143 | ||
| 144 | def remove_all_ugly(self): | 144 | def remove_all_ugly(self): |
| 145 | ''' | 145 | ''' |
| 146 | Opening the pdf with poppler, then doing a render | 146 | Opening the PDF with poppler, then doing a render |
| 147 | on a cairo pdfsurface for each pages. | 147 | on a cairo pdfsurface for each pages. |
| 148 | Thanks to Lunar^for the idea. | 148 | Thanks to Lunar^for the idea. |
| 149 | http://cairographics.org/documentation/pycairo/2/ | 149 | http://cairographics.org/documentation/pycairo/2/ |
| @@ -153,7 +153,7 @@ class PdfStripper(parser.GenericParser): | |||
| 153 | page_width, page_height = page.get_size() | 153 | page_width, page_height = page.get_size() |
| 154 | surface = cairo.PDFSurface(self.output, page_width, page_height) | 154 | surface = cairo.PDFSurface(self.output, page_width, page_height) |
| 155 | context = cairo.Context(surface) # context draws on the surface | 155 | context = cairo.Context(surface) # context draws on the surface |
| 156 | logging.debug('Pdf rendering of %s' % self.filename) | 156 | logging.debug('PDF rendering of %s' % self.filename) |
| 157 | for pagenum in xrange(self.document.get_n_pages()): | 157 | for pagenum in xrange(self.document.get_n_pages()): |
| 158 | page = self.document.get_page(pagenum) | 158 | page = self.document.get_page(pagenum) |
| 159 | context.translate(0, 0) | 159 | context.translate(0, 0) |
| @@ -165,7 +165,7 @@ class PdfStripper(parser.GenericParser): | |||
| 165 | def _remove_meta(self): | 165 | def _remove_meta(self): |
| 166 | ''' | 166 | ''' |
| 167 | Remove superficial/external metadata | 167 | Remove superficial/external metadata |
| 168 | from a pdf file, using exiftool, | 168 | from a PDF file, using exiftool, |
| 169 | of pdfrw if exiftool is not installed | 169 | of pdfrw if exiftool is not installed |
| 170 | ''' | 170 | ''' |
| 171 | processed = False | 171 | processed = False |
| @@ -203,7 +203,7 @@ class PdfStripper(parser.GenericParser): | |||
| 203 | 203 | ||
| 204 | if processed is False: | 204 | if processed is False: |
| 205 | logging.error('Please install either pdfrw, or exiftool to\ | 205 | logging.error('Please install either pdfrw, or exiftool to\ |
| 206 | fully handle pdf files') | 206 | fully handle PDF files') |
| 207 | return processed | 207 | return processed |
| 208 | 208 | ||
| 209 | def get_meta(self): | 209 | def get_meta(self): |
diff --git a/mat/strippers.py b/mat/strippers.py index 1cf2271..7d27874 100644 --- a/mat/strippers.py +++ b/mat/strippers.py | |||
| @@ -20,13 +20,13 @@ STRIPPERS = { | |||
| 20 | 'application/officeopenxml': office.OpenXmlStripper, | 20 | 'application/officeopenxml': office.OpenXmlStripper, |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | try: # pdf support | 23 | try: # PDF support |
| 24 | import poppler | 24 | import poppler |
| 25 | import cairo | 25 | import cairo |
| 26 | STRIPPERS['application/x-pdf'] = office.PdfStripper | 26 | STRIPPERS['application/x-pdf'] = office.PdfStripper |
| 27 | STRIPPERS['application/pdf'] = office.PdfStripper | 27 | STRIPPERS['application/pdf'] = office.PdfStripper |
| 28 | except ImportError: | 28 | except ImportError: |
| 29 | print('Unable to import python-poppler and/or python-cairo: no pdf \ | 29 | print('Unable to import python-poppler and/or python-cairo: no PDF \ |
| 30 | support') | 30 | support') |
| 31 | 31 | ||
| 32 | try: # mutangen-python : audio format support | 32 | try: # mutangen-python : audio format support |
