forked from josch/plakativ
remove pdfrw https://bugs.debian.org/958362
This commit is contained in:
parent
f1dba65984
commit
72b3c6d924
3 changed files with 35 additions and 10 deletions
|
@ -82,7 +82,7 @@ While basic functionality is implemented, lots of work remains to be done:
|
||||||
- changing units
|
- changing units
|
||||||
- changing language
|
- changing language
|
||||||
- make PyMuPDF dependency optional
|
- make PyMuPDF dependency optional
|
||||||
- optionally, use pdfrw and/or pypdf2 to read/write PDF
|
- optionally, use pypdf2 to read/write PDF
|
||||||
- improve command line interface
|
- improve command line interface
|
||||||
- improve module interface
|
- improve module interface
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ environment:
|
||||||
- PYTHON: "C:\\Python37-x64"
|
- PYTHON: "C:\\Python37-x64"
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- "%PYTHON%\\python.exe -m pip install wheel PyMuPDF pytest pdfrw pyinstaller"
|
- "%PYTHON%\\python.exe -m pip install wheel PyMuPDF pytest pyinstaller"
|
||||||
|
|
||||||
build: off
|
build: off
|
||||||
|
|
||||||
|
|
41
test.py
41
test.py
|
@ -4,7 +4,7 @@ import tempfile
|
||||||
import fitz
|
import fitz
|
||||||
import fitz.utils
|
import fitz.utils
|
||||||
import os
|
import os
|
||||||
import pdfrw
|
import math
|
||||||
|
|
||||||
|
|
||||||
def mm_to_pt(length):
|
def mm_to_pt(length):
|
||||||
|
@ -180,12 +180,37 @@ def test_cases(postersize, input_pagesize, output_pagesize, strategy, expected):
|
||||||
)
|
)
|
||||||
os.unlink(infile)
|
os.unlink(infile)
|
||||||
|
|
||||||
reader = pdfrw.PdfReader(outfile)
|
doc = fitz.open(outfile)
|
||||||
os.unlink(outfile)
|
os.unlink(outfile)
|
||||||
|
|
||||||
pages = reader.Root.Pages.Kids
|
for pnum, (bbox, matrix) in zip(range(doc.pageCount), expected):
|
||||||
assert len(pages) == len(expected)
|
xreflist = doc._getPageInfo(pnum, 3)
|
||||||
|
assert len(xreflist) >= 1
|
||||||
for page, (bbox, matrix) in zip(pages, expected):
|
xref, name, _, _ = xreflist[0]
|
||||||
assert page.Resources.XObject.fzFrm0.BBox == bbox
|
assert name == "fzFrm0"
|
||||||
assert page.Resources.XObject.fzFrm0.Matrix == matrix
|
# doc.xrefObject() will return something like:
|
||||||
|
# <<
|
||||||
|
# /Type /XObject
|
||||||
|
# /Subtype /Form
|
||||||
|
# /BBox [ 185.47917 262.17189 445.79167 595 ]
|
||||||
|
# /Matrix [ 2.286773 0 0 2.286773 -424.1487 -599.5276 ]
|
||||||
|
# /Resources <<
|
||||||
|
# /XObject <<
|
||||||
|
# /fullpage 7 0 R
|
||||||
|
# >>
|
||||||
|
# >>
|
||||||
|
# /Length 12
|
||||||
|
# >>
|
||||||
|
keyvals = dict(
|
||||||
|
tuple(line.strip().split(maxsplit=1))
|
||||||
|
for line in doc.xrefObject(xref).splitlines()
|
||||||
|
if " " in line.strip()
|
||||||
|
)
|
||||||
|
assert "/BBox" in keyvals
|
||||||
|
newbbox = keyvals["/BBox"].strip(" []").split()
|
||||||
|
for v1, v2 in zip(bbox, newbbox):
|
||||||
|
assert math.isclose(float(v1), float(v2), abs_tol=0.00001)
|
||||||
|
assert "/Matrix" in keyvals
|
||||||
|
newmatrix = keyvals["/Matrix"].strip(" []").split()
|
||||||
|
for v1, v2 in zip(matrix, newmatrix):
|
||||||
|
assert math.isclose(float(v1), float(v2), abs_tol=0.00001)
|
||||||
|
|
Loading…
Reference in a new issue