您将如何以编程方式在SWF中嵌入SWF?

时间:2022-08-25 08:35:25

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

是否有可能以编程方式将SWF嵌入到C#应用程序的PDF中?

2 个解决方案

#1


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

您可以使用iText库的c#端口。它被称为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.

Flash SWF文件可以通过编程方式嵌入到PDF文档中。看看webSupergoo的PDF库。该文档包括C#和VB.NET中的示例。

#1


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

您可以使用iText库的c#端口。它被称为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.

Flash SWF文件可以通过编程方式嵌入到PDF文档中。看看webSupergoo的PDF库。该文档包括C#和VB.NET中的示例。