Apologies if this has been asked elsewhere.
I am using html2pdf and have created a pdf from my html and I'd like to add extra text to the page using the text layer. I'm adding 2 layers because I want them to have different fonts & collours but for some reason, even with one layer, I can't get the font to set to what I've asked for. I'm using an On_AfterRenderPage method as follows:
Code: C#
private static void On_AfterRenderPage(object sender, EO.Pdf.PdfPageEventArgs e)
{
//Create a new text layer
EO.Pdf.Contents.PdfTextLayer textLayer1 = new EO.Pdf.Contents.PdfTextLayer();
textLayer1.Font = new EO.Pdf.Drawing.PdfFont("Arial", 12);
textLayer1.NonStrokingColor = Color.Gray;
//Create a new text layer
EO.Pdf.Contents.PdfTextLayer textLayer2 = new EO.Pdf.Contents.PdfTextLayer();
textLayer2.Font = new EO.Pdf.Drawing.PdfFont("Arial", 8);
textLayer2.NonStrokingColor = Color.Black;
//Create the text object
EO.Pdf.Contents.PdfTextContent textContent1 = new EO.Pdf.Contents.PdfTextContent("Text 1l");
textContent1.PositionMode = EO.Pdf.Contents.PdfTextPositionMode.Matrix;
textContent1.GfxMatrix.Translate(44, 28);
//Create the text object
EO.Pdf.Contents.PdfTextContent textContent2 = new EO.Pdf.Contents.PdfTextContent("text 2");
textContent2.PositionMode = EO.Pdf.Contents.PdfTextPositionMode.Matrix;
textContent2.GfxMatrix.Translate(265,28);
//Add the text object into the text layer object
textLayer1.Contents.Add(textContent1);
textLayer2.Contents.Add(textContent2);
//Add the text layers onto the page
e.Page.Contents.Add(textLayer1);
e.Page.Contents.Add(textLayer2);
}
The text has no issue displaying or changing colour using the NonStrokingColor variable but for some reason the font request is being ignored. Can you advise me where I may have gone wrong?
Thanks!
Sarah