Similar to Baidu pdf2swf + flexpaper, pdf2swfflexpaper solves the effect of online pdf reading.

Source: Internet
Author: User
Tags php example

Similar to Baidu pdf2swf + flexpaper, pdf2swfflexpaper solves the effect of online pdf reading.

1. Prepare the tool
Download swftools.exe
Http://www.swftools.org/download.html
Install to drive d
SWFTools provides a series of tools to convert various files into swf:
Font2swf.exe
Gif2swf.exe
Ipv2swf.exe
Ipv2swf.exe
Png2swf.exe
Wav2swf.exe
Here we only use ipv2swf.exe

Flexpaper download
Http://code.google.com/p/flexpaper/
Here we use the compiled FlexPaper flash version.

2: Example language. Here I use two development environments as an example.
Php example
Swf file generated by pdf

[Php]View plaincopyprint?
  1. <? Php
  2. /*
  3. * Created on 2010-11-17
  4. *
  5. * To change the template for this generated file go
  6. * Window-Preferences-PHPeclipse-PHP-Code Templates
  7. */
  8. // Obtain the directory of the object
  9. $ Dir = dirname (_ FILE __);
  10. // Delete the test file
  11. @ Unlink ($ dir. "\ test.swf ");
  12. // Use the export 2swf conversion command
  13. $ Command = "D:/SWFTools/ipv2swf.exe-t \"". $ dir. "\ testbench \"-o \"". $ dir. "\ test.swf \"-s flashversion = 9 ";
  14. // Create a shell object
  15. $ WshShell = new COM ("WScript. Shell ");
  16. // Execute the cmd command
  17. $ OExec = $ WshShell-> Run ("cmd/C". $ command, 0, true );
  18. ?>

Java example

 

 

[Java]View plaincopyprint?
  1. <%
  2. /*
  3. * Created on 2010-11-17
  4. */
  5. // Obtain the directory of the object
  6. String path = request. getRealPath ("/");
  7. // Use the export 2swf conversion command
  8. String command = "D: /SWFTools/ipv2swf.exe-t \ "" + path + "\ test1_\"-o \ "" + path + "\ test.swf \"-s flashversion = 9 ";
  9. // Execute the cmd command
  10. Runtime.getruntime(cmd.exe c ("cmd/c" + command );
  11. %>


The above is php, java converts pdf to swf, then it is displayed, so we will use flexpaper, the following is the use of flexpaper
Use flexpaper to display swf

 

 

[Javascript]View plaincopyprint?
  1. <Script type = "text/javascript" src = "js/swfobject. js"> </script>
  2. <Script type = "text/javascript">
  3. Var swfVersionStr = "10.0.0 ";
  4. Var xiSwfUrlStr = "playerProductInstall.swf ";
  5. Var flashvars = {
  6. SwfFile: escape ("test.swf "),
  7. Scale: 0.6,
  8. ZoomTransition: "easeOut ",
  9. ZoomTime: 0.5,
  10. ZoomInterval: 0.1,
  11. FitPageOnLoad: false,
  12. FitWidthOnLoad: true,
  13. PrintEnabled: true,
  14. FullScreenAsMaxWindow: false,
  15. ProgressiveLoading: true,
  16. PrintToolsVisible: true,
  17. ViewModeToolsVisible: true,
  18. ZoomToolsVisible: true,
  19. FullScreenVisible: true,
  20. NavToolsVisible: true,
  21. CursorToolsVisible: true,
  22. SearchToolsVisible: true,
  23. LocaleChain: "zh_CN"
  24. };
  25. Var params = {
  26. }
  27. Params. quality = "high ";
  28. Params. bgcolor = "# ffffff ";
  29. Params. allowscriptaccess = "sameDomain ";
  30. Params. allowfullscreen = "true ";
  31. Var attributes = {};
  32. Attributes. id = "FlexPaperViewer ";
  33. Attributes. name = "FlexPaperViewer ";
  34. Swfobject. embedSWF (
  35. "FlexPaperViewer.swf", "flashContent ",
  36. "650", "500 ",
  37. SwfVersionStr, xiSwfUrlStr,
  38. Flashvars, params, attributes );
  39. Swfobject. createCSS ("# flashContent", "display: block; text-align: left ;");
  40. </Script>
  41. <Body>
  42. <Div style = "position: absolute; left: 10px; top: 10px;">
  43. <Div id = "flashContent">
  44. </Div>
  45. </Div>
  46. </Body>


Using the above method, we can convert a pdf file into a corresponding swf file and display it through flexpaper to prevent users from downloading or copying.

 

 

The detailed parameter description of ipv2swf can be found on Baidu or Google, but it is best to specify flashversion as 9 to prevent unexpected errors.
Not all pdf files can be converted in iis2swf, but the encrypted pdf file cannot be converted.


For more information about flexpaper parameters, see http://code.google.com/p/flexpaper/wiki/Parameters.

Flexpaper API http://code.google.com/p/flexpaper/wiki/API

 

 

If garbled characters occur, it may be character sets. There are many solutions on the Internet to query [I have not encountered Character Set blocking problems ].

In addition, images in pdf may not be clear after being converted to swf.

 

Word, wps, txt and other documents can also be converted in this way, but the tool is not necessarily set as swftools

The uploaded flexpaper attachment contains files in flexpaper. You do not need to download them again. You only need to download swftools and install it.
The flexpaper attachment contains the ipv2swf. jsp and ipv2swf. php files and flexpaper-related components that can be run in the java or php environment.


: PDF2SWF conversion only has one page of PDF document, not displayed in FlexPaper

Version problem. We recommend that you uninstall and reinstall it.

Java + FlexPaper + swfTools design and implementation of an online preview system for Baidu Library Documents

Use the FlexPaper plug-in to convert the word into a pdf file and then convert the pdf file into a swf file. Upload the file and you can use FlexPaper to play the file. Note that the server system is different, so the Delimiter is different. I hope it will be helpful for your thinking.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.