Hello,
I would need some advice please. My situation is the following:
I have a zip-folder with PDF files in it. I go over all the PDFs in the zip folder and print each one.
Is this possible with the native Visual Studio and what it has to offer? Or do I essentially need a tool such as iTextPDF or PDFSharp?
I have been researching for so many hours and I cannot find a solution.
My main problem is, that I cannot find a way to connect my PDF-document I would like to print with the PrintDocument object. I cannot give a path to the document to the PrintDocument. It does not have an attribute either for passing on the path of where your document is located.
So how do I tell it which document to print?
So when I show my print preview, it is all blank. Is this because I cannot natively print PDF from a console application? Or is it possible somehow?
I would appreciate some help very much.
Thank you in advance!
Lila
Some excerpt of my C# code, which I am using within a console application:
PrintDialog pDialog = new PrintDialog();
PrintDocument printDoc = new PrintDocument();
printDoc.DocumentName = ("Print Document");
if (pDialog.ShowDialog() == DialogResult.OK)
{
printDoc.PrinterSettings = pDialog.PrinterSettings;
pDialog.Document = printDoc;
var settingsValid = printDoc.PrinterSettings.IsValid;
}
if (settingsValid)
{
PrintPreviewDialog p = new PrintPreviewDialog();
p.Document = printDoc;
try
{
var r = p.ShowDialog();
printDoc.Print();
}
I would need some advice please. My situation is the following:
I have a zip-folder with PDF files in it. I go over all the PDFs in the zip folder and print each one.
Is this possible with the native Visual Studio and what it has to offer? Or do I essentially need a tool such as iTextPDF or PDFSharp?
I have been researching for so many hours and I cannot find a solution.
My main problem is, that I cannot find a way to connect my PDF-document I would like to print with the PrintDocument object. I cannot give a path to the document to the PrintDocument. It does not have an attribute either for passing on the path of where your document is located.
So how do I tell it which document to print?
So when I show my print preview, it is all blank. Is this because I cannot natively print PDF from a console application? Or is it possible somehow?
I would appreciate some help very much.
Thank you in advance!
Lila
Some excerpt of my C# code, which I am using within a console application:
PrintDialog pDialog = new PrintDialog();
PrintDocument printDoc = new PrintDocument();
printDoc.DocumentName = ("Print Document");
if (pDialog.ShowDialog() == DialogResult.OK)
{
printDoc.PrinterSettings = pDialog.PrinterSettings;
pDialog.Document = printDoc;
var settingsValid = printDoc.PrinterSettings.IsValid;
}
if (settingsValid)
{
PrintPreviewDialog p = new PrintPreviewDialog();
p.Document = printDoc;
try
{
var r = p.ShowDialog();
printDoc.Print();
}