ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] Transparency in external PDFs does not work
@ 2024-06-17 15:07 Gerion Entrup
  2024-06-17 18:38 ` [NTG-context] " Pablo Rodriguez via ntg-context
  2024-06-17 21:50 ` Hans Hagen
  0 siblings, 2 replies; 7+ messages in thread
From: Gerion Entrup @ 2024-06-17 15:07 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1.1: Type: text/plain, Size: 630 bytes --]

Hi,

I'm using LaTeX-Beamer and TikZ for figure typesetting.
With this combination, it is easy to combine Beamer's animation system with TikZ transparency feature.
This way, the resulting PDFs contain the full graphic on every page, but parts of it are invisible for a specific page.
One of these files is attached as an example.

The problem is to embed these PDFs into a ConTeXt document.
For example, this MWE seems to not respect transparency (see mwe.pdf):
```
\starttext
\externalfigure[fig.pdf][page=1]
\stoptext
```

I use Okular/Poppler as PDF viewer.
Can I fix this somehow or is it a bug somewhere deeper?

Best
Gerion

[-- Attachment #1.1.2: fig.pdf --]
[-- Type: application/pdf, Size: 7180 bytes --]

[-- Attachment #1.1.3: mwe.pdf --]
[-- Type: application/pdf, Size: 8419 bytes --]

[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

[-- Attachment #2: Type: text/plain, Size: 511 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: Transparency in external PDFs does not work
  2024-06-17 15:07 [NTG-context] Transparency in external PDFs does not work Gerion Entrup
@ 2024-06-17 18:38 ` Pablo Rodriguez via ntg-context
  2024-06-17 21:50 ` Hans Hagen
  1 sibling, 0 replies; 7+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2024-06-17 18:38 UTC (permalink / raw)
  To: ntg-context; +Cc: Pablo Rodriguez

On 6/17/24 17:07, Gerion Entrup wrote:
> [...]
> I use Okular/Poppler as PDF viewer.
> Can I fix this somehow or is it a bug somewhere deeper?

Hi Gerion,

I can confirm your issue.

It seems to be an issue with LMTX.

LuaTeX has no problem with the file.

Just in case it helps,

Pablo

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: Transparency in external PDFs does not work
  2024-06-17 15:07 [NTG-context] Transparency in external PDFs does not work Gerion Entrup
  2024-06-17 18:38 ` [NTG-context] " Pablo Rodriguez via ntg-context
@ 2024-06-17 21:50 ` Hans Hagen
  2024-06-18  7:54   ` Gerion Entrup
  1 sibling, 1 reply; 7+ messages in thread
From: Hans Hagen @ 2024-06-17 21:50 UTC (permalink / raw)
  To: ntg-context

[-- Attachment #1: Type: text/plain, Size: 1148 bytes --]

On 6/17/2024 5:07 PM, Gerion Entrup wrote:
> Hi,
> 
> I'm using LaTeX-Beamer and TikZ for figure typesetting.
> With this combination, it is easy to combine Beamer's animation system with TikZ transparency feature.
> This way, the resulting PDFs contain the full graphic on every page, but parts of it are invisible for a specific page.
> One of these files is attached as an example.
> 
> The problem is to embed these PDFs into a ConTeXt document.
> For example, this MWE seems to not respect transparency (see mwe.pdf):
> ```
> \starttext
> \externalfigure[fig.pdf][page=1]
> \stoptext
> ```
> 
> I use Okular/Poppler as PDF viewer.
> Can I fix this somehow or is it a bug somewhere deeper?
next time check the file that you include ... it has no transparency (it 
has zero values)

the attached works ok

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

[-- Attachment #2: gif.tex --]
[-- Type: text/plain, Size: 221 bytes --]


\starttext
    \startTEXpage[offset=1pt]
        \colored[a=1,t=.5,r=1]{\framed{test 1}}
    \stopTEXpage
    \startTEXpage[offset=1pt]
        \colored[a=1,t=.5,b=1]{\framed{test 2}}
    \stopTEXpage
\stoptext

[-- Attachment #3: test.tex --]
[-- Type: text/plain, Size: 285 bytes --]

\nopdfcompression

\starttext
%     \externalfigure[fig.pdf][page=1]
    \externalfigure[gif.pdf][page=1]
    \externalfigure[gif.pdf][page=2]
    \startoverlay
        {\externalfigure[gif.pdf][page=1]}
        {\externalfigure[gif.pdf][page=2]}
    \stopoverlay
\stoptext

[-- Attachment #4: Type: text/plain, Size: 511 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: Transparency in external PDFs does not work
  2024-06-17 21:50 ` Hans Hagen
@ 2024-06-18  7:54   ` Gerion Entrup
  2024-06-19  7:50     ` Hans Hagen
  0 siblings, 1 reply; 7+ messages in thread
From: Gerion Entrup @ 2024-06-18  7:54 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1.1: Type: text/plain, Size: 1360 bytes --]

Am Montag, 17. Juni 2024, 23:50:16 MESZ schrieb Hans Hagen:
> On 6/17/2024 5:07 PM, Gerion Entrup wrote:
> > Hi,
> > 
> > I'm using LaTeX-Beamer and TikZ for figure typesetting.
> > With this combination, it is easy to combine Beamer's animation system with TikZ transparency feature.
> > This way, the resulting PDFs contain the full graphic on every page, but parts of it are invisible for a specific page.
> > One of these files is attached as an example.
> > 
> > The problem is to embed these PDFs into a ConTeXt document.
> > For example, this MWE seems to not respect transparency (see mwe.pdf):
> > ```
> > \starttext
> > \externalfigure[fig.pdf][page=1]
> > \stoptext
> > ```
> > 
> > I use Okular/Poppler as PDF viewer.
> > Can I fix this somehow or is it a bug somewhere deeper?
> next time check the file that you include ... it has no transparency (it 
> has zero values)

I don't really have a clue about the PDF standard. It is made with the TikZ opacity flag therefore I thought it controls the transparency.
See the attached tex file to reproduce fig.pdf (compilation with `latexmk -pdflua fig.tex`).

I also found a workaround. It is possible to import fig.pdf with Inkscape and export just the correct page as PDF again and embed that in ConTeXt:
```
inkscape --export-page=1 fig.pdf --export-type=pdf --export-filename=1.pdf
```

Gerion




[-- Attachment #1.1.2: fig.tex --]
[-- Type: text/x-tex, Size: 1126 bytes --]

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{fit}

\usepackage[active, tightpage]{preview}
\PreviewEnvironment{tikzpicture}

% taken from https://github.com/luhsra/texmf/blob/main/tex/latex/beamertools/beamertools.sty
\tikzset{
	onslide/.code args={<#1>#2}{%
		\only<#1>{\pgfkeysalso{#2}}
	},
	alt/.code args={<#1>#2#3}{%
		\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}
	},
	global opacity/.style={
		opacity=#1,
		text opacity=#1,
		every shadow/.append style={opacity=#1},
		every on layer/.append style={opacity=#1},
		every node/.append style={opacity=#1},
		prefix after command={\pgfextra{\tikzset{every pin/.style={opacity=#1},
		every pin edge/.style={opacity=#1},
		every label/.style={opacity=#1}}}},
	},
	invisible/.style={global opacity=0},
	visible/.style={global opacity=1},
	visible on/.style={alt=#1{}{invisible}},
	invisible on/.style={alt=#1{invisible}{}},
}

\begin{document}
	\begin{frame}
		\begin{tikzpicture}
			\node[draw, visible on=<1>] (fp) {First Page};
			\node[draw, visible on=<2>] (sp) {Second Page};
			\node[draw, fit=(fp)(sp)] {};
		\end{tikzpicture}
	\end{frame}

\end{document}

[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

[-- Attachment #2: Type: text/plain, Size: 511 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: Transparency in external PDFs does not work
  2024-06-18  7:54   ` Gerion Entrup
@ 2024-06-19  7:50     ` Hans Hagen
  2024-06-21 12:41       ` Gerion Entrup
  0 siblings, 1 reply; 7+ messages in thread
From: Hans Hagen @ 2024-06-19  7:50 UTC (permalink / raw)
  To: ntg-context

On 6/18/2024 9:54 AM, Gerion Entrup wrote:
> Am Montag, 17. Juni 2024, 23:50:16 MESZ schrieb Hans Hagen:
>> On 6/17/2024 5:07 PM, Gerion Entrup wrote:
>>> Hi,
>>>
>>> I'm using LaTeX-Beamer and TikZ for figure typesetting.
If you use that kind of simple graphics, you can avoid this transparency 
hacking by using metafun:

\setupbodyfont[dejavu]

\starttext

\startuseMPgraphic{test}
     pickup pencircle scaled 2mm ;
     draw fullcircle scaled 3cm withcolor darkred  withstacking 1 ;
     draw fullcircle scaled 2cm withcolor darkblue withstacking 2 ;
     draw textext("one")   withcolor darkgreen withstacking 11 ;
     draw textext("two")   withcolor darkgreen withstacking 12 ;
     draw textext("three") withcolor darkgreen withstacking 13 ;
\stopuseMPgraphic

\startTEXpage[offset=.25ts]
     \useMPgraphic{test}{stacking={1,11}}
\stopTEXpage

\startTEXpage[offset=.25ts]
     \useMPgraphic{test}{stacking={2,12}}
\stopTEXpage

\startTEXpage[offset=.25ts]
     \useMPgraphic{test}{stacking={1,2,13}}
\stopTEXpage

\stoptext

It's an already old feature but probably not that well known. If needed 
I can make something similar at the tex end.

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 / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: Transparency in external PDFs does not work
  2024-06-19  7:50     ` Hans Hagen
@ 2024-06-21 12:41       ` Gerion Entrup
  2024-06-21 14:24         ` Hans Hagen via ntg-context
  0 siblings, 1 reply; 7+ messages in thread
From: Gerion Entrup @ 2024-06-21 12:41 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 1693 bytes --]

Am Mittwoch, 19. Juni 2024, 09:50:33 MESZ schrieb Hans Hagen:
> On 6/18/2024 9:54 AM, Gerion Entrup wrote:
> > Am Montag, 17. Juni 2024, 23:50:16 MESZ schrieb Hans Hagen:
> >> On 6/17/2024 5:07 PM, Gerion Entrup wrote:
> >>> Hi,
> >>>
> >>> I'm using LaTeX-Beamer and TikZ for figure typesetting.
> If you use that kind of simple graphics, you can avoid this transparency 
> hacking by using metafun:
> 
> \setupbodyfont[dejavu]
> 
> \starttext
> 
> \startuseMPgraphic{test}
>      pickup pencircle scaled 2mm ;
>      draw fullcircle scaled 3cm withcolor darkred  withstacking 1 ;
>      draw fullcircle scaled 2cm withcolor darkblue withstacking 2 ;
>      draw textext("one")   withcolor darkgreen withstacking 11 ;
>      draw textext("two")   withcolor darkgreen withstacking 12 ;
>      draw textext("three") withcolor darkgreen withstacking 13 ;
> \stopuseMPgraphic
> 
> \startTEXpage[offset=.25ts]
>      \useMPgraphic{test}{stacking={1,11}}
> \stopTEXpage
> 
> \startTEXpage[offset=.25ts]
>      \useMPgraphic{test}{stacking={2,12}}
> \stopTEXpage
> 
> \startTEXpage[offset=.25ts]
>      \useMPgraphic{test}{stacking={1,2,13}}
> \stopTEXpage
> 
> \stoptext
> 
> It's an already old feature but probably not that well known. If needed 
> I can make something similar at the tex end.
> 
> Hans

Thank you for the example, but learning metafun is another chapter and the
graphics are much more complicated than the minimal example given.

I saw that you pushed an updated version that fixes the bug [1]. Thank you!

Gerion

[1] https://github.com/contextgarden/context/commit/0bcdd3ce47a406ed7852724504e3efe28bc2d9e1#diff-603950e83d66ef32e79066259f4f456250f9f3ae795ade93db2df48d0da1034d

[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

[-- Attachment #2: Type: text/plain, Size: 511 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: Transparency in external PDFs does not work
  2024-06-21 12:41       ` Gerion Entrup
@ 2024-06-21 14:24         ` Hans Hagen via ntg-context
  0 siblings, 0 replies; 7+ messages in thread
From: Hans Hagen via ntg-context @ 2024-06-21 14:24 UTC (permalink / raw)
  To: ntg-context; +Cc: Hans Hagen

On 6/21/2024 2:41 PM, Gerion Entrup wrote:
> Am Mittwoch, 19. Juni 2024, 09:50:33 MESZ schrieb Hans Hagen:
>> On 6/18/2024 9:54 AM, Gerion Entrup wrote:
>>> Am Montag, 17. Juni 2024, 23:50:16 MESZ schrieb Hans Hagen:
>>>> On 6/17/2024 5:07 PM, Gerion Entrup wrote:
>>>>> Hi,
>>>>>
>>>>> I'm using LaTeX-Beamer and TikZ for figure typesetting.
>> If you use that kind of simple graphics, you can avoid this transparency
>> hacking by using metafun:
>>
>> \setupbodyfont[dejavu]
>>
>> \starttext
>>
>> \startuseMPgraphic{test}
>>       pickup pencircle scaled 2mm ;
>>       draw fullcircle scaled 3cm withcolor darkred  withstacking 1 ;
>>       draw fullcircle scaled 2cm withcolor darkblue withstacking 2 ;
>>       draw textext("one")   withcolor darkgreen withstacking 11 ;
>>       draw textext("two")   withcolor darkgreen withstacking 12 ;
>>       draw textext("three") withcolor darkgreen withstacking 13 ;
>> \stopuseMPgraphic
>>
>> \startTEXpage[offset=.25ts]
>>       \useMPgraphic{test}{stacking={1,11}}
>> \stopTEXpage
>>
>> \startTEXpage[offset=.25ts]
>>       \useMPgraphic{test}{stacking={2,12}}
>> \stopTEXpage
>>
>> \startTEXpage[offset=.25ts]
>>       \useMPgraphic{test}{stacking={1,2,13}}
>> \stopTEXpage
>>
>> \stoptext
>>
>> It's an already old feature but probably not that well known. If needed
>> I can make something similar at the tex end.
>>
>> Hans
> 
> Thank you for the example, but learning metafun is another chapter and the
> graphics are much more complicated than the minimal example given.
> 
> I saw that you pushed an updated version that fixes the bug [1]. Thank you!
> 
> Gerion
> 
> [1] https://github.com/contextgarden/context/commit/0bcdd3ce47a406ed7852724504e3efe28bc2d9e1#diff-603950e83d66ef32e79066259f4f456250f9f3ae795ade93db2df48d0da1034d
The next upload will have an example of something similar at the \TEX\ 
end (i made it a few days ago but no upload yet). An exmaple can (then) 
be found in:

   stacking-001.tex

in the test suite.

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 / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2024-06-21 14:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-17 15:07 [NTG-context] Transparency in external PDFs does not work Gerion Entrup
2024-06-17 18:38 ` [NTG-context] " Pablo Rodriguez via ntg-context
2024-06-17 21:50 ` Hans Hagen
2024-06-18  7:54   ` Gerion Entrup
2024-06-19  7:50     ` Hans Hagen
2024-06-21 12:41       ` Gerion Entrup
2024-06-21 14:24         ` Hans Hagen 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).