@pravin_bindage
PDF sharp is available in Windows Compatibility Try the below equivalent code

using System;
using System.IO;
using PdfSharp.Drawing;
using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;
namespace PdfManipulate
{
class PdfImageAdder
{
static void Main(string[] args)
{
if (args.Length != 4)
{
Console.WriteLine("Usage: PdfImageAdder <inputFilePath> <outputFilePath> <imagePath> <text>");
return;
}
string inputFilePath = args[0]; // Existing file
string outputFilePath = args[1]; // New file
string imagePath = args[2]; // Image to be added
string text = args[3]; // Text to be added
using (PdfDocument pdfDocument = PdfReader.Open(inputFilePath, PdfDocumentOpenMode.Modify))
{
//Image to be added in existing pdf file.
using (XImage image = XImage.FromFile(imagePath))
{
image.Interpolate = false;
// Font for text
XFont font = new XFont("Helvetica", 12, XFontStyle.Regular);
XFont font1 = new XFont("Helvetica", 8, XFontStyle.Regular);
// Date to be added in existing pdf file
DateTime date = DateTime.Now;
string formattedDate = date.ToString("dd MMM yyyy");
if (pdfDocument.PageCount > 3)
{
pdfDocument.Pages.RemoveAt(3);
}
// loop on all the PDF pages
for (int i = 0; i < pdfDocument.PageCount; i++)
{
PdfPage page = pdfDocument.Pages[i];
using (XGraphics gfx = XGraphics.FromPdfPage(page))
{
if (i == 0)
{
// add image
gfx.DrawImage(image, 130, 35, 70, 50); //Set position and size for image in PDF
// add text
gfx.DrawString(text, font, XBrushes.Black, new XRect(80, 40, page.Width, page.Height), XStringFormats.TopLeft);
// add date
gfx.DrawString(formattedDate, font1, XBrushes.Black, new XRect(60, 60, page.Width, page.Height), XStringFormats.TopLeft);
}
else
{
// add image
gfx.DrawImage(image, 230, 35, 70, 50); //Set position and size for image in PDF
// add text
gfx.DrawString(text, font, XBrushes.Black, new XRect(90, 36, page.Width, page.Height), XStringFormats.TopLeft);
// add date
gfx.DrawString(formattedDate, font1, XBrushes.Black, new XRect(65, 67, page.Width, page.Height), XStringFormats.TopLeft);
}
Console.WriteLine("Image, Date and Text added in page " + (i + 1) + " of " + outputFilePath);
}
}
}
pdfDocument.Save(outputFilePath);
Console.WriteLine("Modified PDF created in >> " + outputFilePath);
}
}
}
}
I did not compile fully…Should be good…check once
cheers