在c#中将xps文件转换为pdf [英] convert xps file to pdf in c#
本文介绍了在c#中将xps文件转换为pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨朋友们,
请告诉我任何免费的DLL或任何将xps文件转换为pdf文件的代码。
代码:
Hi Friends,
Please tell me any free dll or any code to convert xps file to pdf file.
code:
private static string CreatePdf(string fileName,string filen)
{
string command = "gswin32c -q -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=\"" + fileName + ".pdf\" -fc:\\output.ps";
Console.WriteLine(command);
Process p = new Process();
StreamWriter sw;
StreamReader sr;
ProcessStartInfo info = new ProcessStartInfo("cmd");
info.WorkingDirectory = System.AppDomain.CurrentDomain.BaseDirectory;
Console.WriteLine("Current directory: " + info.WorkingDirectory);
info.CreateNoWindow = true;
info.UseShellExecute = false;
info.RedirectStandardInput = true;
info.RedirectStandardOutput = true;
p.StartInfo = info;
p.Start();
sw = p.StandardInput;
sr = p.StandardOutput;
sw.AutoFlush = true;
sw.WriteLine(command);
sw.Close();
string ret = sr.ReadToEnd();
Console.WriteLine(ret);
return ret;
}
给出管理员阻止cmd执行的错误。
任何替代解决方案都有帮助。
giving error that cmd execution is blocked by admin.
any alternate solution is helpful.
推荐答案
尝试使用
try with
info.Verb = "runas";
查看此链接
http://www.micre13b.com/xps-to-pdf-converter.html#download [ ^ ]
它有免费的exe转换
但我还要检查一些代码..
http://go4answers.webhost4life.com/Example/convert -xps-documents-other-formats-30221.aspx [ ^ ]
尝试此链接也..他们有代码转换为bmp文件。可能你会想到转换为pdf ..
Check out this link
http://www.micre13b.com/xps-to-pdf-converter.html#download[^]
It's having free exe to convert
But i m also checking for some code..
http://go4answers.webhost4life.com/Example/convert-xps-documents-other-formats-30221.aspx[^]
try this link also..they have code for converting to bmp file.may be u will get idea to convert in pdf..
这篇关于在c#中将xps文件转换为pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文