Pdf2swf+flexpapers to achieve similar Baidu Library PDF online Reading _java

Source: Internet
Author: User
Tags php example

1: Tool Preparation

Swftools.exe Download
Http://www.swftools.org/download.html
Install to D disk
Swftools provides a series of tools for converting various files into SWF:
Font2swf.exe
Gif2swf.exe
Jpeg2swf.exe
Pdf2swf.exe
Png2swf.exe
Wav2swf.exe
Here we only use Pdf2swf.exe

Flexpaper Download
http://code.google.com/p/flexpaper/
Here we use the already compiled Flexpaper Flash version

2: Sample language, here are the two development environments I use to do the example
PHP Example
SWF file generated by PDF

Copy Code code as follows:

<?php
/*
* Created on 2010-11-17
*
* To change the template for this generated file go
* Window-preferences-phpeclipse-php-code Templates
*/
Get the directory where the file resides
$dir =dirname (__file__);
Delete test files
@unlink ($dir. " \\test.swf ");
Using the pdf2swf conversion command
$command = "d:/swftools/pdf2swf.exe-t \" ". $dir." \\test.pdf\ "-O \" ". $dir." \\test.swf\ "-S flashversion=9";
Creating a Shell Object
$WshShell = new COM ("Wscript.Shell");
Execute cmd command
$oExec = $WshShell->run ("cmd/c"). $command, 0, true);
?>

Java sample

Copy Code code as follows:

<%
/*
* Created on 2010-11-17
*/
Get the directory where the file resides
String Path=request.getrealpath ("/");
Using the pdf2swf conversion command
String command= "d:/swftools/pdf2swf.exe-t \" "+path+" \\test.pdf\ "-o \" "+path+" \\test.swf\ "-S flashversion=9";
Execute cmd command
Runtime.getruntime (). EXEC ("cmd/c" +command);
%>

The above is Php,java convert PDF to SwF Way, that shows, so we will use to Flexpaper, the following is the use of Flexpaper
Using Flexpaper to show SWF

Copy Code code as follows:

<script type= "Text/javascript" src= "Js/swfobject/swfobject.js" ></script>
<script type= "Text/javascript" >
var swfversionstr = "10.0.0";
var xiswfurlstr = "playerproductinstall.swf";
var flashvars = {
Swffile:escape ("test.swf"),
scale:0.6,
Zoomtransition: "Easeout",
zoomtime:0.5,
zoominterval:0.1,
Fitpageonload:false,
Fitwidthonload:true,
Printenabled:true,
Fullscreenasmaxwindow:false,
Progressiveloading:true,
Printtoolsvisible:true,
Viewmodetoolsvisible:true,
Zoomtoolsvisible:true,
Fullscreenvisible:true,
Navtoolsvisible:true,
Cursortoolsvisible:true,
Searchtoolsvisible:true,
Localechain: "ZH_CN"
};

var params = {

}
Params.quality = "High";
Params.bgcolor = "#ffffff";
params.allowscriptaccess = "Samedomain";
Params.allowfullscreen = "true";
var attributes = {};
Attributes.id = "Flexpaperviewer";
Attributes.name = "Flexpaperviewer";
SWFOBJECT.EMBEDSWF (
"Flexpaperviewer.swf", "Flashcontent",
"650", "500",
Swfversionstr, Xiswfurlstr,
Flashvars, params, attributes);
Swfobject.createcss ("#flashContent", "display:block;text-align:left;");
</script>

<body>
<div style= "position:absolute;left:10px;top:10px;" >
<div id= "Flashcontent" >
</div>
</div>
</body>

In this way we can convert the PDF to the corresponding SWF file and display it through Flexpaper to prevent users from downloading, or copy.

pdf2swf detailed parameter description, Internet Baidu or Google can find, but note the best to specify Flashversion 9, to prevent some unexpected errors.
Not all PDFs in pdf2swf can be converted, and encrypted PDF pdf2swf cannot be converted

Flexpaper parameter details please refer to Http://code.google.com/p/flexpaper/wiki/Parameters

Flexpaper Common API Http://code.google.com/p/flexpaper/wiki/API

If the garbled problem may be a character set, there are many related solutions on the internet can be queried "I did not encounter the problem of character set blocking."

There is also a PDF containing pictures may be converted to SWF after the picture is not clear.

Documents such as Word,wps,txt can also be converted in this way, but the tools are not necessarily swftools

The uploaded flexpaper attachment already contains flexpaper files in the file without downloading, just download the swftools and install it.
The flexpaper attachment contains pdf2swf.jsp and pdf2swf.php two files and Flexpaper-related components that can be run in a Java or PHP environment.

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.