FlashPaper is an electronic document tool launched by Macromedia! By using FlashPaper, you can convert a document to a Flash animation in SWF format through simple settings. The layout style and font display of the original document will not be affected, the advantage of this is that no matter what the platform or language version of the other party is, you can freely watch the electronic document animation you have made, and freely zoom in, zoom out, and print it, page turning and other operations!
The display effect is like viewing the effect of Baidu's library.
I believe most people know how to use Flashpaper. The Demo here is a flash file used to convert. doc files to. swf files online.
The principle is to convert files through process commands, so process operations are involved,
The command for converting doc to swf is:
"Flashpaper execution file path. DOC file path-o output .swf file path"
The Code is as follows:
Copy codeThe Code is as follows: // <summary>
/// Execution Process
/// </Summary>
/// <Param name = "sourceFileName"> enter the. DOC file path </param>
/// <Param name = "outPutFileName"> output .swf file path </param>
Public void ProcessExec (string sourceFileName, string outPutFileName)
{
// You can set the installation path of the FlashPaper file.
String flashPrinter = "F :\\ FlashPaper2.2 \ FlashPrinter.exe ";
Process pss = new Process ();
Pss. StartInfo. CreateNoWindow = false;
Pss. StartInfo. FileName = flashPrinter;
Pss. StartInfo. Arguments = string. Format ("{0} {1}-o {2}", flashPrinter, sourceFileName, outPutFileName );
Try
{
Pss. Start ();
While (! Pss. HasExited)
{
Continue;
}
System. Threading. Thread. Sleep (4000 );
Response. Write ("Succefull! ");
}
Catch (Exception ex)
{
Throw ex;
}
}
Protected void btnText_Click (object o, EventArgs e)
{
String source = Server. MapPath ("~ /Files/Doc.doc ");
String output = Server. MapPath ("~ /Files/doc.swf ");
ProcessExec (source, output );
}
The FlashPaper file is in the FlashPaper folder in the Demo,
The installation method is very simple. Copy the Flashpaper folder to the "to be installed" folder, and click the initialization. bat file in the initialization folder to perform the installation (no virus, huh, you can install it with confidence ).
Download Demo: Click to download
In the Server 2003 system, execution may fail. This is because IIS imposes restrictions on Office file operation permissions. For solutions, see:
IIS permission configuration for ASP. NET Word operations
By default, ASP. NET accounts do not have the permission to operate Microsoft Office objects. If you do not configure permissions, the code will throw an exception similar to the following:
Failed to retrieve components whose CLSID is {00024500-0000-0000-C000-000000000046} in the COM class factory because of the following error: 80070005.
This makes it difficult for Asp. NET to operate Microsoft Office objects. However, we still need to find a way to operate Office objects. The following describes the methods I have used in the development process:
Method 1: configure the Web. Config file to simulate the account of the local system during each request.
Specific Operation: Add the following nodes to the Web. Config file:
<Identity impersonate = "true" userName = "accountname" password = "password"/>
Here, userName is the local account to be simulated, and password is the password of this account.
Method 2: In "DCOM configuration", configure the Word operation permission for the IIS account (the same for other Office objects.
Specific operations: "Component Service"-> Computer-> My Computer-> DCOM Config) -> Microsoft Office Word 97-2003 documents, right-click "Microsoft Office Word 97-2003 documents", and select "properties" for two steps:
(1) On The Identity tab, select The interactive user )".
(2) On the Security tab, select "customer" for the first two groups (START and activate permissions and access permissions )", click "edit". On the displayed page, add an IIS account (the Server version of the operating system is generally network services, and other systems (XP) may be ASP. and assign all permissions to the user in the following permission box.
Method 3: assign a local account to the ASP. NET Site application pool
Specific Operation: in IIS, It is ASP. )".
In IIS7.0, follow these steps: Create a new application pool for the ASP. NET site. Select the application pool, advanced settings, process mode, and identity. Select localSystem.
Among the above three methods, I prefer the third method, because after the Word object is operated, the process of the Word object needs to be closed, and the third method can enable ASP without other settings.. NET applications have the permission to end the word process.