I added background color (added rectangle with color to fill) with transparency but the existing text in the pdf is not visible after I add the rectangle.
Here is the code
public static void drawRectangle(PdfContentByte content, float width, float height)
{
content.SaveState();
PdfGState state = new PdfGState();
state.FillOpacity = 0.5F;
content.SetGState(state);
content.Rectangle(0, 0, width, height);
content.SetColorFill(new BaseColor(255, 255, 0));
content.Rectangle(0, 0, width, height);
content.Fill();
content.RestoreState();
}
Here is how i create the Content byte
Document doc = new Document();
PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(tBox_pdf.Text, FileMode.Create));
doc.Open();
PdfContentByte cb = writer.DirectContent;
drawRectangle(cb, doc.PageSize.Width, doc.PageSize.Height);
doc.Close();
Process.Start(tBox_pdf.Text);