ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* multimedia PDF in ConTeXt
@ 2021-07-30 18:53 Pablo Rodriguez via ntg-context
  2021-07-30 21:57 ` Michal Vlasák via ntg-context
  2021-07-30 23:08 ` Michal Vlasák via ntg-context
  0 siblings, 2 replies; 5+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2021-07-30 18:53 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Pablo Rodriguez

Hi Michal and Hans,

many thanks for your patch to fix multimedia objects in PDF and your
extremely interesting and in-depth explanation about multimedia in PDF.
Many thanks to Hans for the release of an updated latest with also
updated documentation.

Although I don’t read Czech, just out of curiosity, is your bachelor
thesis available on the net, Michal? Thanks to theses.cz, I found
https://is.muni.cz/th/t8qpp/DP_Vlasak_Michal_2015.pdf (only a name
coincidence, I guess).

Using your sample, I have two questions:

  \starttext
  \setupinteraction[state=start]

  \useexternalrendering[myvideo][video/mp4][video.mp4][embed=yes]

  \definerenderingwindow[myrenderingwindow]
    [width=\textwidth, height=\textwidth]

  \placerenderingwindow[myrenderingwindow][myvideo]
  \stoptext

Is there no way to have the video as an embedded file in the PDF
document? (I mean, that the file is listed when the attachment panel is
displayed.)

The second question is addressed to Hans: would it be possible that
\placerenderingwindow could have another option and text as in \framed?
A workaround would be to add a layer, but too complex only for adding
usage instructions for the media usage.

Many thanks for your help,

Pablo
--
http://www.ousia.tk
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: multimedia PDF in ConTeXt
  2021-07-30 18:53 multimedia PDF in ConTeXt Pablo Rodriguez via ntg-context
@ 2021-07-30 21:57 ` Michal Vlasák via ntg-context
  2021-07-31  9:36   ` Pablo Rodriguez via ntg-context
  2021-07-30 23:08 ` Michal Vlasák via ntg-context
  1 sibling, 1 reply; 5+ messages in thread
From: Michal Vlasák via ntg-context @ 2021-07-30 21:57 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Michal Vlasák, Pablo Rodriguez

On Fri Jul 30, 2021 at 8:53 PM CEST, Pablo Rodriguez via ntg-context wrote:
> Hi Michal and Hans,
>
> many thanks for your patch to fix multimedia objects in PDF and your
> extremely interesting and in-depth explanation about multimedia in PDF.
> Many thanks to Hans for the release of an updated latest with also
> updated documentation.
>
> Although I don’t read Czech, just out of curiosity, is your bachelor
> thesis available on the net, Michal? Thanks to theses.cz, I found
> https://is.muni.cz/th/t8qpp/DP_Vlasak_Michal_2015.pdf (only a name
> coincidence, I guess).

Sorry, should have shared the link at the first place.

https://dspace.cvut.cz/handle/10467/95065

(PLNY_TEXT) links to the full text.

(PRILOHA) is almost all files I had for the thesis. Most notably the
testing files I used. (Some were handcoded, so no sources, but these
should be readable in text editors).

> Using your sample, I have two questions:
>
> \starttext
> \setupinteraction[state=start]
>
> \useexternalrendering[myvideo][video/mp4][video.mp4][embed=yes]
>
> \definerenderingwindow[myrenderingwindow]
> [width=\textwidth, height=\textwidth]
>
> \placerenderingwindow[myrenderingwindow][myvideo]
> \stoptext
>
> Is there no way to have the video as an embedded file in the PDF
> document? (I mean, that the file is listed when the attachment panel is
> displayed.)

Currently, only attachments are added as "embedded files" (either as
"hidden", ending up in /EmbeddedFiles, or as "annotation" ending up as
/FileAttachment annotation).

Maybe "codeinjections.embedfile" can have the option to force the
reference, so that the file also ends up in /EmbeddedFiles? Should it be
default for all \externalrenderings?

My try:

https://github.com/contextgarden/context-mirror/commit/681c36d0ecfd30c05ed588eb0f37a06dd19f3492

(the full file can be located by clicking on the three dots after the
file name, then "View file" and then "Raw", resulting in:

https://github.com/contextgarden/context-mirror/blob/681c36d0ecfd30c05ed588eb0f37a06dd19f3492/tex/context/base/mkxl/lpdf-wid.lmt,

Patch can be obtained by adding .diff to the URL:

https://github.com/contextgarden/context-mirror/commit/681c36d0ecfd30c05ed588eb0f37a06dd19f3492.diff

I will probably not keep the commit on GitHub forever, it just seems
like a nice way to send quick patches -- it is visual and allows full
file/patch download. So this time full patch also included below for
future reference.)

Michal


--- a/tex/context/base/mkxl/lpdf-wid.lmt
+++ b/tex/context/base/mkxl/lpdf-wid.lmt
@@ -259,7 +259,7 @@ local function flushembeddedfiles()
         for tag, reference in sortedhash(filestreams) do
             if not reference then
                 report_attachment("unreferenced file, tag %a",tag)
-            elseif referenced[tag] == "hidden" then
+            elseif referenced[tag] == "hidden" or referenced[tag] == "forced" then
                 e[#e+1] = pdfstring(tag)
                 e[#e+1] = reference -- already a reference
                 f[#f+1] = reference -- collect all file description references
@@ -369,6 +369,9 @@ function codeinjections.embedfile(specification)
         }
         local r = pdfreference(pdfflushobject(d))
         filestreams[hash] = r
+        if specification.forcereference == true then
+            referenced[hash] = "forced"
+        end
         return r
     end
 end
@@ -705,9 +708,10 @@ local function insertrendering(specification)
             descriptor = pdfreference(pdfflushobject(descriptor))
         elseif option[v_embed] then
             descriptor = codeinjections.embedfile {
-                file     = filename,
-                mimetype = mimetype, -- yes or no
-                compress = false,
+                file           = filename,
+                mimetype       = mimetype, -- yes or no
+                compress       = false,
+                forcereference = true,
             }
         end
         local clip = pdfdictionary {
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: multimedia PDF in ConTeXt
  2021-07-30 18:53 multimedia PDF in ConTeXt Pablo Rodriguez via ntg-context
  2021-07-30 21:57 ` Michal Vlasák via ntg-context
