Convert PDF to SWF in ASP.NET
I always wanted to guarantee that users of my application can view my published documents even if they don't have the needed application installed on their machines. To achieve this requirement and MACROMEDIA FLASH being installed on almost every browser, i got to either build a tool to convert my PDF files to flash files or to use a free tool. I came across an excellent and effective tool called SWFTOOLS. The beauty of this tool is that it can convert not just all the pdf file to swf file but it can convert a specific page also. In this way, i reduce the time needed to convert all the file and make it on demand. This tool can run using shell commands and using ASP.NET we can execute this process by using the System.Diagnostics.Process class.
When you install this tool on your local machine, copy the "font" and the PDF2SWF.exe file into a folder in your application root folder "PDF2SWF" and use the below code
int pageNumber = 1;
string fileName = "Files/1.pdf";
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.WorkingDirectory = HttpContext.Current.Server.MapPath("~");
p.StartInfo.FileName = HttpContext.Current.Server.MapPath("~/PDF2SWF/PDF2SWF.exe");
p.StartInfo.Arguments = "-F " + "\"" +HttpContext.Current.Server.MapPath("~/PDF2SWF/FONTS") + "\"" + " -p " + pageNumber + " " + fileName + " -o " + fileName + pageNumber + ".swf";
//Start the process
The above code will create an instance of the Process class, Set the working directory to the root application folder, set the filename to the exe file and send arguments to the process. you can check the tool's website to know more about the arguments list.
Now after the above code will finish executing, a new file called 11.swf will be saved in the folder which will you can use to display it in your webform.
Hope this helps,