Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
1.33/5 (2 votes)
See more:
Hi Friends,

Please tell me any free dll or any code to convert xps file to pdf file.

code:
C#
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;
      }


giving error that cmd execution is blocked by admin.
any alternate solution is helpful.
Posted

try with

info.Verb = "runas";
 
Share this answer
 
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..
 
Share this answer
 
v2
Comments
Clifford Nelson 18-Apr-13 22:57pm    
Wrong direction.

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