Here I have code that opens Adobe and causes it to print a PDF file using Process.Start(). I am trying to print multiple files (two different pdfs) using the same command. How would I go about this? This is what I have so far:
Process profilePrintProcess = new Process();
profilePrintProcess.EnableRaisingEvents = true;
profilePrintProcess.StartInfo = new ProcessStartInfo()
{
CreateNoWindow = true,
Verb = "PrintTo",
FileName = "[" + profFileName + " " + contractFileName + "]",
WindowStyle = ProcessWindowStyle.Hidden,
};
profilePrintProcess.Start();
I've been using this link as a guide per another SO question that referenced a similar issue.
to print a single file trough Acrobat Reader try this and let me know if worked:
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "AcroRd32.exe";
startInfo.Arguments = "/p " + YourPDFFilePath;
process.StartInfo = startInfo;
process.Start();
to printig multipile pdf files first combine them and next print combined document trough PDFSharp
var outputPDFDocument = PdfDocument.Combine("Output.pdf", "doc1.pdf", "doc2.pdf", "doc3.pdf");
outputPDFDocument.Save("C:\\temp.pdf");
PdfFilePrinter.AdobeReaderPath = #"C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe";
PdfFilePrinter.DefaultPrinterName = "Take printer";
PdfFilePrinter printer = new PdfFilePrinter(#"C:\\temp.pdf");
printer.Print();
Related
This code below is printing a copy of a 'PDF' file and I'm having trouble making it to print 2 copies of it, not just one can anyone help?
string Filepath = path+ #"\Output.pdf";
Process p = new Process();
p.StartInfo = new ProcessStartInfo()
{
CreateNoWindow = true,
Verb = "print",
FileName = Filepath //put the correct path here
};
p.Start();
p.Start();
I'm working on sending documents to a specific printer, in this case the "Microsoft to PDF" one.
Everything work fine except that a prompt comes up asking for the folder where to save the pdf and its name.
Process printJob = new Process();
printJob.StartInfo.FileName = pathToFile;
printJob.StartInfo.UseShellExecute = true;
printJob.StartInfo.Verb = "printto";
printJob.StartInfo.CreateNoWindow = true;
printJob.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
printJob.StartInfo.Arguments = "\"" + pdfPrinter + "\"";
printJob.StartInfo.WorkingDirectory = Path.GetDirectoryName(destinationPath);
printJob.Start();
Is there a way to pass any paramenter to printJob.StartInfo.Arguments such destination path and filename and avoid the prompt?
So I have the following code:
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized;
startInfo.FileName = "CMD.exe";
string[] serverNameParts = ServerName.Split('.');
string CN1 = t1.Text, CN2 = "Users";
string pwd = t2.Text;
startInfo.Arguments = "/c dsadd user " + "CN=" + CN1 + ",CN=" + CN2 +",";
for (int i = 0; i < serverNameParts.Length; i++)
{
startInfo.Arguments = startInfo.Arguments + "DC=" + serverNameParts[i] + ",";
}
startInfo.Arguments = startInfo.Arguments + " & ping www.google.com /t";
process.StartInfo = startInfo;
process.Start();
I used ping so I could see why it won't create an account.
What I get is this error:
Error code = 0x80005000
type dsadd /? for help.
I can't figure out what could be the problem here, I checked the final string and it looks totally fine and I even typed it into the promt and everything worked perfectly, but it won't when I use it in my app. Is there any way to solve this? I suppose it has something to do with the permissions, but I can't come up with an idea to give my program the rights to run an administrator cmd.
When I run my code I get the command line window popping up and it looks like it executes, but I never have an image created. I'm using the rasterize.js that came with PhantomJS
I have a number of websites I need to get a screen shot of and have stored them in a List<>.
I can't seem to narrow down just what is preventing me from having an image created. Any help would be greatly appreciated, and if there's any information that is missing or if anything needs to be clarified please let me know.
Here's my code:
foreach (var item in itemList)
{
string outPath = OUTPUTPATH + "\\" + item.foldername;
System.IO.Directory.CreateDirectory(outPath);
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "phantomjs.exe";
startInfo.WorkingDirectory = #"C:\phantomjs-1.9.7-windows\";
startInfo.WindowStyle = ProcessWindowStyle.Normal;
startInfo.CreateNoWindow = true;
startInfo.Arguments = "/C .\\examples\\rasterize.js " + item.url + " " + outPath + "\\" + item.filename+".jpg;
using (Process process = Process.Start(startInfo))
{
process.WaitForExit();
}
}
I'm making Visual Studio package where i start devenv.exe and try to build other solution.I need to get building output in realtime, so user can see buiding progress(output), but i don't know how to do it and if it's even possible.
I tried such way :
string rebuildLog = string.Empty;
string logFileName = System.IO.Path.GetTempFileName();
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo();
psi.FileName = #"devenv.exe";
psi.Arguments = "\"" + config.DmsPath + "\"" + #" /rebuild" + " Release|x64 " +" /out " + logFileName;
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo = psi;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.UseShellExecute = false;
process.Start();
while (!process.StandardOutput.EndOfStream)
{
string line = process.StandardOutput.ReadLine();
MessageBox.Show(line); // just to see if it works. It should go to log form
}
rebuildLog = GetRebuildLog(logFileName);
And rebuildLog has output.
Can anybody help ?
I found answer.
devenv.exe doesn't write simple console output, so i had to change
psi.FileName = #"devenv.exe"; to psi.FileName = #"devenv.com"; and it worked.