@@ -13,26 +13,30 @@ export class Pattern extends NonRenderedNode {
1313 }
1414
1515 // the transformations directly at the node are written to the pattern transformation matrix
16+ const x = context . svg2pdfParameters . x ?? 0
17+ const y = context . svg2pdfParameters . y ?? 0
1618 const bBox = this . getBoundingBox ( context )
17- const pattern = new TilingPattern (
18- [ bBox [ 0 ] , bBox [ 1 ] , bBox [ 0 ] + bBox [ 2 ] , bBox [ 1 ] + bBox [ 3 ] ] ,
19- bBox [ 2 ] ,
20- bBox [ 3 ]
21- )
19+ const startX = bBox [ 0 ] + x
20+ const startY = bBox [ 1 ] + y
21+ const width = bBox [ 2 ]
22+ const height = bBox [ 3 ]
23+ const endX = startX + width
24+ const endY = startY + height
25+ const pattern = new TilingPattern ( [ startX , startY , endX , endY ] , width , height )
2226
2327 context . pdf . beginTilingPattern ( pattern )
2428 // continue without transformation
2529
2630 for ( const child of this . children ) {
27- await child . render (
28- new Context ( context . pdf , {
29- attributeState : context . attributeState ,
30- refsHandler : context . refsHandler ,
31- styleSheets : context . styleSheets ,
32- viewport : context . viewport ,
33- svg2pdfParameters : context . svg2pdfParameters
34- } )
35- )
31+ const childContext = new Context ( context . pdf , {
32+ attributeState : context . attributeState ,
33+ refsHandler : context . refsHandler ,
34+ styleSheets : context . styleSheets ,
35+ viewport : context . viewport ,
36+ svg2pdfParameters : context . svg2pdfParameters ,
37+ transform : context . pdf . Matrix ( 1 , 0 , 0 , 1 , x , y )
38+ } )
39+ await child . render ( childContext )
3640 }
3741 context . pdf . endTilingPattern ( id , pattern )
3842 }
0 commit comments