@@ -27,7 +27,7 @@ def __init__(self, stroke, fill, text):
2727
2828class Marisol :
2929
30- def __init__ (self , prefix , fill , start , area = Area .BOTTOM_RIGHT ):
30+ def __init__ (self , prefix , fill , start , area = Area .BOTTOM_RIGHT , offset_horizontal = None , offset_vertical = None , font_size = None ):
3131 """
3232 Marisol Base Class - A collection of documents to be bates numbered.
3333
@@ -36,6 +36,9 @@ def __init__(self, prefix, fill, start, area=Area.BOTTOM_RIGHT):
3636 fill (int): Length for zero-filling
3737 start (int): Starting bates number
3838 area (Area): Area in which to place the bates number.
39+ offset_horizontal: distance from the left or right edge to place the bates number
40+ offset_vertical: distance from the top or bottom edge to place the bates number
41+ font_size: the size of the font for the bates number
3942 """
4043 self .prefix = prefix
4144 self .fill = fill
@@ -46,6 +49,9 @@ def __init__(self, prefix, fill, start, area=Area.BOTTOM_RIGHT):
4649 self .number = 0
4750
4851 self .documents = []
52+ self .offset_horizontal = offset_horizontal
53+ self .offset_vertical = offset_vertical
54+ self .font_size = font_size
4955 self .overwrite = False
5056
5157 def __getitem__ (self , key ):
@@ -90,7 +96,7 @@ def append(self, file):
9096 Returns:
9197 marisol.Marisol: The current Marisol instance.
9298 """
93- d = Document (file , self .prefix , self .fill , self .start + self .number , self .area )
99+ d = Document (file , self .prefix , self .fill , self .start + self .number , self .area , self . offset_horizontal , self . offset_vertical , self . font_size )
94100 self .number += len (d )
95101 self .documents .append (d )
96102 return self
@@ -114,7 +120,7 @@ def save(self, overwrite=False, threads=multiprocessing.cpu_count()*6):
114120
115121class Document :
116122
117- def __init__ (self , file , prefix , fill , start , area ):
123+ def __init__ (self , file , prefix , fill , start , area , offset_horizontal = None , offset_vertical = None , font_size = None ):
118124 """
119125 Represents a document to be numbered.
120126
@@ -124,6 +130,9 @@ def __init__(self, file, prefix, fill, start, area):
124130 fill (int): Length to zero-pad number to.
125131 start (int): Number to start with.
126132 area (Area): Area on the document where the number should be drawn
133+ offset_horizontal: distance from the left or right edge to place the bates number
134+ offset_vertical: distance from the top or bottom edge to place the bates number
135+ font_size: the size of the font for the bates number
127136 """
128137 self .reader = Pdf .open (file )
129138 self .prefix = prefix
@@ -132,13 +141,13 @@ def __init__(self, file, prefix, fill, start, area):
132141 self .area = area
133142
134143 self .overlays = {x : None for x in Area }
135- self .overlays [area ] = BatesOverlay (None , self .area )
144+ self .overlays [area ] = BatesOverlay (None , self .area , offset_horizontal , offset_vertical )
136145
137146 self .index = 0
138147
139148 self .pages = []
140149 for num , page in enumerate (self .reader .pages ):
141- p = Page (self , page , self .prefix , self .fill , self .start + num )
150+ p = Page (self , page , self .prefix , self .fill , self .start + num , font_size )
142151 self .pages .append (p )
143152
144153 def __getitem__ (self , k ):
@@ -226,7 +235,7 @@ def add_overlay(self, overlay):
226235
227236class Page :
228237
229- def __init__ (self , document , page , prefix , fill , start ):
238+ def __init__ (self , document , page , prefix , fill , start , font_size = None ):
230239 """
231240 Represents a page within a document that will be bates numbered.
232241
@@ -236,6 +245,7 @@ def __init__(self, document, page, prefix, fill, start):
236245 prefix (str): Bates number prefix.
237246 fill (int): Length to zero-pad number to.
238247 start (int): Number to start with.
248+ font_size: the size of the font for the bates number
239249 """
240250 self .document = document
241251 self .page = page
@@ -248,6 +258,7 @@ def __init__(self, document, page, prefix, fill, start):
248258
249259 self .canvas_file = io .BytesIO ()
250260 self .canvas = canvas .Canvas (self .canvas_file , pagesize = (self .width , self .height ))
261+ self .canvas .setFontSize (font_size )
251262
252263 self .redactions = []
253264
@@ -310,9 +321,11 @@ def number(self):
310321
311322class GenericTextOverlay :
312323
313- def __init__ (self , text , area ):
324+ def __init__ (self , text , area , offset_horizontal = 15 , offset_vertical = 15 ):
314325 self .text = text
315326 self .area = area
327+ self .offset_horizontal = offset_horizontal
328+ self .offset_vertical = offset_vertical
316329
317330 def apply (self , c ):
318331 """
@@ -335,14 +348,14 @@ def position(self, c):
335348 tuple: the position
336349 """
337350 if self .area in [Area .TOP_LEFT , Area .TOP_RIGHT ]: # top
338- from_bottom = c ._pagesize [1 ]- 15 # 15 down from height of page
351+ from_bottom = c ._pagesize [1 ] - self . offset_vertical # down from height of page
339352 elif self .area in [Area .BOTTOM_LEFT , Area .BOTTOM_RIGHT ]: # bottom
340- from_bottom = 15 # 15 up from bottom of page
353+ from_bottom = self . offset_vertical # up from bottom of page
341354
342355 if self .area in [Area .TOP_LEFT , Area .BOTTOM_LEFT ]: # left
343- from_left = 15
356+ from_left = self . offset_horizontal
344357 elif self .area in [Area .TOP_RIGHT , Area .BOTTOM_RIGHT ]: # right
345- offset = 15 # initial offset
358+ offset = self . offset_horizontal # initial offset
346359 offset += c .stringWidth (self .text ) # offset for text length
347360 from_left = c ._pagesize [0 ]- offset
348361
0 commit comments