Re: [NTG-context] JavaScript in multimedia PDF

2021-08-11 Thread Michal Vlasák via ntg-context
On Thu Aug 12, 2021 at 12:55 AM CEST, Hans Hagen via ntg-context wrote:
> Hi
>
> >  -Type = pdfconstant(MediaPermissions),
> >  +Type = pdfconstant("MediaPermissions"),
> That's an interesting one ... easilly goes unnoticed ... thanks

To put credit where its due, this was Pablo's find.

Indeed very subtle, I didn't notice at all, and PDF viewers also
probably mostly ignore these "/Type"s.

Michal
___
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
___


Re: [NTG-context] JavaScript in multimedia PDF

2021-08-11 Thread Hans Hagen via ntg-context

Hi


 -Type = pdfconstant(MediaPermissions),
 +Type = pdfconstant("MediaPermissions"),

That's an interesting one ... easilly goes unnoticed ... thanks

Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-
___
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
___


Re: [NTG-context] JavaScript in multimedia PDF

2021-08-11 Thread Michal Vlasák via ntg-context
More context is in previous messages, but here is the patch for ConTeXt
to make scripting multimedia possible:

--- a/tex/context/base/mkxl/lpdf-wid.lmt
+++ b/tex/context/base/mkxl/lpdf-wid.lmt
@@ -649,6 +649,7 @@ local function insertrenderingwindow(specification)
 Subtype = pdfconstant("Screen"),
 P   = pdfreference(pdfpagereference(page)),
 A   = a, -- needed in order to make the annotation clickable 
