Folks!
So, I'm attempting to convert a PDF to a .png, as the title implies. I'm using the software package ImageMagick. I want to use this package to convert pdfs to pngs on-the-fly from a Unity 3d project -- so that the application can display the PDFs as .png textures in-game when it needs, but still preserves them as PDFs for smaller file sizes. I'm not quite sure what I've done wrong, here -- but when I run it in Unity, all I get is an open cmd prompt without my command in it. Is there something obvious that I'm missing, here? Here's the code:
using UnityEngine; using System.Collections; using System.IO; using System.Reflection; using System.Security.Policy; public class CommandLineTest : MonoBehaviour { // Use this for initialization void Start () { string convertedDirName = "ConvertedPDFs"; string currDir = System.Environment.CurrentDirectory; System.IO.Directory.CreateDirectory(currDir + @"\" + convertedDirName); string strCmdText; strCmdText= @"/c " + currDir + @"\ImageMagick\convert.exe " + currDir + @"\PDFs\Appointment.pdf " + currDir + @"\" + convertedDirName + @"\" + "Appointment.png"; System.Diagnostics.Process.Start("CMD.exe",strCmdText); //ImageMagick print(strCmdText); } } When the print statement at the end runs, it prints the following string: c/ convert /c F:\Documents and Settings\Administrator\Desktop\ImageMagickTest\ImageMagick\convert.exe F:\Documents and Settings\Administrator\Desktop\ImageMagickTest\PDFs\Appointment.pdf F:\Documents and Settings\Administrator\Desktop\ImageMagickTest\ConvertedPDFs\Appointment.png
Does anything appear obviously wrong, to you? I should mention that ImageMagick's convert application is not actually "installed" on my system -- I'm just using the "portable" version and have thrown it in my project folder. So I was hoping that the "convert" command line would still work. Does this mean that I can't access it with a dos prompt? If I can't, then how do I pass an image to the "convert" program in imagemagick using, provided I know that it's going to be in my project's folder?
EDIT: Some people have suggested that I access convert.exe instead of cmd.exe, and to attempt to just feed the image paths to it that way. So here is the second way I'm trying it:
strCmdText= currDir + @"\PDFs\Appointment.pdf" + " " + currDir + @"\" + convertedDirName + @"\" + "Appointment.png"; System.Diagnostics.Process.Start(currDir + @"\ImageMagick\convert.exe",strCmdText);