Partners Contact US Site Map Blog
A professional PDF Converter, PDF Writer, PDF Creator, PDF Editor, HTML Converter, Postscript Converter, AutoCAD DWG Converter, as well as PCL Converter, etc.  

Call PDF to Flash Converter Command Line from C#, ASP, etc. web program languages

 
1. How to call PDF to Flash Command Line (pdftoflash.exe) from C#, ASP, PHP, etc. web program languages?
A:

Example #1 (C# example),

Make use of the PROCESS class available in SYSTEM.DIOGNOSTICS namaspace, use the following piece of code to execute the pdftoflash.exe file,
~~~~~~~~~~~~~~~~~
using System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Diagnostics
;

namespace ConsoleApplication1
{

    class
Program
    {
       
static void Main(string[] args)
        {
                Process proc = new Process
();
                proc.StartInfo.FileName = @"C:\\pdftoflash.exe"
;
               
string strArguments = "";
                strArguments += " D:\\temp\\sample.pdf D:\\temp\\out.swf";

                Console.WriteLine(strArguments
);
                proc.StartInfo.Arguments = @strArguments
;
                proc.Start
();
                proc.WaitForExit
();
        }
    }
}
~~~~~~~~~~~~~~~~~

Example #2 (C# example),

Please by following steps to call pdftoflash.exe inside a special user account,

1. Please download and install EXEShell COM Library (freeware) from following URL first,

http://www.verydoc.com/exeshell.html
http://www.verydoc.com/download/exeshell.zip

2. Please use following C# code to run the conversion inside a special user account,

~~~~~~~~~~~~~~~~~
using System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;

namespace
ConsoleApplication1
{
    class
Program
    {
       
static void Main(string[] args)
        {
                System.Type otype = System.Type.GetTypeFromProgID("exeshell.shell");
                Object o = System.Activator.CreateInstance(otype);
                otype.InvokeMember("RunCommandLine", System.Reflection.BindingFlags.InvokeMethod, null, o, new object[] { "UserName", "Password", @"C:\pdftoflash.exe ""C:\test.pdf"" ""C:\out.swf""" });
                otype = null;
        }
    }
}
~~~~~~~~~~~~~~~~~

Remark:
You may encounter Error 1314 in some Windows systems when you switch between user accounts, this is caused by permission setting, please by following steps to solve this 1314 Error,

ERROR 1314:
~~~~~~~~~~~~~
1314 A required privilege is not held by the client. ERROR_PRIVILEGE_NOT_HELD
~~~~~~~~~~~~~

To resolve this issue:
1. Click Start, click Run, type "secpol.msc", and then press ENTER.
2. Double-click "Local Policies".
3. Double-click "User Rights Assignment".
4. Double-click "Replace a process level token".
5. Click "Add", and then double-click the "Everyone" group
6. Click "OK".
7. You may have to logout or even reboot to have this change take effect.

Please refer to following two screenshots to understand above steps,

http://www.verydoc.com/images/err1314-1.png
http://www.verydoc.com/images/err1314-2.png

Please look at following page for the details about ERROR 1314,

http://www.verydoc.com/exeshell.html

Example #3 (ASP example),

Please by following steps to call pdftoflash.exe inside a special user account,

1. Please download and install EXEShell COM Library (freeware) from following URL first,

http://www.verydoc.com/exeshell.html
http://www.verydoc.com/download/exeshell.zip

2. Please use following ASP code to run the conversion inside a special user account,

~~~~~~~~~~~~~~~~~
<%
    Set comEXEShell = Server.CreateObject("exeshell.shell")
    RootPath = Server.MapPath(".") & "\"
    EXEFile = RootPath & "test\pdftoflash.exe"
    InFile = RootPath & "test.pdf"
    OutFile = RootPath & "out.swf"
    strCommandLine = EXEFile & " " & InFile & " " & OutFile
    response.write strCommandLine & "<br>"
    comEXEShell.RunCommandLine "UserName", "Password", strCommandLine
    Set comEXEShell = Nothing
%>
~~~~~~~~~~~~~~~~~

Remark:
You may encounter Error 1314 in some Windows systems when you switch between user accounts, this is caused by permission setting, please refer to the steps in #2 to solve the 1314 Error.

Example #4 (VB.NET example),

System.Diagnostics.Process.Start("C:\pdftoflash.exe C:\test.pdf C:\out.swf")

