The following code snippet shows how to draw shapes including lines, circles, rectangles etc to PDF, it is based on a nuget package - Spire.PDF .
using System.Drawing;
using Spire.Pdf;
using Spire.Pdf.Graphics;
namespace DrawLines
{
class Program
{
static void Main(string[] args)
{
PdfDocument pdf = new PdfDocument();;
pdf.LoadFromFile("input.pdf");
PdfPageBase page = pdf.Pages[0];
PdfPath path = new PdfPath();
path.AddLine(new PointF(40, 50), new PointF(100, 50));
PdfPen pen = new PdfPen(Color.DeepSkyBlue, 0.02f);
page.Canvas.DrawPath(pen, path);
pdf.SaveToFile("Drawline.pdf");
}
}
}
Besides, there is a
free version of Spire.PDF which has a 10 pages limitation per pdf, but it's enough for your requirement (single page pdf).