@@ -420,6 +420,33 @@ protected void print(PDDocument document) throws IOException {
420420
421421 }
422422
423+ /**
424+ * @param fatline fatline true if line is fat, false if line is standard
425+ * (thinner)
426+ * @param left left coordinates in mm (note: in PDF, left starts at zero)
427+ * @param top top coordinates in mm (note: in PDF, bottom starts at zero
428+ * except if topatzero is set)
429+ * @param width width in mm, a positive number
430+ * @param height height in mm, a positive number
431+ * @param drawtop if true, draw the top line
432+ * @param drawbottom if true, draw the bottom line
433+ * @param drawleft if true, draw the left line
434+ * @param drawright if true, draw the right line
435+ * @throws IOException
436+ */
437+
438+ public void drawBoxWithWidthAndHeight (boolean fatline , float left , float top , float width , float height ,
439+ boolean drawtop ,boolean drawbottom ,boolean drawleft ,boolean drawright )
440+ throws IOException {
441+
442+ float right = left + width ;
443+ float bottom = top - height ;
444+ if (this .topatzero ) {
445+ bottom = top + height ;
446+ }
447+ drawBox (fatline , left , top , right , bottom ,Color .BLACK ,drawtop ,drawbottom ,drawleft ,drawright );
448+ }
449+
423450 /**
424451 * @param fatline fatline true if line is fat, false if line is standard
425452 * (thinner)
@@ -489,37 +516,42 @@ public void drawCircle(Color bordercolor, Color fillcolor, float centerx, float
489516 * @param bottom bottom coordinates in mm (note: in PDF, bottom starts at zero
490517 * except if topatzero is set)
491518 * @param color color of the box.
492- * @throws IOException
519+ * @param drawtop if true, draw the top line of the box
520+ * @param drawbottom if bottom, draw the bottom line of the box
521+ * @param drawleft if left ... well, draw the left line of the box
522+ * @param drawright if right (I think you got it) draw the right line of the box
523+ * @throws IOException if anything bad happens with the file being printed
493524 */
494- public void drawBox (boolean fatline , float left , float top , float right , float bottom , Color color )
525+
526+ public void drawBox (boolean fatline , float left , float top , float right , float bottom , Color color ,
527+ boolean drawtop ,boolean drawbottom ,boolean drawleft ,boolean drawright )
495528 throws IOException {
496529 this .widgetstoprint .add (() -> {
497- contentStream .setStrokingColor (color );
498- contentStream .setNonStrokingColor (color );
499-
500- if (!fatline )
501- contentStream .setLineWidth (NORMAL_LINE_WIDTH );
502- if (fatline )
503- contentStream .setLineWidth (FAT_LINE_WIDTH );
504-
505- float newtop = top ;
506- float newbottom = bottom ;
507- if (this .topatzero ) {
508- newtop = height - top ;
509- newbottom = height - bottom ;
510- }
511-
512- contentStream .moveTo (left * MM_TO_POINT , newtop * MM_TO_POINT );
513- contentStream .lineTo (right * MM_TO_POINT , newtop * MM_TO_POINT );
514- contentStream .lineTo (right * MM_TO_POINT , newbottom * MM_TO_POINT );
515- contentStream .lineTo (left * MM_TO_POINT , newbottom * MM_TO_POINT );
516- contentStream .lineTo (left * MM_TO_POINT , newtop * MM_TO_POINT );
517- contentStream .closeAndStroke ();
518- contentStream .setStrokingColor (Color .BLACK );
519- contentStream .setNonStrokingColor (Color .BLACK );
530+
531+ if (drawtop ) this .drawLine (fatline , left ,top , right ,top , color );
532+ if (drawbottom ) this .drawLine (fatline , left ,bottom , right ,bottom , color );
533+ if (drawleft ) this .drawLine (fatline , left ,top ,left ,bottom , color );
534+ if (drawright ) this .drawLine (fatline , right ,top ,right ,bottom , color );
520535 });
521536
522537 }
538+
539+ /**
540+ * @param fatline true if line is fat, false if line is standard (thinner)
541+ * @param left left coordinates in mm (note: in PDF, left starts at zero)
542+ * @param top top coordinates in mm (note: in PDF, bottom starts at zero
543+ * except if topatzero is set)
544+ * @param right right coordinates in mm (note: in PDF, left starts at zero)
545+ * @param bottom bottom coordinates in mm (note: in PDF, bottom starts at zero
546+ * except if topatzero is set)
547+ * @param color color of the box.
548+ * @throws IOException
549+ */
550+ public void drawBox (boolean fatline , float left , float top , float right , float bottom , Color color )
551+ throws IOException {
552+ drawBox (fatline ,left ,top ,right ,bottom ,color ,true ,true ,true ,true );
553+
554+ }
523555
524556 /**
525557 * Draws a rectangular box
@@ -1164,7 +1196,7 @@ public static BoxTextContent calculateBoxAndMaybeWriteText(float left, float top
11641196 if (i > 0 )
11651197 currentsplitparagraph = false ;
11661198 String paragraphtext = paragraphs [i ];
1167- logger .severe ("audit on line " +paragraphtext );
1199+ logger .finest ("audit on line " +paragraphtext );
11681200 ArrayList <String > paragraphlines = new ArrayList <String >();
11691201 int lastspace = -1 ;
11701202 // in this version, tab is treated as any other space
0 commit comments