These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Generate RichMedia

RyuMaster
Registered: Aug 18 2010
Posts: 7

Hi! There is open source FPDF library, which generates PDF files. I'm trying to add SWF suport for it.

For sample, in order to add image to PDF, it parses the file and returns those values:

//////////////////////////////////////////////////////////////////////////////////////////////////
array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data);
w - width
h - height
cs - color space
bpc- bits
f - decoder
data - image data

And then outputs file to PDF

$this->_out(sprintf('q %.2F 0 0 %.2F %.2F %.2F cm /I%d Do Q',$w*$this->k,$h*$this->k,$x*$this->k,($this->h-($y+$h))*$this->k,$info['i']));
//////////////////////////////////////////////////////////////////////////////////////////////
How should this process look for SWF file?
Aside from parsing it, which minimal amount of data should be outputed to PDF, in order for it to display embedded SWF correctly? Is there any sample around the net?

All I can found, is information how to embed swf using Captives, but not programatically generate syntax. There is one sample in Adobe Reference, but is is quite complex and has no "Hello swf" to start with.

UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
Creating a rich media annotation directly in the COS stream is a fair amount more complicated than placing an image, which explains why the example in the PDF reference is equally complex. Not only does the RMA itself need defining (position, playback style, mode, activation triggers, etc) but you need to add dicts of both the SWF and a poster image (in JPEG). Acrobat makes one for you, but you'll need to handle doing that yourself. If the SWF has resources, those need to be added too, in yet another subclass of dict.
RyuMaster
Registered: Aug 18 2010
Posts: 7
Thanks for the answer. So it would not be easy. Well, I guess I'll try and start somewhere...
RyuMaster
Registered: Aug 18 2010
Posts: 7
Little by little, I have improved FPDF library to generate code for swf embed. But no matter what, I still get corrupted output. I tried many ways, was getting back to documentaton many times. Can't figure out, where I am going wrong. Is there any way to debug pdf, tell where it is corrupted?

Like, this one I have. It has embedd swf, but shows error. How can I figure out, why? I think I added all annotations, asset definitions, anything.

http://www.gomsek.org/fpdf/doc.pdf
idefaye
Registered: Sep 15 2010
Posts: 1
I am for looking the same functionality. Have you had any success to embed swf with fpdf ?
If you still have some problems may be I could be of help by looking at the code.