fixed graphics bug
[swftools.git] / pdf2swf / HOWTO_pdf2swf
1 Notice
2
3    This documentation is a little outdated. As with swftools-0.2.1 and
4    above, you can simply do
5    pdf2swf -bl -o document.swf document.pdf
6    to link viewer and preloader.
7    However, the Steps below are still valid for jpeg2swf.
8
9 Step 1: Converting the documents
10
11    Suppose you have an arbitrary pdf file, "document.pdf".
12    Call:
13    pdf2swf -o tmp.swf document.pdf
14    Now, tmp.swf is a Flash Movie generated from document.pdf. Movie means
15    that there are no navigation elements whatsoever. Just frames which
16    get displayed one by one, at a rate of approx. 1/2 frames/second. How
17    to make document browsable is explained below.
18    (You can do the same things described below with jpeg files. Simply
19    use
20    jpeg2swf -o tmp.swf pic1.jpeg pic2.jpeg ...
21    and read on)
22
23 Step 2: Linking a viewer
24
25    Just take a viewer of your choice (e.g. [1]SimpleViewer.swf ) and put
26    it in the same directory where you entered the commands above.
27    Now call:
28    swfcombine -o flashfile.swf SimpleViewer.swf viewport=tmp.swf
29    Now, 'flashfile.swf' is "browsable", i.e. there are some buttons in it
30    for turning pages.
31
32 Step 3: Linking a Preloader
33
34    Depending on the size of your PDFs/SWFs, you may want to have some
35    kind of loading animation displayed while the browser is busy getting
36    the actual document. Assuming you have some file like flashfile.swf
37    above, you furthermore need the file [2]PreLoader.swf and an arbirtary
38    loading animation of your choice. (To get started, try [3]loading.swf,
39    or just convert a "Loading" JPEG picture to swf (jpeg2swf -o
40    loading.swf picture.jpg)) Now use
41    swfcombine -o flashfile.swf PreLoader.swf loader=loading.swf
42    movie=flashfile.swf
43    (Most loaders are smaller than the document they load. They usually
44    need some centering so they appear in the middle of the page to be
45    displayed, not in the upper left corner. Replace the above command
46    with e.g.
47    swfcombine -o flashfile.swf PreLoader.swf -x 3000 -y 3000
48    loader=loading.swf movie=flashfile.swf
49    and try playing around with the values after -x and -y)
50
51 Step 4: Correcting the size and framerate
52
53    Sometimes, the bounding box of the generated flash file is not
54    correct. This happens because when linking a viewer or preloader to
55    the SWFs, the new dimensions are those of the PreLoader and Viewer
56    templates, and not those of your pdf or jpeg files. To fix this, use
57    swfcombine --dummy `swfdump -XY tmp.swf` flashfile.swf -o
58    flashfile.swf
59    (tmp.swf is your 'original' swf, generated like above)
60    You may also want to adjust the framerate of the movie to that of the
61    preloader. (As the preloader is usually the only animated part of e.g.
62    pdf viewers)
63    Use:
64    swfcombine --dummy `swfdump -r loading.swf` flashfile.swf -o
65    flashfile.swf
66
67 Step 5: Embedding the SWF into a html page
68
69    Usually, one wants to put the generated SWFs on his web page. To do
70    so, you have to embed the SWF file into html. If you don't know how to
71    embed SWFs into html pages, it's explained at
72    [4]http://www.macromedia.com/support/flash/ts/documents/tn4150.html .
73    Also, you can simply type
74    swfdump --html flashfile.swf
75    and insert the output into your html document
76
77 Appendix A: Creating your own Viewers
78
79    If you know about Flash, and you want to substitute SimpleViewer from
80    above with something more sophisticated, follow these rules:
81    1. There has to be some rectangle (Movieclip, whatever... ) in your
82    Viewer, named "viewport". (This name is used to reference the object
83    when using swfcombine for merging it with the converted pdfs)
84    2. The First frame should contain an actionscript "Stop" instruction.
85    (Otherwise, the browsing buttons turn pages, but pages get also
86    automatically turned every few seconds)
87    3. Browsing buttons next to the rectangle (which turn pages in the
88    shown pdf) should trigger some Actionsscript events, like
89
90      SetTarget "viewport"
91      NextFrame
92      SetTarget ""
93
94    to set the frame in the to-be-replaced rectangle. (It will be replaced
95    with a MovieClip, therefore a SetTarget is neccessary)
96    It's important that the Target Name ist "viewport", not "/viewport",
97    as the Movie will get inserted into a Movieclip (Sprite).
98      _________________________________________________________________
99
100    [5]Back to the SWFTools Project page
101
102 References
103
104    Visible links
105    1. http://www.quiss.org/swftools/SimpleViewer.swf
106    2. http://www.quiss.org/swftools/PreLoader.swf
107    3. http://www.quiss.org/swftools/loading.swf
108    4. http://www.macromedia.com/support/flash/ts/documents/tn4150.html
109    5. http://www.quiss.org/swftools
110
111
112