Click here to Skip to main content
15,911,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can i print pdf created to folder with itextSharp.

process steps

1.Pdf created in folder.
2. The created pdf is taken from the corresponding folder and printed. //couldn't do this line


But I couldn't make my 2nd step.
How can I print itextsharp pdf I created.

What I have tried:

using (FileStream fs = new FileStream(@"C:\Example.Pdf", FileMode.Create,
                    FileAccess.Write, FileShare.None))
{

//this line create pdf.

Print();

}

//This print method does not work.

        private static void Print()
        {
            Process process = new Process();
            process.StartInfo.FileName = "C:\\Example.Pdf";

            process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            process.StartInfo.Arguments = string.Format("C:\\Example.Pdf");
            process.Start();
            process.WaitForExit();
        }
Posted
Updated 6-Feb-20 9:05am
v2
Comments
Richard MacCutchan 18-Aug-19 3:08am    
You need to tell he process to print the file. What you have is just the filename.
[no name] 18-Aug-19 10:50am    
This code is done but I take error.This error is :An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in System.dll

private Print()
{
string path = "‪C:\\PdfFile.Pdf";
Process p = new Process();
p.StartInfo = new ProcessStartInfo()
{
CreateNoWindow = true,
Verb = "print",
FileName = path
};
p.Start(); //this line is error message
}

 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900