Marthee commited on
Commit
6a09ed7
·
verified ·
1 Parent(s): 193d145

Update Doors_Schedule.py

Browse files
Files changed (1) hide show
  1. 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
- for loc in locations:
390
- coor, lbl, clr,w = loc
391
- clr = (clr[0] / 255, clr[1] / 255, clr[2] / 255)
392
- for cor in coor:
393
- #Create a Circle annotation (Count Markup)
394
- annot = page.add_circle_annot(
395
- fitz.Rect(cor[0] - 10, cor[1] - 10, cor[0] + 10, cor[1] + 10) # Small circle
396
- )
397
-
398
- #Assign required Bluebeam metadata
399
- annot.set_colors(stroke=clr, fill=(1, 1, 1)) # Set stroke color and fill white
400
- annot.set_border(width=2) # Border thickness
401
- annot.set_opacity(1) # Fully visible
402
-
403
- #Set annotation properties for Bluebeam Count detection
404
- annot.set_info("name", lbl) # Unique name for each count
405
- annot.set_info("subject", "Count") #Bluebeam uses "Count" for Count markups
406
- annot.set_info("title", lbl) # Optional
407
- annot.update() # Apply changes
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()