Browse Source

linted

master
Holger Frey 6 years ago
parent
commit
1fbe133e7f
  1. 6
      pdftools/cli.py
  2. 4
      pdftools/formfill.py
  3. 1
      pdftools/nameplate.py
  4. 9
      pdftools/ruler.py

6
pdftools/cli.py

@ -66,13 +66,13 @@ def nameplates(attendees, logo, size, adjust_x, adjust_y): @@ -66,13 +66,13 @@ def nameplates(attendees, logo, size, adjust_x, adjust_y):
size and adjustment options.
"""
if logo is not None:
logo = nameplate.Logo(logo, size * mm, adjust_x=adjust_x, adjust_y=adjust_y)
logo = nameplate.Logo(
logo, size * mm, adjust_x=adjust_x, adjust_y=adjust_y
)
npc = nameplate.NamePlateCards(logo)
npc.generate(attendees, show=True)
@click.command()
@click.argument(
"pdf",

4
pdftools/formfill.py

@ -1,11 +1,9 @@ @@ -1,11 +1,9 @@
import pdfrw
import subprocess
import itertools
import tempfile
from pathlib import Path
from reportlab.pdfgen import canvas
from reportlab.lib.units import mm
from reportlab.lib.pagesizes import A4
@ -48,5 +46,3 @@ def fill(original_form, values, draw_function, output_file="filled.pdf"): @@ -48,5 +46,3 @@ def fill(original_form, values, draw_function, output_file="filled.pdf"):
# write the combined file to the output
pdfrw.PdfWriter().write(output_file, form)
subprocess.run(["open", output_file])

1
pdftools/nameplate.py

@ -41,6 +41,7 @@ false_and_true = itertools.cycle([False, True]) @@ -41,6 +41,7 @@ false_and_true = itertools.cycle([False, True])
imtek_logo_path = Path(__file__).parent / "logo_imtek.png"
class NamePlateCards:
def __init__(
self,

9
pdftools/ruler.py

@ -5,20 +5,19 @@ from . import formfill @@ -5,20 +5,19 @@ from . import formfill
def ruler_overlay(original_form):
def ruler(c, item):
c.setStrokeColorRGB(0, 0, 1)
c.setFillColorRGB(0, 0, 1)
c.setLineWidth(0.5)
c.setFont("Helvetica", 8)
x_grid = [x*mm for x in range(10, 210, 10)]
y_grid = [y*mm for y in range(10, 297, 10)]
x_grid = [x * mm for x in range(10, 210, 10)]
y_grid = [y * mm for y in range(10, 297, 10)]
c.grid(x_grid, y_grid)
for x in range(10, 210, 10):
c.drawString((x-2)*mm, 5*mm, str(x))
c.drawString((x - 2) * mm, 5 * mm, str(x))
for y in range(10, 297, 10):
c.drawString(4*mm, (y-0.5)*mm, str(y))
c.drawString(4 * mm, (y - 0.5) * mm, str(y))
ofp = Path(original_form)
out_path = ofp.parent / f"{ofp.stem}_ruler.pdf"

Loading…
Cancel
Save