[latex3-commits] [git/LaTeX3-latex3-pdfresources] backendtest: starting xform code ... (a852f5b)
Ulrike Fischer
fischer at troubleshooting-tex.de
Sun Aug 4 19:34:36 CEST 2019
Repository : https://github.com/latex3/pdfresources
On branch : backendtest
Link : https://github.com/latex3/pdfresources/commit/a852f5b025c4a418a6d7e2f6a6b52a242544696f
>---------------------------------------------------------------
commit a852f5b025c4a418a6d7e2f6a6b52a242544696f
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Sun Aug 4 19:34:36 2019 +0200
starting xform code ...
>---------------------------------------------------------------
a852f5b025c4a418a6d7e2f6a6b52a242544696f
experiments/xform-resources.tex | 43 +++++++++++++++++
experiments/xform-tests.tex | 101 +++++++++++++++++++++++++++++++++-------
pdfresources.dtx | 1 +
3 files changed, 129 insertions(+), 16 deletions(-)
diff --git a/experiments/xform-resources.tex b/experiments/xform-resources.tex
new file mode 100644
index 0000000..12afcb5
--- /dev/null
+++ b/experiments/xform-resources.tex
@@ -0,0 +1,43 @@
+%https://chat.stackexchange.com/transcript/message/50666032#50666032
+\documentclass{article}
+\usepackage{l3pdf}
+\ExplSyntaxOn
+\pdf_uncompress:
+\ExplSyntaxOff
+\usepackage{ocgx2} % BDC, EMC pdfmark
+\usepackage{xsavebox} % BP, EP and SP pdfmarks for XObject generation and referencing
+
+\begin{document}
+%hm creates three sets of local properties ...
+\xsavebox{Hello}{\begin{ocg}{C}{C}{on}\fbox{Hello!}\end{ocg} \begin{ocg}{A}{A}{on}\fbox{World!}\end{ocg}}%
+
+%\xsavebox{section}{\begin{ocg}{C}{C}{on}\fbox{Hello!}\end{ocg} \begin{ocg}{A}{A}{on}\fbox{World!}\end{ocg}}%
+\begin{ocg}{A}{A}{on}
+Layer A \theHello
+\end{ocg}
+
+\begin{ocg}{B}{B}{off}
+Layer B \theHello
+\end{ocg}
+\section{abc}
+
+\theHello
+
+% Manually adding to /Resources or /Properties will break OCG- and XObject-related
+% automatic insertions!
+
+%%%%%%%%%%
+%% Bad: %%
+%%%%%%%%%%
+%\special{ps:
+% mark {ThisPage} <</Resources << /Properties <</Foo/Bar>> >> >> /PUT pdfmark
+%}
+%
+%%%%%%%%%%%%%%%
+%% Also Bad: %%
+%%%%%%%%%%%%%%%
+%\special{ps:
+% mark {ThisPage} <</Resources << /Foo/Bar >> >> /PUT pdfmark
+%}
+
+\end{document}
\ No newline at end of file
diff --git a/experiments/xform-tests.tex b/experiments/xform-tests.tex
index 48f26e1..8a4a2aa 100644
--- a/experiments/xform-tests.tex
+++ b/experiments/xform-tests.tex
@@ -1,12 +1,73 @@
% !Mode:: "TeX:DE:UTF-8:Main"
\documentclass{article}
-\usepackage{l3pdf,ifxetex,tikz}
+\usepackage{l3pdf,ifxetex,tikz,pdfresources}
\ExplSyntaxOn
\pdf_uncompress:
\ExplSyntaxOff
%\usepackage[generic]
%{attachfile2}
+
+\ExplSyntaxOn
+\box_new:N \l__pdf_backend_tmpa_box
+\bool_new:N \l__pdf_backend_xform_bool
+\sys_if_engine_pdftex:T
+{
+ \cs_new:Npn \__pdf_backend_xform_new:nnnn
+ % #1 name
+ % #2 attributes
+ % #3 resources
+ % #4 content, not necessarly a box!
+ {
+ \hbox_set:Nn \l__pdf_backend_tmpa_box
+ {
+ \bool_set_true:N \l__pdf_backend_xform_bool
+ #4
+ }
+ \tl_const:cx
+ { c__pdf_backend_xform_wd_ \tl_to_str:n {#1} _tl }
+ { \tex_the:D \box_wd:N \l__pdf_backend_tmpa_box } }
+ \tl_const:cx
+ { c__pdf_backend_xform_ht_ \tl_to_str:n {#1} _tl }
+ { \tex_the:D \box_ht:N \l__pdf_backend_tmpa_box } }
+ \tl_const:cx
+ { c__pdf_backend_xform_dp_ \tl_to_str:n {#1} _tl }
+ { \tex_the:D \box_dp:N \l__pdf_backend_tmpa_box } }
+ %% do we need to test if #2 and #3 are empty??
+ \tex_immediate:D \tex_pdfxform:D
+ ~ attr ~ { #2 }
+ %% add local properties.... !!!!!!
+ %% which resources should be default? Is an argument actually needed?
+ ~ resources ~ { #3 }
+ \l__pdf_backend_tmpa_box
+ \int_const:cn
+ { c__pdf_backend_xform_ \tl_to_str:n {#1} _int }
+ { \tex_pdflastxform:D }
+ }
+
+ \cs_new:Npn \__pdf_backend_xform_ref:n #1 %#1 name
+ { \int_use:c { c_@@_backend_xform_ \tl_to_str:n {#1} _int } ~ 0 ~ R }
+
+ \cs_new:Npn \__pdf_backend_xform_use:n #1 %#1 name
+ {
+ \tex_pdfrefxform:D \int_use:c { c__pdf_backend_xform_ \tl_to_str:n {#1} _int } \scan_stop:
+ }
+}
+\ExplSyntaxOff
\begin{document}
+\ExplSyntaxOn
+%correct g to c, is already in master ...
+\sys_if_engine_xetex:T
+{
+ \cs_set:Npn \__pdf_backend_object_ref:n #1
+ { @pdf.obj \int_use:c { c__pdf_backend_object_ \tl_to_str:n {#1} _int } }
+}
+
+%object for bdc test
+\pdf_object_new:nn {objA}{dict}
+\pdf_object_write:nn {objA}{/Type/Artifact}
+
+
+\ExplSyntaxOff
% \pbs_pdfxform:nnnnn
% #1: add pgf/tikz resources (transparency, shading)? (1|0) %dvipdfmx/xetex
% #2: used as PDF annotation appearance? (1|0) %dvips/pdftex
@@ -76,14 +137,34 @@ Some Text \tikz\fill[opacity=0.5,red](0,0)rectangle(1,1);
%\newpage
\ifxetex
-\savebox\testxform{Some Text \tikz\fill[opacity=0.5,red](0,0)rectangle(1,1);}
+\savebox\testxform{\csname pdf_bdc:nn\endcsname {Span}{objA}xxxyyy Some Text \csname pdf_emc:\endcsname \tikz\fill[opacity=0.5,red](0,0)rectangle(1,1);}
% when saving the xform object, is should be in a zero box.
% all dimensions must be there, or the content is typeset ...
% and don't forget the \the!!
% transparency resources etc must be add to the box
abc%
\bigskip
-Use xform: \special{pdf:uxobj @MyStamp}
+%xobjects must be defined before use ...
+
+\begin{picture}(0,0)
+ \put(0,0)
+ {
+ \special
+ {pdf:bxobj @MyStamp
+ width \the\wd\testxform\space
+ height \the\ht\testxform\space
+ depth \the\dp\testxform
+ }%
+ % \csname pdf_bdc:nn\endcsname {Span}{objA}xxx
+ \usebox\testxform
+ % \csname pdf_emc:\endcsname
+ \special{pdf:put @resources <</ExtGState @pgfextgs>>} %
+ \special{pdf:exobj}}
+ \end{picture}yyyy
+
+Use xform: \fboxsep0pt \fbox{\makebox[\the\wd\testxform][l]{\special{pdf:uxobj @MyStamp}}}
+
+\newpage
%Use as appearance:
\fbox{
xx
@@ -101,19 +182,7 @@ Use xform: \special{pdf:uxobj @MyStamp}
\phantom{\usebox\testxform}xx}
abc
- \begin{picture}(0,0)
- \put(0,0)
- {
- \special
- {pdf:bxobj @MyStamp
- width \the\wd\testxform\space
- height \the\ht\testxform\space
- depth \the\dp\testxform
- }%
- \usebox\testxform
- \special{pdf:put @resources <</ExtGState @pgfextgs>>} %
- \special{pdf:exobj}}
- \end{picture}yyyy
+
Use xform after: \special{pdf:uxobj @MyStamp}
diff --git a/pdfresources.dtx b/pdfresources.dtx
index 0cbb4b1..a965012 100644
--- a/pdfresources.dtx
+++ b/pdfresources.dtx
@@ -771,6 +771,7 @@
% \begin{NOTE}{UF}
% we still need a switch for the case that the resource should be added to
% xform resource instead of a page resources, see pdfbase.sty
+% - xdvipdfmx: looks fine, the resource is added to the xform resource automatically
% \end{NOTE}
% Entries to the /Properties dictionary in the page resources can
% be added with dvips only through side-effect: if a bdc-mark is created dvips/ghostscript
More information about the latex3-commits
mailing list