how to put a video inside a pdf

Asked

Viewed 1,011 times

0

How to insert a video into a generated pdf using the iTextSharp library?

I need the library because it also does file union and digital signature.

1 answer

3

Using iTextSharp, do it as follows:

//cria o documento
var doc = new Document();
//caminho do arquivo gerado
String outfile = "c:/documento.pdf";
//pega instância do objeto PdfWriter
PdfWriter writer=PdfWriter.GetInstance(doc, new FileStream(outfile, FileMode.Create));
//abre o documento para escrita
doc.Open();
//cria uma instância da classe PdfFileSpecification
PdfFileSpecification fs = PdfFileSpecification.FileEmbedded(writer, "c:/video.mpg", "video.mpg", null);
//criar e adiciona uma anotação de vídeo no documento
writer.AddAnnotation(PdfAnnotation.CreateScreen(writer, new Rectangle(200f, 700f, 400f, 800f), "Vídeo", fs,"video/mpeg", true));
//fecha o documento
doc.Close();
//visualiza o resultado
System.Diagnostics.Process.Start(outfile);

The following file formats are supported:

  • .aiff --- audio/aiff
  • .au --- audio/basic
  • .avi --- video/avi
  • .mid --- audio/midi
  • .mov -- video/Quicktime
  • .mp4 --- video/mp4
  • .mp4 --- audio/mp4
  • .mpeg --- video/mpeg
  • .Smil -- application/Smil
  • .swf --- application/x-Shockwave-flash

Source

Browser other questions tagged

You are not signed in. Login or sign up in order to post.