I wonder if it is possible to add a curved text into last page of an existing pdf file or add an image and set a text over it.
Thanks in advanced
PdfDocument doc = new PdfDocument("sample.pdf");
PdfPageBase page = doc.Pages[0];
Image image = Image.FromFile(@"F:\image\image1.jpg");
PdfImage pdfimage = PdfImage.FromImage(image);
float x = 5;
float y = 10;
//draw image
page.Canvas.DrawImage(pdfimage, x, y);
PdfUnitConvertor uinit = new PdfUnitConvertor();
//get the image size in point
SizeF NewSize = uinit.ConvertFromPixels(image.Size, PdfGraphicsUnit.Point);
System.Drawing.Font font = new System.Drawing.Font("Calibri", 18, FontStyle.Regular);
PdfTrueTypeFont ttf = new PdfTrueTypeFont(font, true);
PdfSolidBrush brush = new PdfSolidBrush(Color.Black);
string text = "text";
Graphics g = Graphics.FromImage(new Bitmap(1, 1));
g.PageUnit = GraphicsUnit.Point;
//measure the text and get its size in point
SizeF sim = g.MeasureString(text, font);
page.Canvas.DrawString(text, ttf, brush, x + (NewSize.Width - sim.Width) / 2, y + (NewSize.Height - sim.Height) / 2);
doc.SaveToFile("14313.pdf");
PdfDocument doc = new PdfDocument();
PdfPageBase page = doc.Pages.Add();
string s = "test test test";
var brush = new PdfSolidBrush(Color.Black);
var font = new Font("Arial", 20);
PdfTrueTypeFont tfont = new PdfTrueTypeFont(font, true);
var origin = new Point(200, 200);
int radius = 50;
var format = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
page.Canvas.TranslateTransform(origin.X, origin.Y);
//you might need to change the arithmetic to draw your text
foreach (var c in s)
{
page.Canvas.RotateTransform(170f / s.Length);
page.Canvas.DrawString(c.ToString(), tfont, brush, new PointF(0, -radius), format);
}
doc.PageSettings.Rotate = PdfPageRotateAngle.RotateAngle270;
doc.SaveToFile("CurvedText14313.pdf");