diff options
| author | jvoisin | 2022-03-28 22:34:57 +0200 |
|---|---|---|
| committer | jvoisin | 2022-03-28 22:34:57 +0200 |
| commit | 5ccddae7f5a4482d0868158f19ceddf8a20c9225 (patch) | |
| tree | 4f30da7b832a80ba95a132c001393d03f2e1f6bd /libmat2/pdf.py | |
| parent | 12582ba2f5017906e3e3382197f6eaf732d1d10e (diff) | |
Fix the PDF version
This should prevent the testsuite from breaking,
and marginally increase fingerprinting resistance.
Diffstat (limited to 'libmat2/pdf.py')
| -rw-r--r-- | libmat2/pdf.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/libmat2/pdf.py b/libmat2/pdf.py index ff12fc2..b79c7c7 100644 --- a/libmat2/pdf.py +++ b/libmat2/pdf.py | |||
| @@ -22,6 +22,7 @@ if LooseVersion(poppler_version) < LooseVersion('0.46'): # pragma: no cover | |||
| 22 | raise ValueError("mat2 needs at least Poppler version 0.46 to work. \ | 22 | raise ValueError("mat2 needs at least Poppler version 0.46 to work. \ |
| 23 | The installed version is %s." % poppler_version) # pragma: no cover | 23 | The installed version is %s." % poppler_version) # pragma: no cover |
| 24 | 24 | ||
| 25 | FIXED_PDF_VERSION = cairo.PDFVersion.VERSION_1_5 | ||
| 25 | 26 | ||
| 26 | class PDFParser(abstract.AbstractParser): | 27 | class PDFParser(abstract.AbstractParser): |
| 27 | mimetypes = {'application/pdf', } | 28 | mimetypes = {'application/pdf', } |
| @@ -52,6 +53,7 @@ class PDFParser(abstract.AbstractParser): | |||
| 52 | 53 | ||
| 53 | tmp_path = tempfile.mkstemp()[1] | 54 | tmp_path = tempfile.mkstemp()[1] |
| 54 | pdf_surface = cairo.PDFSurface(tmp_path, 10, 10) # resized later anyway | 55 | pdf_surface = cairo.PDFSurface(tmp_path, 10, 10) # resized later anyway |
| 56 | pdf_surface.restrict_to_version(FIXED_PDF_VERSION) | ||
| 55 | pdf_context = cairo.Context(pdf_surface) # context draws on the surface | 57 | pdf_context = cairo.Context(pdf_surface) # context draws on the surface |
| 56 | 58 | ||
| 57 | for pagenum in range(pages_count): | 59 | for pagenum in range(pages_count): |
| @@ -80,6 +82,7 @@ class PDFParser(abstract.AbstractParser): | |||
| 80 | 82 | ||
| 81 | _, tmp_path = tempfile.mkstemp() | 83 | _, tmp_path = tempfile.mkstemp() |
| 82 | pdf_surface = cairo.PDFSurface(tmp_path, 32, 32) # resized later anyway | 84 | pdf_surface = cairo.PDFSurface(tmp_path, 32, 32) # resized later anyway |
| 85 | pdf_surface.restrict_to_version(FIXED_PDF_VERSION) | ||
| 83 | pdf_context = cairo.Context(pdf_surface) | 86 | pdf_context = cairo.Context(pdf_surface) |
| 84 | 87 | ||
| 85 | for pagenum in range(pages_count): | 88 | for pagenum in range(pages_count): |
