Kann eine SWF-Datei programmgesteuert in eine PDF-Datei aus einer C# -Anwendung eingebettet werden?Wie würden Sie eine SWF-Datei programmatisch in ein PDF einbetten?
6
A
Antwort
4
Sie können den C# -Port der iText-Bibliothek verwenden. Es heißt iTextSharp.
Ein Beispiel, wie der Code aussehen könnte:
// 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();
1
Flash SWF-Dateien können programmatisch in ein PDF-Dokument eingebettet werden. Sehen Sie sich die PDF-Bibliothek von webSupergoo an. Die Dokumentation enthält Beispiele in C# und VB.NET.