Spaces:
Sleeping
Sleeping
Update Doors_Schedule.py
Browse files- Doors_Schedule.py +40 -19
Doors_Schedule.py
CHANGED
|
@@ -386,25 +386,46 @@ def add_bluebeam_count_annotations(pdf_bytes, locations):
|
|
| 386 |
pdf_document = fitz.open("pdf", pdf_stream.read()) # Open PDF in memory
|
| 387 |
|
| 388 |
page = pdf_document[0] # First page
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 408 |
|
| 409 |
#Save modified PDF to a variable instead of a file
|
| 410 |
output_stream = io.BytesIO()
|
|
|
|
| 386 |
pdf_document = fitz.open("pdf", pdf_stream.read()) # Open PDF in memory
|
| 387 |
|
| 388 |
page = pdf_document[0] # First page
|
| 389 |
+
if len(locations[0]) == 4:
|
| 390 |
+
for loc in locations:
|
| 391 |
+
coor, lbl, clr,w = loc
|
| 392 |
+
clr = (clr[0] / 255, clr[1] / 255, clr[2] / 255)
|
| 393 |
+
for cor in coor:
|
| 394 |
+
#Create a Circle annotation (Count Markup)
|
| 395 |
+
annot = page.add_circle_annot(
|
| 396 |
+
fitz.Rect(cor[0] - 10, cor[1] - 10, cor[0] + 10, cor[1] + 10) # Small circle
|
| 397 |
+
)
|
| 398 |
+
|
| 399 |
+
#Assign required Bluebeam metadata
|
| 400 |
+
annot.set_colors(stroke=clr, fill=(1, 1, 1)) # Set stroke color and fill white
|
| 401 |
+
annot.set_border(width=2) # Border thickness
|
| 402 |
+
annot.set_opacity(1) # Fully visible
|
| 403 |
+
|
| 404 |
+
#Set annotation properties for Bluebeam Count detection
|
| 405 |
+
annot.set_info("name", lbl) # Unique name for each count
|
| 406 |
+
annot.set_info("subject", "Count") #Bluebeam uses "Count" for Count markups
|
| 407 |
+
annot.set_info("title", lbl) # Optional
|
| 408 |
+
annot.update() # Apply changes
|
| 409 |
+
if len(locations[0]) == 5:
|
| 410 |
+
for loc in locations:
|
| 411 |
+
coor, lbl, clr,w,h = loc
|
| 412 |
+
clr = (clr[0] / 255, clr[1] / 255, clr[2] / 255)
|
| 413 |
+
for cor in coor:
|
| 414 |
+
#Create a Circle annotation (Count Markup)
|
| 415 |
+
annot = page.add_circle_annot(
|
| 416 |
+
fitz.Rect(cor[0] - 10, cor[1] - 10, cor[0] + 10, cor[1] + 10) # Small circle
|
| 417 |
+
)
|
| 418 |
+
|
| 419 |
+
#Assign required Bluebeam metadata
|
| 420 |
+
annot.set_colors(stroke=clr, fill=(1, 1, 1)) # Set stroke color and fill white
|
| 421 |
+
annot.set_border(width=2) # Border thickness
|
| 422 |
+
annot.set_opacity(1) # Fully visible
|
| 423 |
+
|
| 424 |
+
#Set annotation properties for Bluebeam Count detection
|
| 425 |
+
annot.set_info("name", lbl) # Unique name for each count
|
| 426 |
+
annot.set_info("subject", "Count") #Bluebeam uses "Count" for Count markups
|
| 427 |
+
annot.set_info("title", lbl) # Optional
|
| 428 |
+
annot.update() # Apply changes
|
| 429 |
|
| 430 |
#Save modified PDF to a variable instead of a file
|
| 431 |
output_stream = io.BytesIO()
|