List Info

Thread: Printing PDF directly from server...




Printing PDF directly from server...
country flaguser name
United States
2007-02-28 15:11:44
I am using Process.Start() and pdfp.exe to launch Adobe
Reader to
print PDFs directly from the server.  My website's
Application Pool
runs under a domain account and I am having trouble getting
the
permissions right.  It works when I add the domain account
to the web
server's administrators group, but this isn't something I
want to do
in production.  Any ideas on how to give the domain account
the
correct permissions without adding it to the Admins group? 
TIA ~
Matt ... Code follows...

public static void PrintPdfForm(System.Type builderType,
string
inPath,
			string outDir, DataSet formData, string printer) {

			string outPath = outDir + Guid.NewGuid().ToString() +
".pdf";
			IPdfFormBuilder builder;
			try {
				builder = Activator.CreateInstance(builderType) as
IPdfFormBuilder;
				builder.BuildForm(inPath, outPath, formData);
				string pdfpPath =
Mcrcsip.Amwa.PdfFormHandler.Properties.Settings.Default.Pdfp
Path;
				string args = "-p "" + printer +
"" " + outPath;
				RunExecutable(pdfpPath, args);
			} catch (Exception ex) {
				throw PdfFormException.GetException(
					"Caught exception in
Mcrcsip.Amwa.PdfFormHandler.PrintPdfForm().", ex);
			} finally {
				if (System.IO.File.Exists(outPath)) {
					try {
						System.IO.File.Delete(outPath);
					} catch (System.IO.IOException) {
					}
				}
			}
		}

		private static void RunExecutable(string executable,
string
arguments) {
			ProcessStartInfo starter = new
ProcessStartInfo(executable,
arguments);
			starter.CreateNoWindow = true;
			starter.RedirectStandardOutput = true;
			starter.UseShellExecute = false;
			Process process = new Process();
			process.StartInfo = starter;
			process.Start();
			StringBuilder buffer = new StringBuilder();
			using (StreamReader reader = process.StandardOutput) {
				string line = reader.ReadLine();
				while (line != null) {
					buffer.Append(line);
					buffer.Append(Environment.NewLine);
					line = reader.ReadLine();
					Thread.Sleep(100);
				}
			}
		}


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "DotNetDevelopment, VB.NET, C# .NET,
ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting"
group.
To post to this group, send email to DotNetDevelopmentgooglegroups.com
To unsubscribe from this group, send email to
DotNetDevelopment-unsubscribegooglegroups.com
For more options, visit this group at
http:
//cm.megasolutions.net/forums/default.aspx
-~----------~----~----~----~------~----~------~--~---


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )