Swftools converts PDF to SwF

Source: Internet
Author: User
Tags flv file

Swftools is a set of sdks used to process Flash SWF files, including:
1. Merge tool swfcombine
2. Extraction Tool swfextract
3. Conversion tools from PDF, JPEG, PNG, Avi, TTF, and wav to SwF: pdf2swf, jpeg2swf, png2swf, avi2swf, font2swf, and wav2swf |
4. Text parsing tool swfstrings
5. SWF parser swfdump
6. SWF read/write library rfxswflib
Swftools provides a series of tools to convert various files into SWF:
Font2swf.exe
Gif2swf.exe
Ipv2swf.exe
Ipv2swf.exe
Png2swf.exe
Wav2swf.exe
The specific functions are just as the name suggests.
The tool used to convert a PDF file into a SWF file is ipv2swf. Generally, running ipv2swf src.pdf des.swf in the command line can meet the requirements. The command line parameters can be obtained through ipv2swf-F:
-H,-help print short help message and exit print help information

-V,-version print version info and exit print version number

-O,-output file.swf direct output to file.swf. If file.swf contains '000000' (file13568630.swf), then each page specifies the output SWF file name

-P,-pages range convert only pages in range with range e.g. 1-20
Or,-11 or specifies the conversion page range. The page number description method is the same as that used when the printer prints a file.
-P,-Password Use password for deciphering the pdf. Specify the password for opening the PDF.
-V,-verbose be verbose. use more than one-V for greater effect. Detailed content is output during conversion.

-Z,-zlib use flash 6 (MX) zlib compression. Use zlib compression mechanism of Flash 6

-I,-ignore allows into 2swf to change the draw order of the PDF. This may make the generated allow the program to modify the drawing sequence of the PDF, which may cause the results to be different from the original

-J,-maximum quality set quality of embedded JPEG pictures to quality. 0 is worst (small) and 100 is best (BIG ). (default: 85) set the quality of the JPEG image to be converted from 0 to 100. The default value is 85.

-S,-set Param = value set a SwF encoder specific parameter. See parameter 2swf-s help for more information. You can use the parameter 2swf-s help to obtain the parameters for SwF transcoding.

-W,-samewindow when converting PDF hyperlinks, don't make the links open a new window. Set the converted SWF to use the same window when opening the connection in the original PDF.

-T,-Stop insert a stop () command in each page. Add a stop () command at the end of each page.

-T,-flashversion num set flash version in the SWF header to num. Set the Flash version used by SWF

-F,-fontdir directory add directory to the font search path. specifies the path of the font file

-B,-defaultviewer link a standard viewer to the SWF file. Specify the default SWF navigation file to flip pages, zoom in and out

-L,-defaultloader link a standard preloader to the SWF file which will be displayed while the main SWF is loading. Specify the default SWF file to display the loading process effect.

-B,-Viewer filename link viewer filename to the SWF file. Specify the SWF navigation file, which works the same as-B.

-L,-preloader filename link preloader filename to the SWF file. Specify the SWF file to be loaded.

-Q,-Quiet suppress normal messages. Use-QQ to suppress warnings, also. Do not print common information, do not print warning information with-QQ.

-S,-shapes don't use SWF fonts, but store everything as shape. No font is used, and all are converted into shapes.

-F,-fonts store full fonts in SWF. (Don't reduce to used characters). Save All fonts in SWF.

-G,-flatten remove as your clip layers from file as possible. Remove the film layers in the file as much as possible and merge them.

-I,-Info don't do actual conversion, just display a list Of all pages in the PDF. No actual conversion is performed, only PDF information is displayed.

-Q,-maxtime n abort conversion after n seconds. Only available on Unix. Exit if the running time times out.
Then let's see what-S can set:
PDF parameters:
PDF device global parameters:
Fontdir = a directory with additional fonts specifies the font Directory, which is similar to-F of level 1 parameters.
Font = an additional Font filename add additional font files
Pages = the range of pages to convert (example: pages = 1-100,210-) specifies the page range, which is similar to-P of level 1 parameters.
Zoom = the resolution (default: 72) specifies the resolution. The default value is 72 dpi.
Export agedir = add an xpdf language directory, useful for non-Western European characters
Multiply = render everything at the resolution rendering at several times of resolution
Poly2bitmap convert graphics to bitmaps converts a graph into a dot matrix.
Bitmap convert everything to bitmaps converts all the content into a dot matrix (including a font) SWF parameters:
SWF layer options:
Required subpixels = <pixels> resolution adjustment for JPEG images (same as jpegdpi, but in pixels) JPEG image resolution
Ppmsubpixels = <pixels> resolution adjustment for Lossless images (same asppmdpi, but in pixels) lossless image resolution
Subpixels = <pixels> shortcut for setting both limit subpixels and ppmsubpixels
Drawonlyshapes convert everything to shapes (currently broken)
Ignoredraworder allow to perform a few optimizations for creating smaller SWFs allows small Optimizations
Linksopennewwindow make links open a new browser window link opens a new window
Linktarget target window name of new links new link window name
Linkcolor = <color) color of links (Format: rrggbbaa) link color
Linknameurl link buttons will be named like the URL they refer to (handy for iterating through links with ActionScript) The Link name is consistent with the link URL
Storeallcharacters don't reduce the fonts to used characters in the output file to save all Character Fonts
Enablezlib switch on zlib compression (also done if flashversion> = 7) Use zlib for compression
Bboxvars store the bounding box of the SWF file in ActionScript variables saves the SWF area size in
Dots take care to handle dots correctly save single-point display
Reordertags = 0/1 (default: 1) perform some tag optimizations perform some tag Optimization
Internallinkfunction = <Name> when the user clicks a internal link (to a different page) in the converted file, this ActionScript function is a called internal link function. If you click an internal link, the ActionScript function will be called.
Externallinkfunction = <Name> when the user clicks an external link (e.g.
Http://www.foo.bar/) on the converted file, this ActionScript function is the called external link function, if you click an external link, it is called
Disable_polygon_conversion never convert strokes to polygons (will remove capstyles and joint styles) do not convert strokes into Polygon
Caplinewidth = <width> the minimum thichness a line needs to have so that capstyles become visible (and are converted) The minimum conversion width of a line is not converted.
Insertstop put an ActionScript "stop" tag in every frame Add the stop () function to each worker of SwF
Protect Add a "protect" tag to the file, to prevent loadingin The Flash editor Add the protect tag, prohibit loading the SWF in Flash
Flashversion = <version> the SWF fileversion (6) sets the lowest SWF version
Framerate = <FPS> SWF framerate
Minlinewidth = <width> convert horizontal/vertical boxes smaller than thiswidth to lines (0.05) convert a rectangle with a width less than a certain value into a line
Simpleviewer add next/previous buttons to the SWF use simple navigation
Animate insert a showframe tag after each placeobject (animate draw order of PDF files )???
Required quality = <quality> set compression quality of JPEG images sets the JPEG compression quality
Splinequality = <value> set the quality of spline convertion to value (0-100, default: 100). Set the conversion quality of the spline.
Disablelinks disable links. Disable link
There may be some trouble in converting PDF files with Chinese characters. The specific solution is as follows: (the text on javaeye)
1. Download swftools: http://www.swftools.org/download.html download xpdf

Xpdf-Chinese-Simplified
Download two Chinese font files
Font File
2. Install swftools to any path
Decompress xpdf to any path
Decompress the Chinese font to the xdpf \ Chinese-Simplified \ cmap folder.
3. Modify the xpdfrc file in xpdf to change the cidtounicode and other paths to the local path,
Modify the Chinese-Simplified \ add-to-xpdfrc file in xpdf.
4. Open the command line window: Export 2swf-O output file path-T input file path-s export agedir = xpdf path \ Chinese-Simplified
Some PDF images have poor conversion performance and lead to excessive shapes. In this case, you can use the-s poly2bitmap parameter to convert the image into a dot matrix. The size of the generated SWF is smaller.

Problem:

A problem occurs when processing a Chinese document:
Couldn't find a font for 'simhei'
The font code for this document is "GBK-EUC-H", the actual font is simhei, the type is TrueType (CID ).

Solution:

1. Copy A simhei. TTF to xdpf \ Chinese-Simplified \ cmap,
2. Modify the xpdfrc file under xpdf and add one line: displaycidfonttt Adobe-GB1 simhei. TTF path

 

Reference
As the project requires, I have been studying an example of Baidu Library. After searching on the internet, I found that there is basically a Way of Thinking: first use OpenOffice and jodconverter to convert documents such as office to PDF, and then use Java. lang. process calls the swftools program to Convert PDF to SWF. At last, flexpaper can be used to display the generated SWF. The effect is similar to that of Baidu Library.
There is no problem in thinking, but a Java. lang. the problem of process blocking is that the PDF file cannot be generated when JAVA process is called to start the SWF conversion file. After that, I did not understand the problem for a long time, I accidentally found a post about Java Process blocking. Later I learned that when calling a local program through java. Lang. process, I need to read the output information in the process cache. Otherwise, the process will be blocked.

These two days I have been working on setting up the FLV video environment, including Server Installation and Java applications. There is no major problem in installing FFMPEG and mencoder, but there is still a small problem that makes me depressed, that is, an error occurs when installing amrwb and amrnb. The error is as follows:
/Usr/bin/wget-n
Http://www.3gpp.org/ftp/Specs/ar. .. 6.104/26104-610.zip
-- 20:41:59 -- http://www.3gpp.org/ftp/Specs/ar... 6.104/26104-610.zip
Parsing host www.3gpp.org... 212.234.161.21
Connecting to www.3gpp.org | 212.234.161.21 |: 80... connected.
An HTTP request has been sent and is waiting for response... 403 Forbidden
20:42:00 error 403: forbidden.
Make: *** invalid 26104-610.zip] Error 1
Later, I carefully read and asked the company's network administrator to know that I did not open the Internet for this test machine. I also thought of this problem at the beginning. I can ping it when I can ping it, so I gave up that idea. Who knows this is really the problem? The result is just a bit simple. After activating the network, the installation will be very smooth ~~~ This is an out-of-the-box question.
After the FFMPEG environment is set up, it is no problem to manually convert it locally. It is no problem to call the program (without obtaining the program feedback results. Later, when I submitted a video conversion request, I had to perform database operations. For example, before the conversion, I updated the status of the video to being updated, after the conversion, enter the FLV file path and image path information of the video, as well as the size and duration of the FLV file. This requires controlling the status of the FFMPEG process in the thread. here we need to use the process class. The typical code is as follows:
......
Process = runtime.getruntime.exe C (CMD); // run the FFMPEG command
Inputstream is = process. getinputstream (); // gets the output stream of the FFMPEG Process
Bufferedreader BR = new buffered (New inputstreamreader (is); // buffer read
Stringbuilder Buf = new stringbuilder (); // Save the output stream of FFMPEG
String line = NULL;
While (line = Br. Readline ())! = NULL) BUF. append (line); // The loop waits until the FFMPEG process ends.
System. Out. println ("FFMPEG output content:" + BUF );
......
This is usually the way to call a program and get the output stream of the process. However, when I execute such a call on Windows, it is always blocked while, as a result, the FFMPEG program will not be executed after being executed for a while. here we can see from the official reference documents that this is due to the buffer issue because the Java Process has not cleared the content written by the FFMPEG program to the buffer, as a result, the FFMPEG program remains waiting. I also found a lot of such problems on the Internet, but all I said was to use a separate thread for control. I also tried a lot of methods on the Internet, but it never worked. The following is my solution. Have you noticed the red part in the above Code? Here is the key. I changed it to the following result and it will run normally.
Inputstream is = process. geterrorstream (); // gets the output stream of the FFMPEG Process
Did you notice? I changed it to get the error stream so that the process will not be blocked, and I have been thinking that the same command can be completed when I call it manually, java calls cannot be completed. It is always considered that the buffer zone of getinputstream is not cleared, but the problem is that the buffer content is not cleared, but not the buffer of getinputstream, but the buffer zone of geterrorstream, in this way, the problem is solved. Therefore, when we encounter thread blocking caused by Java calling external programs, we can consider using two threads to clear the two input streams obtained by process at the same time, as shown below:
......
Process = runtime.getruntime.exe C (command); // call an external program
Final inputstream is1 = process. getinputstream ();
New thread (New runnable (){
Public void run (){
Bufferedreader BR = new buffered (New inputstreamreader (is ));
While (Br. Readline ()! = NULL );
}
}. Start (); // start a separate thread to clear the buffer zone of process. getinputstream ().
Inputstream is2 = process. geterrorstream ();
Bufferedreader Br2 = new buffered (New inputstreamreader (is2 ));
Stringbuilder Buf = new stringbuilder (); // Save the output result stream
String line = NULL;
While (line = Br. Readline ())! = NULL) BUF. append (line); // The loop waits until the FFMPEG process ends.
System. Out. println ("output result:" + BUF );
......
In this way, we use a thread to read the process. the output stream of getinputstream (). Use another thread to obtain the process. the output stream of geterrorstream (), so that we can ensure that the buffer is cleared in time without worrying about thread blocking. Of course, you can retain the content in the process. getinputstream () stream as needed. It depends on the processing of the called program. In Windows, when I call the FFMPEG program for video conversion, this solves the problem of thread congestion ~

 

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.