(i.e. don't bark)
+T   = pdfunicode(label), -- title (for JS)
 Border  = bs,
 C   = bc,
 AA  = actions,
@@ -693,7 +694,7 @@ local function insertrendering(specification)
  -- }
  -- }
 local parameters = pdfdictionary {
-Type = pdfconstant(MediaPermissions),
+Type = pdfconstant("MediaPermissions"),
 TF   = pdfstring("TEMPALWAYS"), -- TEMPNEVER TEMPEXTRACT 
TEMPACCESS TEMPALWAYS / needed for acrobat/wmp
 }
 local descriptor = pdfdictionary {
@@ -723,7 +724,7 @@ local function insertrendering(specification)
 local rendition = pdfdictionary {
 Type = pdfconstant("Rendition"),
 S= pdfconstant("MR"),
-N= label,
+N= pdfunicode(label),
 C= pdfreference(pdfflushobject(clip)),
 }
 mf[label] = pdfreference(pdfflushobject(rendition))
@@ -761,6 +762,20 @@ function codeinjections.processrendering(label)
 end
 end

+-- needed mapping for access from JS
+local function flushrenderings()
+if next(mf) then
+local r = pdfarray()
+for label, reference in sortedhash(mf) do
+r[#r+1] = pdfunicode(label)
+r[#r+1] = reference -- already a reference
+end
+
lpdf.addtonames("Renditions",pdfreference(pdfflushobject(pdfdictionary{ Names = 
r })))
+end
+end
+
+lpdf.registerdocumentfinalizer(flushrenderings,"renderings")
+
 function codeinjections.insertrenderingwindow(specification)
 local label = specification.label
 codeinjections.processrendering(label)

The patch is also be available here
https://github.com/vlasakm/context-mirror/commit/99f81beae0d13f1aecc20be187ada9eb88a2aa68
until it is applied (for full file download, which is available under
the three dots next to the file name).

The created Screen annotation will be given the title, that corresponds
to the second \placerenderingwindow parameter. So here:

\definerenderingwindow[soundplace]
  [width=0pt, height=0pt]

\useexternalrendering[mainsound][audio/mp3][sound.mp3][embed=yes]

\placerenderingwindow[soundplace][mainsound]

both the screen annotation and rendition are available under the name
"mainsound". The name "soundplace" can be anything (even "mainsound"),
it doesn't propagate to the PDF file in any way.

And here is the patch required to make Pablo's example work:

--- a/pablo.tex
+++ b/pablo.tex
@@ -7,8 +7,10 @@
 function GoToFirstSlide(label) {
 this.pageNum = 0 ;
 var rendition = this.media.getRendition(label) ;
+var screen = this.media.getAnnot({nPage: 0, cAnnotTitle: label}) ;
 var player = app.media.openPlayer({
 rendition: rendition,
+annot: screen,
   });
 }

The second possibility I proposed previously is not as general, and
implementing it is not worth, until it is really needed (which I presume
won't happen).

Michal Vlasák
___
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
___


Re: [NTG-context] JavaScript in multimedia PDF

2021-08-11 Thread Pablo Rodriguez via ntg-context
On 8/10/21 11:52 PM, Michal Vlasák via ntg-context wrote:
> On Mon Aug 9, 2021 at 8:32 AM CEST, Pablo Rodriguez via ntg-context wrote:
> [...]
>> I get exactly the same results: screen object, but null rendition.
>>
>> I have no idea what it is needed here.
>
> Sorry, in the last mail I forgot to mention one idea I had. But now I
> had time to try it, and in the end came up with three different ways to
> get it working (at least the multimedia part, didn't test the rest).

Many thanks for your in-depth reply and explanation, Michal.

Since there are some related issues, I think it is better to discuss it
in private.

Many thanks for your help again,

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
___


Re: [NTG-context] Create an enumeration style

2021-08-11 Thread Otared Kavian via ntg-context
> On 11 Aug 2021, at 10:19, Thomas A. Schmitz via ntg-context 
>  wrote:
> 
> 
>> On 11. Aug 2021, at 10:09, Otared Kavian via ntg-context 
>>  wrote:
>> 
>> Thanks for the example and the fix, but I would rather think that the « 
>> french » part of ordinals should be
>> 
>>  french = function(n)
>>  if n == 1 then
>>  return « er"
>>  else
>>   return « ème"
>>  end
>>  end,
> 
> Except if you have something like “1ère image”… Ah, languages are so messy 
> (no pun with recent events in Paris intended).
> 
> Thomas

Sure… But then maybe it is possible to define one’s own « ordinals.french » for 
messy cases :-) 
___
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
___


Re: [NTG-context] Create an enumeration style

2021-08-11 Thread Fabrice Couvreur via ntg-context
I forgot this : how to reduce the font size for the exponents "er", "e" ?
Thanks
Fabrice

Le mer. 11 août 2021 à 12:41, Fabrice Couvreur 
a écrit :

> Hi Wolfgang,
> Many thanks
> Fabrice
>
> Le mer. 11 août 2021 à 10:23, Hans Hagen via ntg-context <
> ntg-context@ntg.nl> a écrit :
>
>> On 8/11/2021 10:09 AM, Otared Kavian via ntg-context wrote:
>> >
>> >
>> >> On 9 Aug 2021, at 18:10, Wolfgang Schuster via ntg-context <
>> ntg-context@ntg.nl> wrote:
>> >> (…)
>> >> core-con.lua (line 1155):
>> >>
>> >> local ordinals = {
>> >>  [...]
>> >>  french = function(n)
>> >>  if n == 1 then
>> >>  return "er"
>> >> +   else
>> >> +   return "e"
>> >>  end
>> >>  end,
>> >> }
>> >
>> > Hi Wolfgang,
>> >
>> > Thanks for the example and the fix, but I would rather think that the «
>> french » part of ordinals should be
>> >
>> >   french = function(n)
>> >   if n == 1 then
>> >   return « er"
>> >   else
>> >return « ème"
>> >   end
>> >   end,
>> >
>> > Now if this were not accepted as a fix in core-con.lua, is there a way
>> for a user to change the default to the above choice in his document ?
>>
>> it is no problem to fix if you all can agree on what/how to fix ...
>>
>> Hans
>>
>>
>> -
>>Hans Hagen | PRAGMA ADE
>>Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>> tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
>> -
>>
>> ___
>> 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
>>
>> ___
>>
>
___
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
___


Re: [NTG-context] Create an enumeration style

2021-08-11 Thread Fabrice Couvreur via ntg-context
Hi Wolfgang,
Many thanks
Fabrice

Le mer. 11 août 2021 à 10:23, Hans Hagen via ntg-context 
a écrit :

> On 8/11/2021 10:09 AM, Otared Kavian via ntg-context wrote:
> >
> >
> >> On 9 Aug 2021, at 18:10, Wolfgang Schuster via ntg-context <
> ntg-context@ntg.nl> wrote:
> >> (…)
> >> core-con.lua (line 1155):
> >>
> >> local ordinals = {
> >>  [...]
> >>  french = function(n)
> >>  if n == 1 then
> >>  return "er"
> >> +   else
> >> +   return "e"
> >>  end
> >>  end,
> >> }
> >
> > Hi Wolfgang,
> >
> > Thanks for the example and the fix, but I would rather think that the «
> french » part of ordinals should be
> >
> >   french = function(n)
> >   if n == 1 then
> >   return « er"
> >   else
> >return « ème"
> >   end
> >   end,
> >
> > Now if this were not accepted as a fix in core-con.lua, is there a way
> for a user to change the default to the above choice in his document ?
>
> it is no problem to fix if you all can agree on what/how to fix ...
>
> Hans
>
>
> -
>Hans Hagen | PRAGMA ADE
>Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
> tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
> -
>
> ___
> 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
>
> ___
>
___
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
___


Re: [NTG-context] Create an enumeration style

2021-08-11 Thread Hans Hagen via ntg-context

On 8/11/2021 10:09 AM, Otared Kavian via ntg-context wrote:




On 9 Aug 2021, at 18:10, Wolfgang Schuster via ntg-context  
wrote:
(…)
core-con.lua (line 1155):

local ordinals = {
 [...]
 french = function(n)
 if n == 1 then
 return "er"
+   else
+   return "e"
 end
 end,
}


Hi Wolfgang,

Thanks for the example and the fix, but I would rather think that the « french 
» part of ordinals should be

french = function(n)
if n == 1 then
return « er"
else
 return « ème"
end
end,

Now if this were not accepted as a fix in core-con.lua, is there a way for a 
user to change the default to the above choice in his document ?


it is no problem to fix if you all can agree on what/how to fix ...

Hans


-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-
___
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
___


Re: [NTG-context] Create an enumeration style

2021-08-11 Thread Thomas A. Schmitz via ntg-context

> On 11. Aug 2021, at 10:09, Otared Kavian via ntg-context  
> wrote:
> 
> Thanks for the example and the fix, but I would rather think that the « 
> french » part of ordinals should be
> 
>   french = function(n)
>   if n == 1 then
>   return « er"
>   else
>return « ème"
>   end
>   end,

Except if you have something like “1ère image”… Ah, languages are so messy (no 
pun with recent events in Paris intended).

Thomas
___
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
___


Re: [NTG-context] Create an enumeration style

2021-08-11 Thread Otared Kavian via ntg-context


> On 9 Aug 2021, at 18:10, Wolfgang Schuster via ntg-context 
>  wrote:
> (…)
> core-con.lua (line 1155):
> 
> local ordinals = {
> [...]
> french = function(n)
> if n == 1 then
> return "er"
> +   else
> +   return "e"
> end
> end,
> }

Hi Wolfgang,

Thanks for the example and the fix, but I would rather think that the « french 
» part of ordinals should be

french = function(n)
if n == 1 then
return « er"
else
 return « ème"
end
end,

Now if this were not accepted as a fix in core-con.lua, is there a way for a 
user to change the default to the above choice in his document ?

Best regards: Otared
___
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
___