@@ -504,8 +504,8 @@ public virtual void DrawBackground(DrawContext drawContext) {
504
504
// for gradient uses width and height = 1. For all othe cases the logic left as it was.
505
505
Rectangle imageRectangle ;
506
506
if ( backgroundXObject == null ) {
507
- backgroundXObject = CreateXObject ( backgroundImage . GetLinearGradientBuilder ( ) , backgroundArea , drawContext .
508
- GetDocument ( ) ) ;
507
+ backgroundXObject = iText . Layout . Renderer . AbstractRenderer . CreateXObject ( backgroundImage . GetLinearGradientBuilder
508
+ ( ) , backgroundArea , drawContext . GetDocument ( ) ) ;
509
509
imageRectangle = new Rectangle ( backgroundArea . GetX ( ) , backgroundArea . GetTop ( ) - backgroundXObject . GetHeight
510
510
( ) , 1 , 1 ) ;
511
511
}
@@ -548,17 +548,24 @@ public virtual void DrawBackground(DrawContext drawContext) {
548
548
}
549
549
}
550
550
551
- public virtual PdfFormXObject CreateXObject ( AbstractLinearGradientBuilder linearGradientBuilder , Rectangle
552
- xObjectArea , PdfDocument document ) {
553
- if ( linearGradientBuilder == null ) {
554
- return null ;
555
- }
551
+ /// <summary>
552
+ /// Create a
553
+ /// <see cref="iText.Kernel.Pdf.Xobject.PdfFormXObject"/>
554
+ /// with the given area and containing a linear gradient inside.
555
+ /// </summary>
556
+ /// <param name="linearGradientBuilder">the linear gradient builder</param>
557
+ /// <param name="xObjectArea">the result object area</param>
558
+ /// <param name="document">the pdf document</param>
559
+ /// <returns>the xObject with a specified area and a linear gradient</returns>
560
+ public static PdfFormXObject CreateXObject ( AbstractLinearGradientBuilder linearGradientBuilder , Rectangle
561
+ xObjectArea , PdfDocument document ) {
556
562
Rectangle formBBox = new Rectangle ( 0 , 0 , xObjectArea . GetWidth ( ) , xObjectArea . GetHeight ( ) ) ;
557
- PdfFormXObject xObject = null ;
558
- Color gradientColor = linearGradientBuilder . BuildColor ( formBBox , null ) ;
559
- if ( gradientColor != null ) {
560
- xObject = new PdfFormXObject ( formBBox ) ;
561
- new PdfCanvas ( xObject , document ) . SetColor ( gradientColor , true ) . Rectangle ( formBBox ) . Fill ( ) ;
563
+ PdfFormXObject xObject = new PdfFormXObject ( formBBox ) ;
564
+ if ( linearGradientBuilder != null ) {
565
+ Color gradientColor = linearGradientBuilder . BuildColor ( formBBox , null ) ;
566
+ if ( gradientColor != null ) {
567
+ new PdfCanvas ( xObject , document ) . SetColor ( gradientColor , true ) . Rectangle ( formBBox ) . Fill ( ) ;
568
+ }
562
569
}
563
570
return xObject ;
564
571
}
0 commit comments