Skip to content

Commit 2ee586c

Browse files
src/utils.py: rename show_pdf_page() arg src to docsrc, to match documentation.
This allows the name to be specified as documented; previously this failed.
1 parent b8dd942 commit 2ee586c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/utils.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,19 @@ def write_text(
106106
def show_pdf_page(
107107
page,
108108
rect,
109-
src,
109+
docsrc,
110110
pno=0,
111111
keep_proportion=True,
112112
overlay=True,
113113
oc=0,
114114
rotate=0,
115115
clip=None,
116116
) -> int:
117-
"""Show page number 'pno' of PDF 'src' in rectangle 'rect'.
117+
"""Show page number 'pno' of PDF 'docsrc' in rectangle 'rect'.
118118
119119
Args:
120120
rect: (rect-like) where to place the source image
121-
src: (document) source PDF
121+
docsrc: (document) source PDF
122122
pno: (int) source page number
123123
keep_proportion: (bool) do not change width-height-ratio
124124
overlay: (bool) put in foreground
@@ -165,15 +165,15 @@ def calc_matrix(sr, tr, keep=True, rotate=0):
165165
pymupdf.CheckParent(page)
166166
doc = page.parent
167167

168-
if not doc.is_pdf or not src.is_pdf:
168+
if not doc.is_pdf or not docsrc.is_pdf:
169169
raise ValueError("is no PDF")
170170

171171
if rect.is_empty or rect.is_infinite:
172172
raise ValueError("rect must be finite and not empty")
173173

174174
while pno < 0: # support negative page numbers
175-
pno += src.page_count
176-
src_page = src[pno] # load source page
175+
pno += docsrc.page_count
176+
src_page = docsrc[pno] # load source page
177177
if src_page.get_contents() == []:
178178
raise ValueError("nothing to show - source page empty")
179179

@@ -199,7 +199,7 @@ def calc_matrix(sr, tr, keep=True, rotate=0):
199199
i += 1
200200
_imgname = n + str(i)
201201

202-
isrc = src._graft_id # used as key for graftmaps
202+
isrc = docsrc._graft_id # used as key for graftmaps
203203
if doc._graft_id == isrc:
204204
raise ValueError("source document must not equal target")
205205

@@ -210,7 +210,7 @@ def calc_matrix(sr, tr, keep=True, rotate=0):
210210
doc.Graftmaps[isrc] = gmap
211211

212212
# take note of generated xref for automatic reuse
213-
pno_id = (isrc, pno) # id of src[pno]
213+
pno_id = (isrc, pno) # id of docsrc[pno]
214214
xref = doc.ShownPages.get(pno_id, 0)
215215

216216
if overlay:

0 commit comments

Comments
 (0)