Example #5 (C# example),

Please by following steps to call pdftoflash.exe inside a special user account,

1. Please download and install EXEShell COM Library (freeware) from following URL first,

http://www.verydoc.com/exeshell.html
http://www.verydoc.com/download/exeshell.zip

2. Please use following C# code to run the conversion inside a special user account,

~~~~~~~~~~~~~~~~~
using System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
EXESHELLLib;

namespace ConsoleApplication1
{

    class
Program
    {
       
static void Main(string[] args)
        {
                EXESHELLLib.shell EXEShell = new EXESHELLLib.shellClass
();
                EXEShell.RunCommandLine("
UserName", "Password", @"C:\pdftoflash.exe ""C:\test.pdf"" ""C:\out.swf""");
                EXEShell = null
;
        }
    }
}
~~~~~~~~~~~~~~~~~

Remark:
You may encounter Error 1314 in some Windows systems when you switch between user accounts, this is caused by permission setting, please refer to the steps in #2 to solve the 1314 Error.

Example #6 (PHP example),

<?php
    $exeshell =new COM("exeshell.shell") or die("Can't start exeshell");
    $exeshell->
RunCommandLine("UserName", "Password", ' "C:\pdftoflash.exe" "C:\test.pdf" "C:\out.swf" ');
    $exeshell = null;
?>

Example #7 (VBScript example),

Set fso = CreateObject("Scripting.FileSystemObject")
strFolder = fso.GetParentFolderName(wscript.ScriptFullName)

strEXEFile = strFolder & "\pdftoflash.exe"
strInFile = strFolder & "\test.pdf"
strOutFile = strFolder & "\test.swf"
strCmd = strEXEFile & " " & strInFile & " " & strOutFile

Dim objShell
Set objShell = CreateObject("WScript.Shell")
objShell.Run strCmd

Example #8 (Run conversion inside an interactive user account from service or web applications),

Please by following solution to run PDF to Flash conversion inside an interactive user account,

1. Please add "Everyone" user account to the folder of pdftoflash.exe, give "Full Control" permission to "Everyone" user account,

2. Download CmdAsUser.exe from following page,

http://www.verydoc.com/exeshell.html

You can also download it from following URL directly,

http://www.verydoc.com/download/cmdasuser.zip

3. Run following command line to test CmdAsUser.exe application,

C:\test\CmdAsUser.exe Administrator . /p password /c C:\test\pdftoflash.exe C:\test\test.pdf C:\test\out.swf

If you can run above command line in Command Line Window correctly, please call above command line from PHP by shell_exec() function or other web applications, then you will get it work properly.

Please notice, you need modify "Administrator" and "password" parameters in above command line, CmdAsUser.exe will launch pdftoflash.exe from an interactive user account with administrator privilege.

Example #9 (Run conversion by docPrint Service)

docPrint Service can be used to run a Command Line from current active user account or a special user account, this tool is useful to overcome permission restrictions in SYSTEM and Non-Interactive user accounts.

Please by following steps to use docPrint Service,
1. Download docPrint_Service.zip and unzip it to a folder,
2. Run docPrint_Service.exe application, you will see an icon appear in tray area,
3. You can run following command lines to test it first, "docPrint_client.exe" will deliver the Command Line to docPrint_Service.exe application, docPrint_Service.exe application will execute the Command Line from active user account automatically,

docPrint_client.exe nowait "C:\VeryDOC\pdftoflash.exe" C:\test.pdf C:\out.swf
docPrint_client.exe wait "C:\VeryDOC\pdftoflash.exe" C:\test.pdf C:\out.swf

4. You can call "docPrint_client.exe" from your code, please refer to a simple C# code at below,

public partial class runexe : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Process proc = new Process();
        proc.StartInfo.FileName = "C:\\VeryDOC\\docPrint_client.exe";
        string strArguments = "wait C:\\VeryDOC\\pdftoflash.exe C:\\test.pdf C:\\test.swf";
        Console.WriteLine(strArguments);
        proc.StartInfo.Arguments = @strArguments;
        proc.Start();
        proc.WaitForExit();
        Response.Write("File has been successfully converted");
    }
}

 

Home | Site Map | VeryPDF.com | VeryPCL.com | Contact | Blog
Copyright © 2002- VeryDOC.com Company. All Rights Reserved.