Hi All,
I am trying to draw a string in the center of the page. The below code is working for almost all the file. for the specific file attached its not positioning the graphics object correctly. Its drawing the string somewhere. Any help would be appreciated.
The below is the code snippet:
====================
Code:
XFont font = new XFont(fontFamilyName, FontSize, XFontStyleEx.Regular); //"Times New Roman" ,22 is fontsize
PdfDocument doc = PdfReader.Open(sourceFileName, PdfDocumentOpenMode.Modify);
XBrush brush = new XSolidBrush(XColor.FromArgb(128, 127, 127, 127)); //50%
foreach (PdfPage page in doc.Pages)
{
using (XGraphics graphics = XGraphics.FromPdfPage(page, XGraphicsPdfPageOptions.Append))
{
double dwPageWidthInPoints = mediabox.Width;
double dwpageHeightInPoints = mediabox.Height;
// Convert dimensions to inches
double dwpageWidthInInches = dwPageWidthInPoints / 72;
double dwpageHeightInInches = dwpageHeightInPoints / 72;
double centerX = dwPageWidthInPoints / 2;
double centerY = dwpageHeightInPoints / 2;
graphics.DrawString("CONFIDENTIAL",, font, brush, new XPoint(centerX, centerY));
}