I am using itextsharp for creating pdf and its working good, but now when I am trying to add a background image (as a watermark), and I want to change image color to black and white but don't know how doing that. I am posting screenshot and also code which I am using for added background image.
Code :
public class PdfWriterEvents : IPdfPageEvent
{
string watermarkText = string.Empty;
public PdfWriterEvents(string watermark)
{
watermarkText = watermark;
}
public void OnStartPage(PdfWriter writer, Document document)
{
float width = document.PageSize.Width;
float height = document.PageSize.Height;
try
{
PdfContentByte under = writer.DirectContentUnder;
Image image = Image.GetInstance(watermarkText);
image.ScaleToFit(275f, 275f);
image.SetAbsolutePosition(150, 300);
under.AddImage(image);
}
catch (Exception ex)
{
Console.Error.WriteLine(ex.Message);
}
}
public void OnEndPage(PdfWriter writer, Document document) { }
public void OnParagraph(PdfWriter writer, Document document, float paragraphPosition) { }
public void OnParagraphEnd(PdfWriter writer, Document document, float paragraphPosition) { }
public void OnChapter(PdfWriter writer, Document document, float paragraphPosition, Paragraph title) { }
public void OnChapterEnd(PdfWriter writer, Document document, float paragraphPosition) { }
public void OnSection(PdfWriter writer, Document document, float paragraphPosition, int depth, Paragraph title) { }
public void OnSectionEnd(PdfWriter writer, Document document, float paragraphPosition) { }
public void OnGenericTag(PdfWriter writer, Document document, Rectangle rect, String text) { }
public void OnOpenDocument(PdfWriter writer, Document document) { }
public void OnCloseDocument(PdfWriter writer, Document document) { }
}
For call this :
writer.PageEvent = new PdfWriterEvents(LogoImage);
So How can I change color to black and white like normal watermark image.
Thank you !