You can use the iTextSharp library to generate a PDF and the PrintDocument class from System.Drawing.Printing to print it. Here's an example:
main.cs
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.Drawing.Printing;
// create a PDF document using iTextSharpvar document = new Document();
var writer = PdfWriter.GetInstance(document, new FileStream("myPdf.pdf", FileMode.Create));
document.Open();
document.Add(new Paragraph("Hello, world!"));
document.Close();
// create a PrintDocument and specify the printer namevar printDoc = new PrintDocument();
printDoc.PrinterSettings.PrinterName = "Adobe PDF";
// handle the PrintPage event and draw the PDF onto the pageprintDoc.PrintPage += (sender, args) =>
{
var pdfReader = new PdfReader("myPdf.pdf");
var pdfPage = pdfReader.GetPageN(1);
var pdfSize = pdfReader.GetPageSizeWithRotation(1);
args.Graphics.DrawImage(pdfPage, args.MarginBounds);
};
// print the documentprintDoc.Print();