@ 2021-07-30 23:08 ` Michal Vlasák via ntg-context
  2021-07-31  9:45   ` Pablo Rodriguez via ntg-context
  1 sibling, 1 reply; 5+ messages in thread
From: Michal Vlasák via ntg-context @ 2021-07-30 23:08 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Michal Vlasák, Pablo Rodriguez

On Fri Jul 30, 2021 at 8:53 PM CEST, Pablo Rodriguez via ntg-context wrote:
> Hi Michal and Hans,
>
> many thanks for your patch to fix multimedia objects in PDF and your
> extremely interesting and in-depth explanation about multimedia in PDF.
> Many thanks to Hans for the release of an updated latest with also
> updated documentation.

By the way, Pablo, your issue
https://www.mail-archive.com/ntg-context@ntg.nl/msg88204.html was also
solved in the last upload. Unfortunately it will probably not help you,
because Acrobat no longer supports this.

    \useexternalsoundtrack
      [myaudio][audio.mp3]
    
    \checksoundtrack{myaudio}
    
    \goto{PLAY SOUND}[StartSound{myaudio}]


But, you can use renderings instead:

    \useexternalrendering[myaudiorendering]
      [audio/mp3][audio.mp3][embed=yes]
    
    \definerenderingwindow[audiowindow]
      [width=0sp, height=0sp]
    
    \definelayer[resources]
    \setupbackgrounds[page][background=resources]
    \setlayer[resources]{\placerenderingwindow[audiowindow][myaudiorendering]}
    
    \goto{PLAY SOUND}[StartRendering{myaudiorendering}]


This is basically the example from "/back-swf.mkiv". Works in Acrobat.
And one can use either of the three possible file methods (embedded,
external, URL), not just external files. The layer is so that the empty
frame doesn't interfere with normal page content. No frame is drawn when
both dimensions are 0, not sure if that is a behaviour one can take as
granted. But currenntly the dimensions can't be zero.

Hans, I would omit the check for 0 dimensions of rendering window (as
already noted in the source, it is useful for sound). See patch below.

Michal Vlasák

--- a/tex/context/base/mkxl/lpdf-wid.lmt
+++ b/tex/context/base/mkxl/lpdf-wid.lmt
@@ -655,9 +655,6 @@ local function insertrenderingwindow(specification)
     }
     local width = specification.width or 0
     local height = specification.height or 0
