How would you programmatically embed a SWF in a PDF?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-01 05:20:32

问题


Is it possible to programmatically embed a SWF in a PDF from a C# application?


回答1:


You can use the c# port of the iText library. It's called iTextSharp.

http://itextsharp.com/

An example of what the code could look like:

 // create an output file stream which will be used to capture the generated file 
    string outputFileName = "output.pdf"; 
    FileStream outputFile = new FileStream(outputFileName, FileMode.Create); 

    // open the original pdf file as a PdfReader 
    PdfReader reader = new PdfReader("inputfile.pdf"); 

    // open the output pdf file as a PdfStamper 
    PdfStamper stamper = new PdfStamper(reader, outputFile); 

    // inserts a blank page at the start of the document 
    stamper.InsertPage(1, PageSize.A4); 

    // add the flash file to the output document as an annotation 
    PdfFileSpecification fs = PdfFileSpecification.FileEmbedded(stamper.Writer, flashFileTextBox.Text, flashFileTextBox.Text, null); 
    PdfAnnotation flashInsert = PdfAnnotation.CreateScreen(stamper.Writer, new Rectangle(50f,791f,545f,420f),"Flash Insert",fs, "application/x-shockwave-flash", true); 

    stamper.AddAnnotation(flashInsert,1); 

    stamper.Close(); 
    reader.Close(); 



回答2:


Flash SWF files can be embedded into a PDF document programmatically. Have a look at the PDF library from webSupergoo. The documentation includes examples in C# and VB.NET.



来源:https://stackoverflow.com/questions/1021124/how-would-you-programmatically-embed-a-swf-in-a-pdf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!