Difference between revisions of "Hiding Content"

From Wiki
Jump to navigation Jump to search
(Clarified language, added another example for comparison.)
(Summation of methods (that's why I didn't link to the page before). Not yet complete.)
Line 1: Line 1:
 
< [[Visuals]] | [[Presentations]] | [[Layers]] >
 
< [[Visuals]] | [[Presentations]] | [[Layers]] >
  
Probably for your [[Presentations|slides]], probably for some [[Animation|animation]] or for whatever reason you may want it: you can hide some content from the document, while leaving exactly the same amount of space as that content would need if typeset in the usual way. This is done by placing the content on a layer that is not normally visible when the document is displayed.
+
Probably for your [[Presentations|slides]], probably for some [[Animation|animation]] or for whatever reason you may want it: you can hide some content from the document, while leaving exactly the same amount of space as that content would need if typeset in the usual way.
 +
 
 +
On the [[http://archive.contextgarden.net/thread/20050707.223338.a9169811.html mailing list]] Hans suggested many different ways (astonishing easy to use) to hide the content in a PDF document. Sadly, most of them are viewer-dependent.
 +
 
 +
<table style="border:1px solid #DDDDDD; width:100%" align="left" valign="top">
 +
 
 +
<tr style="background-color:#DDDDDD" align="left" valign="top"><th> method </th><th> principle </th><th> PROS </th><th> CONS </th></tr>
 +
 
 +
<tr><td>
 +
<texcode>
 +
\defineproperty[my-secrets][layer][state=top]
 +
\startproperty[my-secrets]
 +
My public secret.
 +
\stopproperty
 +
</texcode>
 +
</td><td>
 +
* makes (invisible) layer on top (JS-based)
 +
</td><td>
 +
* completely hides everything
 +
</td><td>
 +
* works with newer Adobe Acrobat/Viewer, in most other browsers the content is not hidden
 +
* I managed to freeze Acrobat 6.0 pro when trying to save the text
 +
</td></tr>
 +
 
 +
<tr align="left" valign="top" style="background-color:#EEEEEE;">
 +
<td>
 +
<texcode>
 +
\defineproperty[my-hasitations][layer][state=stop]
 +
 
 +
\startproperty[my-hasitations]
 +
To \ConTeXt\ or not to \ConTeXt?
 +
\stopproperty
 +
 
 +
\button{Show  Decision}[VideLayer{my-hasitations}]
 +
\button{Hide  Decision}[HideLayer{my-hasitations}]
 +
\button{Toggle Decision}[ToggleLayer{my-hasitations}]
 +
</texcode>
 +
</td>
 +
    <td>
 +
* makes (invisible) layer, which can be switched on and off (JS-based)</td>
 +
    <td>
 +
* you can switch the content on and off
 +
* when hidden, it is completely hidden (as above)
 +
</td><td>
 +
* (same as above)
 +
* even some new Acrobat versions can't handle the buttons
 +
</td></tr>
 +
 
 +
<tr><td>
 +
<texcode>
 +
\startproperty[hidden]
 +
My secret hidden for Adam's apple ;)
 +
\stopproperty
 +
</texcode>
 +
</td><td>
 +
* makes transparent fonts
 +
</td><td>
 +
* no JavaScript
 +
* pretty safe for different viewers
 +
</td><td>
 +
* only text is hidden, but not images, rules, ...
 +
</td></tr>
 +
 
 +
<tr align="left" valign="top" style="background-color:#EEEEEE;">
 +
<td>
 +
[[Hiding Content#The plain TeX way|the plain TeX way]]
 +
</td><td>
 +
* puts a blank box instead of its content (letter)
 +
</td><td>
 +
* <b>absolutely no</b> content in the document, not even hidden (only blank space)
 +
</td><td>
 +
* only works for letters and whitespace, no macros, no figures, ...
 +
</td></tr>
 +
</table>
 +
 
 +
x
 +
 
 +
== The plain TeX way ==
 +
 
 +
This example was adapted from the TeXBOOK. However, it can only handle usual text. Forget about macros, forget about graphics ...
 +
 
 +
I hope and still believe that it is possible to extend this macro to make it work in general case. This would also be a preferred solution as it doesn't depend on the viewer's JavaScript <i>in</i>capabilities.
 +
 
 +
<texcode>
 +
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 +
% the portion of code adapted from the TeXBOOK, Excercise 11.5 %
 +
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 +
 
 +
\def\dolist{\afterassignment\dodolist\let\next= }
 +
\def\dodolist{\ifx\next\endlist\let\next\relax
 +
  \else \\\let\next\dolist \fi
 +
\next}
 +
\def\endlist{\endlist}
 +
 
 +
\def\\{\if\space\next\ % assume that \next is unexpandable
 +
\else\setbox0=\hbox{\next}\setbox1=\hbox{}%
 +
  \dp1=\dp0\ht1=\ht0\wd1=\wd0\box1\fi}
 +
 
 +
\def\demobox#1{{\dolist#1\endlist}}
 +
 
 +
</texcode>
 +
 
 +
<context>
 +
 
 +
\def\dolist{\afterassignment\dodolist\let\next= }
 +
\def\dodolist{\ifx\next\endlist\let\next\relax
 +
  \else \\\let\next\dolist \fi
 +
\next}
 +
\def\endlist{\endlist}
 +
 
 +
\def\\{\if\space\next\ % assume that \next is unexpandable
 +
\else\setbox0=\hbox{\next}\setbox1=\hbox{}%
 +
  \dp1=\dp0\ht1=\ht0\wd1=\wd0\box1\fi}
 +
 
 +
\def\demobox#1{{\dolist#1\endlist}}
 +
 
 +
Please write something more interesting on this place
 +
\demobox{if you are visiting this page and getting bored.}
 +
Thanks.
 +
 
 +
Please write something more interesting on this place
 +
if you are visiting this page and getting bored.
 +
Thanks.
 +
 
 +
</context>
 +
 
 +
== Layer: state=top ==
  
 
You can try something like:
 
You can try something like:
Line 44: Line 170:
 
</context>
 
</context>
  
<b>Just as a hint</b>: Don't ever think about hiding your secrets or solutions to the problems for your students that way!<br>
+
== Layer: state=stop ==
 +
 
 +
== Transparent fonts ==
 +
 
 +
== Final Remarks ==
 +
 
 +
* <b>Just as a hint</b>: Don't ever think about hiding your secrets or solutions to the problems for your students that way!<br>
 
If you happen to have Adobe Acrobat Professional, you can select <i>Layers</i> on the left and switch the hidden layer on again.<br>
 
If you happen to have Adobe Acrobat Professional, you can select <i>Layers</i> on the left and switch the hidden layer on again.<br>
 
<font color="red">YOU HAVE BEEN WARNED!</font>
 
<font color="red">YOU HAVE BEEN WARNED!</font>
  
[[http://archive.contextgarden.net/thread/20050707.223338.a9169811.html]]
+
* kerning: could cause micro differences in the exact placemet of the (hidden) content

Revision as of 01:55, 6 August 2005

< Visuals | Presentations | Layers >

Probably for your slides, probably for some animation or for whatever reason you may want it: you can hide some content from the document, while leaving exactly the same amount of space as that content would need if typeset in the usual way.

On the [mailing list] Hans suggested many different ways (astonishing easy to use) to hide the content in a PDF document. Sadly, most of them are viewer-dependent.

method principle PROS CONS
\defineproperty[my-secrets][layer][state=top]
\startproperty[my-secrets]
My public secret.
\stopproperty
  • makes (invisible) layer on top (JS-based)
  • completely hides everything
  • works with newer Adobe Acrobat/Viewer, in most other browsers the content is not hidden
  • I managed to freeze Acrobat 6.0 pro when trying to save the text
\defineproperty[my-hasitations][layer][state=stop]

\startproperty[my-hasitations]
To \ConTeXt\ or not to \ConTeXt?
\stopproperty

\button{Show   Decision}[VideLayer{my-hasitations}]
\button{Hide   Decision}[HideLayer{my-hasitations}]
\button{Toggle Decision}[ToggleLayer{my-hasitations}]
  • makes (invisible) layer, which can be switched on and off (JS-based)
  • you can switch the content on and off
  • when hidden, it is completely hidden (as above)
  • (same as above)
  • even some new Acrobat versions can't handle the buttons
\startproperty[hidden]
My secret hidden for Adam's apple ;)
\stopproperty
  • makes transparent fonts
  • no JavaScript
  • pretty safe for different viewers
  • only text is hidden, but not images, rules, ...

the plain TeX way

  • puts a blank box instead of its content (letter)
  • absolutely no content in the document, not even hidden (only blank space)
  • only works for letters and whitespace, no macros, no figures, ...

x

The plain TeX way

This example was adapted from the TeXBOOK. However, it can only handle usual text. Forget about macros, forget about graphics ...

I hope and still believe that it is possible to extend this macro to make it work in general case. This would also be a preferred solution as it doesn't depend on the viewer's JavaScript incapabilities.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% the portion of code adapted from the TeXBOOK, Excercise 11.5 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\dolist{\afterassignment\dodolist\let\next= }
\def\dodolist{\ifx\next\endlist\let\next\relax
  \else \\\let\next\dolist \fi
\next}
\def\endlist{\endlist}

\def\\{\if\space\next\ % assume that \next is unexpandable
\else\setbox0=\hbox{\next}\setbox1=\hbox{}%
  \dp1=\dp0\ht1=\ht0\wd1=\wd0\box1\fi}

\def\demobox#1{{\dolist#1\endlist}}

Layer: state=top

You can try something like:

\defineproperty[my-secrets][layer][state=top]

I don't tell this to everybody:
%
\startproperty[my-secrets]%
\quotation{\ConTeXt\ goes beyond the limits of imagination, that's why I love it!}
\stopproperty
%
You'll understand that once you get to know it better.

which results in

This can be compared to the non-hidden version, which is:

Layer: state=stop

Transparent fonts

Final Remarks

  • Just as a hint: Don't ever think about hiding your secrets or solutions to the problems for your students that way!

If you happen to have Adobe Acrobat Professional, you can select Layers on the left and switch the hidden layer on again.
YOU HAVE BEEN WARNED!

  • kerning: could cause micro differences in the exact placemet of the (hidden) content