-    if height == 0 or width == 0 then
-        -- todo: sound needs no window
-    end
     context(nodeinjections.annotation(width,height,0,d(),r)) -- save ref
     return pdfreference(r)
 end
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: multimedia PDF in ConTeXt
  2021-07-30 21:57 ` Michal Vlasák via ntg-context
@ 2021-07-31  9:36   ` Pablo Rodriguez via ntg-context
  0 siblings, 0 replies; 5+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2021-07-31  9:36 UTC (permalink / raw)
  To: ntg-context; +Cc: Pablo Rodriguez

On 7/30/21 11:57 PM, Michal Vlasák via ntg-context wrote:
> On Fri Jul 30, 2021 at 8:53 PM CEST, Pablo Rodriguez via ntg-context wrote:
>> [...]
>> Although I don’t read Czech, just out of curiosity, is your bachelor
>> thesis available on the net, Michal? Thanks to theses.cz, I found
>> https://is.muni.cz/th/t8qpp/DP_Vlasak_Michal_2015.pdf (only a name
>> coincidence, I guess).
>
> Sorry, should have shared the link at the first place.
>
> https://dspace.cvut.cz/handle/10467/95065

Many thanks for your fast reply and the link to your thesis, Michal.

>> [...]
>> Is there no way to have the video as an embedded file in the PDF
>> document? (I mean, that the file is listed when the attachment panel is
>> displayed.)
>
> Currently, only attachments are added as "embedded files" (either as
> "hidden", ending up in /EmbeddedFiles, or as "annotation" ending up as
> /FileAttachment annotation).
>
> Maybe "codeinjections.embedfile" can have the option to force the
> reference, so that the file also ends up in /EmbeddedFiles? Should it be
> default for all \externalrenderings?
> [...]
> --- a/tex/context/base/mkxl/lpdf-wid.lmt
> +++ b/tex/context/base/mkxl/lpdf-wid.lmt
> [...]

Many thanks for the patch.

It would be also great to have an option not to list some files as
embedded (adding a option "list" to "\useexternalrendering" such as in
"\useexternalrendering[myvideo][video/mp4][video.mp4][embed=yes, list=no]").

Being the default to yes, I’m thinking of cases where there is a risk
distributing the multimedia file without the embedding document, because
of the lack of context (no pun indented)

Many thanks for your help,

Pablo
--
http://www.ousia.tk
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: multimedia PDF in ConTeXt
  2021-07-30 23:08 ` Michal Vlasák via ntg-context
@ 2021-07-31  9:45   ` Pablo Rodriguez via ntg-context
  0 siblings, 0 replies; 5+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2021-07-31  9:45 UTC (permalink / raw)
  To: Michal Vlasák via ntg-context; +Cc: Pablo Rodriguez

On 7/31/21 1:08 AM, Michal Vlasák via ntg-context wrote:
> [...]
> By the way, Pablo, your issue
> https://www.mail-archive.com/ntg-context@ntg.nl/msg88204.html was also
> solved in the last upload. Unfortunately it will probably not help you,
> because Acrobat no longer supports this.
> [...]
> But, you can use renderings instead:
>
>     \useexternalrendering[myaudiorendering]
>       [audio/mp3][audio.mp3][embed=yes]
>
>     \definerenderingwindow[audiowindow]
>       [width=0sp, height=0sp]
>
>     \definelayer[resources]
>     \setupbackgrounds[page][background=resources]
>     \setlayer[resources]{\placerenderingwindow[audiowindow][myaudiorendering]}
>
>     \goto{PLAY SOUND}[StartRendering{myaudiorendering}]
>
> This is basically the example from "/back-swf.mkiv". Works in Acrobat.
> And one can use either of the three possible file methods (embedded,
> external, URL), not just external files. The layer is so that the empty
> frame doesn't interfere with normal page content. No frame is drawn when
> both dimensions are 0, not sure if that is a behaviour one can take as
> granted. But currenntly the dimensions can't be zero.

Many thanks for your code update, Michal.

I’m extremely interested in investigating the possibilities this opens.

But I’m afraid that I will have other things to do first. It will take
me months to come back to this again.

> Hans, I would omit the check for 0 dimensions of rendering window (as
> already noted in the source, it is useful for sound). See patch below.

Many thanks for the patch and for your help,

Pablo
--
http://www.ousia.tk
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-07-31  9:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-30 18:53 multimedia PDF in ConTeXt Pablo Rodriguez via ntg-context
2021-07-30 21:57 ` Michal Vlasák via ntg-context
2021-07-31  9:36   ` Pablo Rodriguez via ntg-context
2021-07-30 23:08 ` Michal Vlasák via ntg-context
2021-07-31  9:45   ` Pablo Rodriguez via ntg-context

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).