We are trying to create a overlay pdf using itext and its working.
We are also trying to change the entire text font color of our pdf.
We are trying to do it using itext and c#.net
The font color is not changing
I also attached the pdf file.
Below is the code snippet.
string outputFile = @"./Overlay.pdf";
iTextSharp.text.pdf.PdfReader reader = new iTextSharp.text.pdf.PdfReader(sourcefilePath);
iTextSharp.text.pdf.PdfReader sReader = new iTextSharp.text.pdf.PdfReader(overlayfilePath);
PdfStamper stamper = new PdfStamper(reader, new FileStream(outputFile, FileMode.Create));
int inputDocumentPages = reader.NumberOfPages;
int overlayDocumentPages = sReader.NumberOfPages;
PdfContentByte background;
for (int i = 1; i <= inputDocumentPages; i++)
{
if (i <= overlayDocumentPages)
{
PdfImportedPage page = stamper.GetImportedPage(sReader, i);
background = stamper.GetUnderContent(i);
background.AddTemplate(page, 0, 0);
PdfGState state = new PdfGState();
state.FillOpacity = 0.6f;
state.BlendMode = PdfGState.BM_MULTIPLY;
background.SetGState(state);
background.SaveState();
background.BeginText();
background.SetColorFill(BaseColor.RED);
background.EndText();
background.Fill();
}
}
stamper.Close();