Spaces:
Sleeping
Sleeping
Update pixelconversion.py
Browse files- pixelconversion.py +11 -8
pixelconversion.py
CHANGED
|
@@ -23,21 +23,24 @@ def openDrawPDF(path):
|
|
| 23 |
doc = fitz.open(path)
|
| 24 |
page = doc[0]
|
| 25 |
pix = page.get_pixmap(dpi=200) # render page to an image
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
-
if page.rect.height > page.rect.width:
|
| 28 |
-
rect = fitz.Rect(10, 10, (10+page.rect.width-50),( 10+700))
|
| 29 |
-
rectText=fitz.Rect(300, 200, (10+page.rect.width-50),( 300+100))
|
| 30 |
-
rotate=90
|
| 31 |
else:
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
| 35 |
annot = page.add_rect_annot(rect)
|
| 36 |
annot.set_colors( fill=(75/255,0,130/255) ,stroke=(75/255,0,130/255) )
|
| 37 |
annot.set_opacity(0.9)
|
| 38 |
annot.set_border(border=None, width=0)
|
| 39 |
annot.update()
|
| 40 |
-
|
| 41 |
text = """Scale Document"""
|
| 42 |
annot1=page.add_freetext_annot(rectText, text, fontsize=45, fontname='helv', border_color=(1,1,1), text_color=(1,1,1), rotate=rotate, align=1)
|
| 43 |
annot1.update()
|
|
|
|
| 23 |
doc = fitz.open(path)
|
| 24 |
page = doc[0]
|
| 25 |
pix = page.get_pixmap(dpi=200) # render page to an image
|
| 26 |
+
rotate=0
|
| 27 |
+
if page.rect.height > page.rect.width:
|
| 28 |
+
rect = fitz.Rect(80,80, (page.rect.width-80),( page.rect.width+80))
|
| 29 |
+
rectText=fitz.Rect(300, 200, (page.rect.width-80),( page.rect.width+80) )
|
| 30 |
+
rotate=0
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
else:
|
| 33 |
+
|
| 34 |
+
rect = fitz.Rect(80,80, (page.rect.height-80),( page.rect.height+80))
|
| 35 |
+
rectText=fitz.Rect(500, 200, (page.rect.height-80),( page.rect.height+80) )
|
| 36 |
+
rotate=90
|
| 37 |
+
|
| 38 |
annot = page.add_rect_annot(rect)
|
| 39 |
annot.set_colors( fill=(75/255,0,130/255) ,stroke=(75/255,0,130/255) )
|
| 40 |
annot.set_opacity(0.9)
|
| 41 |
annot.set_border(border=None, width=0)
|
| 42 |
annot.update()
|
| 43 |
+
|
| 44 |
text = """Scale Document"""
|
| 45 |
annot1=page.add_freetext_annot(rectText, text, fontsize=45, fontname='helv', border_color=(1,1,1), text_color=(1,1,1), rotate=rotate, align=1)
|
| 46 |
annot1.update()
|