@@ -2576,18 +2576,6 @@ class CanvasGraphics {
25762576 if ( group . matrix ) {
25772577 currentCtx . transform ( ...group . matrix ) ;
25782578 }
2579- if ( ! group . bbox ) {
2580- throw new Error ( "Bounding box is required." ) ;
2581- }
2582-
2583- // Based on the current transform figure out how big the bounding box
2584- // will actually be.
2585- let bounds = MIN_MAX_INIT . slice ( ) ;
2586- Util . axialAlignedBoundingBox (
2587- group . bbox ,
2588- getCurrentTransform ( currentCtx ) ,
2589- bounds
2590- ) ;
25912579
25922580 // Clip the bounding box to the current canvas.
25932581 const canvasBounds = [
@@ -2596,7 +2584,23 @@ class CanvasGraphics {
25962584 currentCtx . canvas . width ,
25972585 currentCtx . canvas . height ,
25982586 ] ;
2599- bounds = Util . intersect ( bounds , canvasBounds ) || [ 0 , 0 , 0 , 0 ] ;
2587+
2588+ let bounds ;
2589+ if ( group . bbox ) {
2590+ bounds = MIN_MAX_INIT . slice ( ) ;
2591+ Util . axialAlignedBoundingBox (
2592+ group . bbox ,
2593+ getCurrentTransform ( currentCtx ) ,
2594+ bounds
2595+ ) ;
2596+
2597+ bounds = Util . intersect ( bounds , canvasBounds ) || [ 0 , 0 , 0 , 0 ] ;
2598+ } else {
2599+ bounds = canvasBounds ;
2600+ }
2601+
2602+ // Based on the current transform figure out how big the bounding box
2603+ // will actually be.
26002604 // Use ceil in case we're between sizes so we don't create canvas that is
26012605 // too small and make the canvas at least 1x1 pixels.
26022606 const offsetX = Math . floor ( bounds [ 0 ] ) ;
@@ -2624,15 +2628,17 @@ class CanvasGraphics {
26242628 groupCtx . transform ( ...currentTransform ) ;
26252629
26262630 // Apply the bbox to the group context.
2627- let clip = new Path2D ( ) ;
2628- const [ x0 , y0 , x1 , y1 ] = group . bbox ;
2629- clip . rect ( x0 , y0 , x1 - x0 , y1 - y0 ) ;
2630- if ( group . matrix ) {
2631- const path = new Path2D ( ) ;
2632- path . addPath ( clip , new DOMMatrix ( group . matrix ) ) ;
2633- clip = path ;
2631+ if ( group . bbox ) {
2632+ let clip = new Path2D ( ) ;
2633+ const [ x0 , y0 , x1 , y1 ] = group . bbox ;
2634+ clip . rect ( x0 , y0 , x1 - x0 , y1 - y0 ) ;
2635+ if ( group . matrix ) {
2636+ const path = new Path2D ( ) ;
2637+ path . addPath ( clip , new DOMMatrix ( group . matrix ) ) ;
2638+ clip = path ;
2639+ }
2640+ groupCtx . clip ( clip ) ;
26342641 }
2635- groupCtx . clip ( clip ) ;
26362642
26372643 if ( group . smask ) {
26382644 // Saving state and cached mask to be used in setGState.
0 commit comments