I am trying to draw a vertical gradient at the bottom of an iTextSharp pdf document:
PdfShading shading = PdfShading.SimpleAxial(pdfWriter, 0, document.PageSize.Height, document.PageSize.Width, 0, BaseColor.WHITE, BaseColor.GREEN);
PdfShadingPattern pattern = new PdfShadingPattern(shading);
pdfContentByte.SetShadingFill(pattern);
pdfContentByte.Rectangle(0, 0, document.PageSize.Width, 70);
pdfContentByte.Fill();
This creates a gradient at the exact position I want it to be created, but the gradient is horizontal from left (white) to right (green).
I want the gradient to be vertical from top (white) to bottom (green).
Modifying the coordinates like some one did here (Does iTextsharp support multi color diagonal gradients?) did not solve the problem. I also tried to rotate the document but that didn't work as well.
You are using the wrong coordinates. In Java, you'd need something like this:
See GradientTopToBottom for the full sample code.
Do you see the difference?
0, document.PageSize.Height
) to the right-bottom corner (document.PageSize.Width, 0
). That's a diagonal.0, document.PageSize.Height
) to the bottom (0, 0
) which leads to the following result: gradient_top_to_bottom.pdf