I am trying to learn, if it's possible to create an application in C# which needs to meet requirements:
- Can load a template PDF file, and draw some text on top of it (positioned by pixels for example)
- Save this file in a specific directory
- And most important... Application should be able to print such PDF file. And i don't mean print it on the screen, i mean 'silently' send on the printer.
I've heard, that two first points can be accomplished by iTextSharp/iTextPdf. But does it allow me to simply send this file to the printer? I was looking for a solution for a while now.
User should pick default printer once in options, and all he should do is click "print" after generating such PDF file. I would love the solution that doesn't open Adobe Reader in the background.
Are there maybe some alternatives?
I know its possible to send images to printer like that, without running any other program in the background. But I need it to work for PDFs.
private void SendToPrinter(string path)
{
PrinterSettings defaultprinter = new PrinterSettings();
PrintDocument pd = new PrintDocument();
pd.PrinterSettings.PrinterName = defaultprinter.PrinterName;
pd.PrintPage += (sender, e) => PrintPage(e, path);
pd.Print();
}
private void PrintPage(PrintPageEventArgs e, string path)
{
Bitmap bitma = new Bitmap(776, 538, PixelFormat.Format32bppArgb);
System.Drawing.Image dest = bitma;
Graphics graph = Graphics.FromImage(dest);
graph.Clear(Color.FromArgb(255, 255, 255));
Bitmap z = new Bitmap(path);
System.Drawing.Image img = z;
graph.DrawImage(img, new System.Drawing.Point(120, 350));
e.Graphics.DrawImage(dest, new System.Drawing.Point(0, 0));
}
PS. Yes, I've tried searching. Google, stackoverflow, seen even few similar questions, but didn't find one answering all my questions.