You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Gary Grosso <ga...@oberontech.com> on 2016/09/21 14:23:54 UTC

Embedding video in PDF

Hi PDFBoxers,

A customer wants to embed MP4 video in their PDF. (They want to be able to view with an offline iPad.)

I see info in the cookbook for 1.8 (https://pdfbox.apache.org/1.8/cookbook/workingwithattachments.html) and the example at https://svn.apache.org/repos/asf/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/EmbeddedFiles.java. Also Tilman's reply in 2014:

~~~~~~
Yes, please look at the example
examples\src\main\java\org\apache\pdfbox\examples\pdmodel\EmbeddedFiles.java
or
https://svn.apache.org/repos/asf/pdfbox/branches/1.8/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/EmbeddedFiles.java
to see how to embed a file. There is no restriction on the type AFAIK.

Tilman
~~~~~~

My questions are:

- Is the above info relevant/accurate if using PDFBox 2.0?

- Has anyone had any personal experience with this sort of thing? (We would be post-processing their PDF, which is created elsewhere, to insert the video at a point where we would leave some sort of local-filename marker and sufficient white space.)

Thanks,
Gary



RE: Embedding video in PDF

Posted by Gary Grosso <ga...@oberontech.com>.
It's also the most recently written book I see at Amazon. Thanks.


Gary


-----Original Message-----
From: John Hewson [mailto:john@jahewson.com] 
Sent: Wednesday, September 21, 2016 3:53 PM
To: users@pdfbox.apache.org
Subject: Re: Embedding video in PDF


> On 21 Sep 2016, at 12:30, Gary Grosso <ga...@oberontech.com> wrote:
> 
> Hi John,
> 
> I'll keep that in mind. The XML-to-PDF process in use is a black box (no source available), so I'll have to experiment --  I have no definite way of creating an annotation. But your information may prove useful. In fact, I think I'll try putting out a rectangle of a particular color, whether it uses annotation or not. Sounds like a good place to start.
> 
> It sounds like I'll have to get better with using PDFDebugger, which I expect means getting a better understanding of the PDF spec. I’d be interested in any recommendations of books or online resources.

The spec itself is pretty readable. If you’re looking to get up to speed on the basics first, then Leonard Rosenthal’s book “Developing with PDF” gives a concise (200 pages) introduction. Leonard is Adobe’s chief PDF spec guy.

— John

> Thanks,
> Gary
> 
> 
> -----Original Message-----
> From: John Hewson [mailto:john@jahewson.com]
> Sent: Wednesday, September 21, 2016 3:11 PM
> To: users@pdfbox.apache.org
> Subject: Re: Embedding video in PDF
> 
> 
>> On 21 Sep 2016, at 10:15, Gary Grosso <ga...@oberontech.com> wrote:
>> 
>> Hi Tilman,
>> 
>> Yes, that is correct. And the video has to be embedded, since some end-users may not have an Internet connection. The video files they are starting with are MP4s.
>> 
>> I figure I have to reserve the correct amount of vertical space in the original PDF to get appropriate page breaks. Either the author will specify the height, or I'll have to have other code to call something like ffmpeg or ImageMagick to get the height of the video. But that's a separate issue.
>> 
>> Then I figure I need to insert some "marker" in the PDF file that gives the location of the MP4 on the system which publishes the PDF.
>> 
>> So the piece I am asking about would be a Java program which would look through the PDF for these markers, find the MP4 for each marker, and embed the video in the PDF at that location.
> 
> Given that videos in PDF are a form of “annotation”, you might want to use a rectangle annotation as your marker. Perhaps give it a specific color.
> 
> — John
> 
>> Any thoughts on this matter are much appreciated. (I have to give an 
>> estimate of effort -- for me giving estimates is the bane of computer
>> programming.)
>> 
>> Best regards,
>> Gary
>> 
>> 
>> -----Original Message-----
>> From: Tilman Hausherr [mailto:THausherr@t-online.de]
>> Sent: Wednesday, September 21, 2016 1:03 PM
>> To: users@pdfbox.apache.org
>> Subject: Re: Embedding video in PDF
>> 
>> Am 21.09.2016 um 16:23 schrieb Gary Grosso:
>>> 
>>> - Has anyone had any personal experience with this sort of thing? 
>>> (We would be post-processing their PDF, which is created elsewhere, 
>>> to insert the video at a point where we would leave some sort of 
>>> local-filename marker and sufficient white space.)
>> 
>> I think what you want to do is to embed the video so that there is a screen area in the PDF, like embedding a youtube video - right?
>> 
>> Tilman
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: Embedding video in PDF

Posted by John Hewson <jo...@jahewson.com>.
> On 21 Sep 2016, at 12:30, Gary Grosso <ga...@oberontech.com> wrote:
> 
> Hi John,
> 
> I'll keep that in mind. The XML-to-PDF process in use is a black box (no source available), so I'll have to experiment --  I have no definite way of creating an annotation. But your information may prove useful. In fact, I think I'll try putting out a rectangle of a particular color, whether it uses annotation or not. Sounds like a good place to start.
> 
> It sounds like I'll have to get better with using PDFDebugger, which I expect means getting a better understanding of the PDF spec. I’d be interested in any recommendations of books or online resources.

The spec itself is pretty readable. If you’re looking to get up to speed on the basics first, then Leonard Rosenthal’s book “Developing with PDF” gives a concise (200 pages) introduction. Leonard is Adobe’s chief PDF spec guy.

— John

> Thanks,
> Gary
> 
> 
> -----Original Message-----
> From: John Hewson [mailto:john@jahewson.com] 
> Sent: Wednesday, September 21, 2016 3:11 PM
> To: users@pdfbox.apache.org
> Subject: Re: Embedding video in PDF
> 
> 
>> On 21 Sep 2016, at 10:15, Gary Grosso <ga...@oberontech.com> wrote:
>> 
>> Hi Tilman,
>> 
>> Yes, that is correct. And the video has to be embedded, since some end-users may not have an Internet connection. The video files they are starting with are MP4s.
>> 
>> I figure I have to reserve the correct amount of vertical space in the original PDF to get appropriate page breaks. Either the author will specify the height, or I'll have to have other code to call something like ffmpeg or ImageMagick to get the height of the video. But that's a separate issue.
>> 
>> Then I figure I need to insert some "marker" in the PDF file that gives the location of the MP4 on the system which publishes the PDF.
>> 
>> So the piece I am asking about would be a Java program which would look through the PDF for these markers, find the MP4 for each marker, and embed the video in the PDF at that location.
> 
> Given that videos in PDF are a form of “annotation”, you might want to use a rectangle annotation as your marker. Perhaps give it a specific color.
> 
> — John
> 
>> Any thoughts on this matter are much appreciated. (I have to give an 
>> estimate of effort -- for me giving estimates is the bane of computer 
>> programming.)
>> 
>> Best regards,
>> Gary
>> 
>> 
>> -----Original Message-----
>> From: Tilman Hausherr [mailto:THausherr@t-online.de]
>> Sent: Wednesday, September 21, 2016 1:03 PM
>> To: users@pdfbox.apache.org
>> Subject: Re: Embedding video in PDF
>> 
>> Am 21.09.2016 um 16:23 schrieb Gary Grosso:
>>> 
>>> - Has anyone had any personal experience with this sort of thing? (We 
>>> would be post-processing their PDF, which is created elsewhere, to 
>>> insert the video at a point where we would leave some sort of 
>>> local-filename marker and sufficient white space.)
>> 
>> I think what you want to do is to embed the video so that there is a screen area in the PDF, like embedding a youtube video - right?
>> 
>> Tilman
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


RE: Embedding video in PDF

Posted by Gary Grosso <ga...@oberontech.com>.
Hi John,

I'll keep that in mind. The XML-to-PDF process in use is a black box (no source available), so I'll have to experiment --  I have no definite way of creating an annotation. But your information may prove useful. In fact, I think I'll try putting out a rectangle of a particular color, whether it uses annotation or not. Sounds like a good place to start.

It sounds like I'll have to get better with using PDFDebugger, which I expect means getting a better understanding of the PDF spec. I'd be interested in any recommendations of books or online resources.

Thanks,
Gary


-----Original Message-----
From: John Hewson [mailto:john@jahewson.com] 
Sent: Wednesday, September 21, 2016 3:11 PM
To: users@pdfbox.apache.org
Subject: Re: Embedding video in PDF


> On 21 Sep 2016, at 10:15, Gary Grosso <ga...@oberontech.com> wrote:
> 
> Hi Tilman,
> 
> Yes, that is correct. And the video has to be embedded, since some end-users may not have an Internet connection. The video files they are starting with are MP4s.
> 
> I figure I have to reserve the correct amount of vertical space in the original PDF to get appropriate page breaks. Either the author will specify the height, or I'll have to have other code to call something like ffmpeg or ImageMagick to get the height of the video. But that's a separate issue.
> 
> Then I figure I need to insert some "marker" in the PDF file that gives the location of the MP4 on the system which publishes the PDF.
> 
> So the piece I am asking about would be a Java program which would look through the PDF for these markers, find the MP4 for each marker, and embed the video in the PDF at that location.

Given that videos in PDF are a form of “annotation”, you might want to use a rectangle annotation as your marker. Perhaps give it a specific color.

— John

> Any thoughts on this matter are much appreciated. (I have to give an 
> estimate of effort -- for me giving estimates is the bane of computer 
> programming.)
> 
> Best regards,
> Gary
> 
> 
> -----Original Message-----
> From: Tilman Hausherr [mailto:THausherr@t-online.de]
> Sent: Wednesday, September 21, 2016 1:03 PM
> To: users@pdfbox.apache.org
> Subject: Re: Embedding video in PDF
> 
> Am 21.09.2016 um 16:23 schrieb Gary Grosso:
>> 
>> - Has anyone had any personal experience with this sort of thing? (We 
>> would be post-processing their PDF, which is created elsewhere, to 
>> insert the video at a point where we would leave some sort of 
>> local-filename marker and sufficient white space.)
> 
> I think what you want to do is to embed the video so that there is a screen area in the PDF, like embedding a youtube video - right?
> 
> Tilman
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: Embedding video in PDF

Posted by John Hewson <jo...@jahewson.com>.
> On 21 Sep 2016, at 10:15, Gary Grosso <ga...@oberontech.com> wrote:
> 
> Hi Tilman,
> 
> Yes, that is correct. And the video has to be embedded, since some end-users may not have an Internet connection. The video files they are starting with are MP4s.
> 
> I figure I have to reserve the correct amount of vertical space in the original PDF to get appropriate page breaks. Either the author will specify the height, or I'll have to have other code to call something like ffmpeg or ImageMagick to get the height of the video. But that's a separate issue.
> 
> Then I figure I need to insert some "marker" in the PDF file that gives the location of the MP4 on the system which publishes the PDF.
> 
> So the piece I am asking about would be a Java program which would look through the PDF for these markers, find the MP4 for each marker, and embed the video in the PDF at that location.

Given that videos in PDF are a form of “annotation”, you might want to use a rectangle annotation as your marker. Perhaps give it a specific color.

— John

> Any thoughts on this matter are much appreciated. (I have to give an estimate of effort -- for me giving estimates is the bane of computer programming.)
> 
> Best regards,
> Gary
> 
> 
> -----Original Message-----
> From: Tilman Hausherr [mailto:THausherr@t-online.de] 
> Sent: Wednesday, September 21, 2016 1:03 PM
> To: users@pdfbox.apache.org
> Subject: Re: Embedding video in PDF
> 
> Am 21.09.2016 um 16:23 schrieb Gary Grosso:
>> 
>> - Has anyone had any personal experience with this sort of thing? (We 
>> would be post-processing their PDF, which is created elsewhere, to 
>> insert the video at a point where we would leave some sort of 
>> local-filename marker and sufficient white space.)
> 
> I think what you want to do is to embed the video so that there is a screen area in the PDF, like embedding a youtube video - right?
> 
> Tilman
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


RE: Embedding video in PDF

Posted by Gary Grosso <ga...@oberontech.com>.
Not what I most wanted to hear ("looks very painful") but I appreciate the input.


Gary


-----Original Message-----
From: Tilman Hausherr [mailto:THausherr@t-online.de] 
Sent: Wednesday, September 21, 2016 3:31 PM
To: users@pdfbox.apache.org
Subject: Re: Embedding video in PDF

Am 21.09.2016 um 19:15 schrieb Gary Grosso:
> Hi Tilman,
>
> Yes, that is correct. And the video has to be embedded, since some end-users may not have an Internet connection. The video files they are starting with are MP4s.
>
> I figure I have to reserve the correct amount of vertical space in the original PDF to get appropriate page breaks. Either the author will specify the height, or I'll have to have other code to call something like ffmpeg or ImageMagick to get the height of the video. But that's a separate issue.
>
> Then I figure I need to insert some "marker" in the PDF file that gives the location of the MP4 on the system which publishes the PDF.
>
> So the piece I am asking about would be a Java program which would look through the PDF for these markers, find the MP4 for each marker, and embed the video in the PDF at that location.
>
> Any thoughts on this matter are much appreciated. (I have to give an 
> estimate of effort -- for me giving estimates is the bane of computer 
> programming.)

I can't answer that one... I just looked at the PDF specification and it looks very painful. The best would be that you create such a PDF file with Adobe Professional, then analyse it with PDFDebugger to see what structures are needed.

Tilman

>
> Best regards,
> Gary
>
>
> -----Original Message-----
> From: Tilman Hausherr [mailto:THausherr@t-online.de]
> Sent: Wednesday, September 21, 2016 1:03 PM
> To: users@pdfbox.apache.org
> Subject: Re: Embedding video in PDF
>
> Am 21.09.2016 um 16:23 schrieb Gary Grosso:
>> - Has anyone had any personal experience with this sort of thing? (We 
>> would be post-processing their PDF, which is created elsewhere, to 
>> insert the video at a point where we would leave some sort of 
>> local-filename marker and sufficient white space.)
> I think what you want to do is to embed the video so that there is a screen area in the PDF, like embedding a youtube video - right?
>
> Tilman
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: Embedding video in PDF

Posted by Tilman Hausherr <TH...@t-online.de>.
Am 21.09.2016 um 19:15 schrieb Gary Grosso:
> Hi Tilman,
>
> Yes, that is correct. And the video has to be embedded, since some end-users may not have an Internet connection. The video files they are starting with are MP4s.
>
> I figure I have to reserve the correct amount of vertical space in the original PDF to get appropriate page breaks. Either the author will specify the height, or I'll have to have other code to call something like ffmpeg or ImageMagick to get the height of the video. But that's a separate issue.
>
> Then I figure I need to insert some "marker" in the PDF file that gives the location of the MP4 on the system which publishes the PDF.
>
> So the piece I am asking about would be a Java program which would look through the PDF for these markers, find the MP4 for each marker, and embed the video in the PDF at that location.
>
> Any thoughts on this matter are much appreciated. (I have to give an estimate of effort -- for me giving estimates is the bane of computer programming.)

I can't answer that one... I just looked at the PDF specification and it 
looks very painful. The best would be that you create such a PDF file 
with Adobe Professional, then analyse it with PDFDebugger to see what 
structures are needed.

Tilman

>
> Best regards,
> Gary
>
>
> -----Original Message-----
> From: Tilman Hausherr [mailto:THausherr@t-online.de]
> Sent: Wednesday, September 21, 2016 1:03 PM
> To: users@pdfbox.apache.org
> Subject: Re: Embedding video in PDF
>
> Am 21.09.2016 um 16:23 schrieb Gary Grosso:
>> - Has anyone had any personal experience with this sort of thing? (We
>> would be post-processing their PDF, which is created elsewhere, to
>> insert the video at a point where we would leave some sort of
>> local-filename marker and sufficient white space.)
> I think what you want to do is to embed the video so that there is a screen area in the PDF, like embedding a youtube video - right?
>
> Tilman
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


RE: Embedding video in PDF

Posted by Gary Grosso <ga...@oberontech.com>.
Hi Tilman,

Yes, that is correct. And the video has to be embedded, since some end-users may not have an Internet connection. The video files they are starting with are MP4s.

I figure I have to reserve the correct amount of vertical space in the original PDF to get appropriate page breaks. Either the author will specify the height, or I'll have to have other code to call something like ffmpeg or ImageMagick to get the height of the video. But that's a separate issue.

Then I figure I need to insert some "marker" in the PDF file that gives the location of the MP4 on the system which publishes the PDF.

So the piece I am asking about would be a Java program which would look through the PDF for these markers, find the MP4 for each marker, and embed the video in the PDF at that location.

Any thoughts on this matter are much appreciated. (I have to give an estimate of effort -- for me giving estimates is the bane of computer programming.)

Best regards,
Gary


-----Original Message-----
From: Tilman Hausherr [mailto:THausherr@t-online.de] 
Sent: Wednesday, September 21, 2016 1:03 PM
To: users@pdfbox.apache.org
Subject: Re: Embedding video in PDF

Am 21.09.2016 um 16:23 schrieb Gary Grosso:
>
> - Has anyone had any personal experience with this sort of thing? (We 
> would be post-processing their PDF, which is created elsewhere, to 
> insert the video at a point where we would leave some sort of 
> local-filename marker and sufficient white space.)

I think what you want to do is to embed the video so that there is a screen area in the PDF, like embedding a youtube video - right?

Tilman


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: Embedding video in PDF

Posted by Tilman Hausherr <TH...@t-online.de>.
Am 21.09.2016 um 16:23 schrieb Gary Grosso:
> Hi PDFBoxers,
>
> A customer wants to embed MP4 video in their PDF. (They want to be able to view with an offline iPad.)
>
> I see info in the cookbook for 1.8 (https://pdfbox.apache.org/1.8/cookbook/workingwithattachments.html) and the example at https://svn.apache.org/repos/asf/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/EmbeddedFiles.java. Also Tilman's reply in 2014:
>
> ~~~~~~
> Yes, please look at the example
> examples\src\main\java\org\apache\pdfbox\examples\pdmodel\EmbeddedFiles.java
> or
> https://svn.apache.org/repos/asf/pdfbox/branches/1.8/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/EmbeddedFiles.java
> to see how to embed a file. There is no restriction on the type AFAIK.
>
> Tilman
> ~~~~~~
>
> My questions are:
>
> - Is the above info relevant/accurate if using PDFBox 2.0?
>
> - Has anyone had any personal experience with this sort of thing? (We would be post-processing their PDF, which is created elsewhere, to insert the video at a point where we would leave some sort of local-filename marker and sufficient white space.)

I think what you want to do is to embed the video so that there is a 
screen area in the PDF, like embedding a youtube video - right?

Tilman



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: Embedding video in PDF

Posted by Maruan Sahyoun <sa...@fileaffairs.de>.
Hi,

> Am 21.09.2016 um 16:23 schrieb Gary Grosso <ga...@oberontech.com>:
> 
> Hi PDFBoxers,
> 
> A customer wants to embed MP4 video in their PDF. (They want to be able to view with an offline iPad.)
> 
> I see info in the cookbook for 1.8 (https://pdfbox.apache.org/1.8/cookbook/workingwithattachments.html) and the example at https://svn.apache.org/repos/asf/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/EmbeddedFiles.java. Also Tilman's reply in 2014:
> 
> ~~~~~~
> Yes, please look at the example
> examples\src\main\java\org\apache\pdfbox\examples\pdmodel\EmbeddedFiles.java
> or
> https://svn.apache.org/repos/asf/pdfbox/branches/1.8/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/EmbeddedFiles.java
> to see how to embed a file. There is no restriction on the type AFAIK.
> 
> Tilman
> ~~~~~~
> 
> My questions are:
> 
> - Is the above info relevant/accurate if using PDFBox 2.0?

it's still relevant. The version for 2.0.3 is at https://svn.apache.org/repos/asf/pdfbox/tags/2.0.3/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/EmbeddedFiles.java

BR
Maruan

> 
> - Has anyone had any personal experience with this sort of thing? (We would be post-processing their PDF, which is created elsewhere, to insert the video at a point where we would leave some sort of local-filename marker and sufficient white space.)
> 
> Thanks,
> Gary
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org