[latex3-commits] [git/LaTeX3-latex3-pdfresources] testlinkstuff: test for ocg properties (a677a10)

Ulrike Fischer fischer at troubleshooting-tex.de
Mon May 20 15:59:44 CEST 2019


Repository : https://github.com/latex3/pdfresources
On branch  : testlinkstuff
Link       : https://github.com/latex3/pdfresources/commit/a677a10d8a55a859aaac91eebebdcefa8e335038

>---------------------------------------------------------------

commit a677a10d8a55a859aaac91eebebdcefa8e335038
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Mon May 20 15:59:44 2019 +0200

    test for ocg properties


>---------------------------------------------------------------

a677a10d8a55a859aaac91eebebdcefa8e335038
 pdfresources.dtx              |   31 ++++-
 test-ocg-properties.tex       |    8 +-
 testfiles/properties-ocgx.pvt |   54 ++++++++
 testfiles/properties-ocgx.tpf |  303 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 393 insertions(+), 3 deletions(-)

diff --git a/pdfresources.dtx b/pdfresources.dtx
index c6855c3..d7cc6c6 100644
--- a/pdfresources.dtx
+++ b/pdfresources.dtx
@@ -538,7 +538,13 @@
   }
 }
 
-\AtEndDocument % must perhaps be even later??
+% doesn't work: ocg layer of float gets lost ...
+%\AtEndDocument % must perhaps be even later??
+%
+\RequirePackage{etoolbox}
+\AfterEndDocument
+%\RequirePackage{atenddvi}
+%\AtEndDvi
  {
    % write the global objects:
   \clist_map_inline:Nn \c_@@_pdf_pageresources_clist
@@ -1291,6 +1297,29 @@
  }
 \msg_info:nn{pdf}{patches}
 \RequirePackage{etoolbox}
+% code to add to the resources existing stuff in the format "/name value":
+\cs_new:Npn \__pdf_split_dict_entry_aux:NNw #1 #2 /#3~#4\q_stop
+ {
+  \tl_set:Nn #1 {#3}
+  \tl_set:Nn #2 {#4}
+ }
+\tl_new:N \l__pdf_name_tmp_tl
+\tl_new:N \l__pdf_value_tmp_tl
+\cs_generate_variant:Nn \pdf_pageresources_gput:nnnn {nnoo}
+\cs_new_protected:Npn \pdf_pageresources_split_gput:nnn  #1 #2 #3 %#1 page, #2 resources
+ {
+   \__pdf_split_dict_entry_aux:NNw \l__pdf_name_tmp_tl \l__pdf_value_tmp_tl #3 \q_stop
+   \pdf_pageresources_gput:nnoo {#1}{#2}{\l__pdf_name_tmp_tl}{\l__pdf_value_tmp_tl}
+ }
+
+\cs_generate_variant:Nn \pdf_pageresources_gput:nnn {noo}
+\cs_new_protected:Npn \pdf_pageresources_split_gput:nn  #1 #2  %#1  resources
+ {
+   \__pdf_split_dict_entry_aux:NNw \l__pdf_name_tmp_tl \l__pdf_value_tmp_tl #2 \q_stop
+   \pdf_pageresources_gput:noo {#1}{#2}{\l__pdf_name_tmp_tl}{\l__pdf_value_tmp_tl}
+ }
+
+
   %Trying to patch pgf ..
 \AtBeginDocument
  {
diff --git a/test-ocg-properties.tex b/test-ocg-properties.tex
index 81ae56e..49c8d68 100644
--- a/test-ocg-properties.tex
+++ b/test-ocg-properties.tex
@@ -1,6 +1,7 @@
 % !Mode:: "TeX:UTF-8:Main"
 \pdfcompresslevel0
 \pdfobjcompresslevel0
+
 \documentclass{article}
 
 \usepackage[a6paper]{geometry}
@@ -10,14 +11,17 @@
 
 \begin{document}
 
-Some \begin{ocg}{red}{red}{on}
+Some \begin{ocg}{red Layer}{red}{on}
 {\color{red}layered text.}
 \end{ocg}
 
+Some \begin{ocg}{yellow Layer}{yellow}{on}
+{\color{yellow}layered text.}
+\end{ocg}
 
 \newpage
 
-More \begin{ocg}{blue}{blue}{on}
+More \begin{ocg}{blue Layer}{blue}{on}
 {\color{blue}layered text.}
 \end{ocg}
 
diff --git a/testfiles/properties-ocgx.pvt b/testfiles/properties-ocgx.pvt
new file mode 100644
index 0000000..1a056ac
--- /dev/null
+++ b/testfiles/properties-ocgx.pvt
@@ -0,0 +1,54 @@
+\RequirePackage[enable-debug]{expl3}
+\RequirePackage[patches]{pdfresources}
+\documentclass{article}
+\ExplSyntaxOn
+\driver_pdf_compresslevel:n {0}
+\driver_pdf_compress_objects:n {0}
+
+\ExplSyntaxOff
+
+\usepackage[a6paper]{geometry}
+
+\usepackage{ocgx2}
+\usepackage{color}
+\ExplSyntaxOn
+\pdf_pageresources_gput:nnn {Properties}{test}{<</test (value)>>}
+\ExplSyntaxOff
+\begin{document}
+\ExplSyntaxOn\makeatletter
+\tl_if_exist:NT \pbs at last@page
+{
+ \int_step_inline:nn{\pbs at last@page}
+ {
+  \seq_map_inline:cn { pbs at props@#1 }
+  {
+   \pdf_pageresources_split_gput:nnn {#1} {Properties}{##1}
+  }
+ }
+}
+\ExplSyntaxOff
+
+Some \begin{ocg}{red Layer}{red}{on}
+{\color{red}layered text.}
+\end{ocg}
+
+Some \begin{ocg}{yellow Layer}{yellow}{on}
+{\color{yellow}layered text.}
+\end{ocg}
+
+\newpage
+
+More \begin{ocg}{blue Layer}{blue}{on}
+{\color{blue}layered text.}
+\end{ocg}
+
+\begin{figure}[p]
+
+Some \begin{ocg}{red Layer}{red}{on}
+{\color{red}layered text.}
+\end{ocg}
+
+\end{figure}
+
+
+\end{document}
\ No newline at end of file
diff --git a/testfiles/properties-ocgx.tpf b/testfiles/properties-ocgx.tpf
new file mode 100644
index 0000000..23c60a8
--- /dev/null
+++ b/testfiles/properties-ocgx.tpf
@@ -0,0 +1,303 @@
+%PDF-1.5
+%ÐÔÅØ
+9 0 obj
+<</Type/OCG/Name (red Layer) >>
+endobj
+10 0 obj
+<</Type/OCG/Name (yellow Layer) >>
+endobj
+14 0 obj
+<<
+/Length 408       
+>>
+stream
+0 g 0 G
+0 g 0 G
+BT
+/F8 9.9626 Tf 59.59 359.221 Td [(Some)]TJ
+ET
+/OC/rm at oc0 BDC
+1 0 0 rg 1 0 0 RG
+BT
+/F8 9.9626 Tf 86.157 359.221 Td [(la)28(y)28(ered)-334(text.)]TJ
+0 g 0 G
+ET
+EMC
+BT
+/F8 9.9626 Tf 59.59 347.266 Td [(Some)]TJ
+ET
+/OC/rm at oc1 BDC
+0 0 1 0 k 0 0 1 0 K
+BT
+/F8 9.9626 Tf 86.157 347.266 Td [(la)28(y)28(ered)-334(text.)]TJ
+0 g 0 G
+ET
+EMC
+0 g 0 G
+BT
+/F8 9.9626 Tf 146.328 45.628 Td [(1)]TJ
+0 g 0 G
+ET
+endstream
+endobj
+13 0 obj
+<<
+/Type /Page
+/Contents 14 0 R
+/Resources 12 0 R
+/MediaBox [0 0 297.638 419.528]
+/Parent 16 0 R
+/Annots [ 11 0 R ]
+>>
+endobj
+11 0 obj
+<<
+/Type /Annot
+/Ff 65537/FT/Btn/Subtype/Widget/T (pbs at ARFix@1)
+/Rect [0 416.539 2.989 419.528]
+>>
+endobj
+12 0 obj
+<<
+/ExtGState 1 0 R /ColorSpace 2 0 R /Pattern 3 0 R /Shading 4 0 R /Properties 6 0 R 
+/Font << /F8 15 0 R >>
+/ProcSet [ /PDF /Text ]
+>>
+endobj
+17 0 obj
+<</Type/OCG/Name (blue Layer) >>
+endobj
+21 0 obj
+<<
+/Length 242       
+>>
+stream
+0 g 0 G
+0 g 0 G
+BT
+/F8 9.9626 Tf 59.59 359.221 Td [(More)]TJ
+ET
+/OC/rm at oc2 BDC
+0 0 1 rg 0 0 1 RG
+BT
+/F8 9.9626 Tf 85.355 359.221 Td [(la)28(y)28(ered)-334(text.)]TJ
+0 g 0 G
+ET
+EMC
+0 g 0 G
+BT
+/F8 9.9626 Tf 146.328 45.628 Td [(2)]TJ
+0 g 0 G
+ET
+endstream
+endobj
+20 0 obj
+<<
+/Type /Page
+/Contents 21 0 R
+/Resources 19 0 R
+/MediaBox [0 0 297.638 419.528]
+/Parent 16 0 R
+/Annots [ 18 0 R ]
+>>
+endobj
+18 0 obj
+<<
+/Type /Annot
+/Ff 65537/FT/Btn/Subtype/Widget/T (pbs at ARFix@2)
+/Rect [0 416.539 2.989 419.528]
+>>
+endobj
+19 0 obj
+<<
+/ExtGState 1 0 R /ColorSpace 2 0 R /Pattern 3 0 R /Shading 4 0 R /Properties 7 0 R 
+/Font << /F8 15 0 R >>
+/ProcSet [ /PDF /Text ]
+>>
+endobj
+22 0 obj
+[ 9 0 R 10 0 R 17 0 R]
+endobj
+23 0 obj
+[ 9 0 R 10 0 R 17 0 R]
+endobj
+27 0 obj
+<<
+/Length 259       
+>>
+stream
+0 g 0 G
+0 g 0 G
+0 g 0 G
+BT
+/F8 9.9626 Tf 44.646 219.859 Td [(Some)]TJ
+ET
+/OC/rm at oc3 BDC
+1 0 0 rg 1 0 0 RG
+BT
+/F8 9.9626 Tf 71.213 219.859 Td [(la)28(y)28(ered)-334(text.)]TJ
+0 g 0 G
+ET
+EMC
+0 g 0 G
+0 g 0 G
+BT
+/F8 9.9626 Tf 146.328 45.628 Td [(3)]TJ
+0 g 0 G
+ET
+endstream
+endobj
+26 0 obj
+<<
+/Type /Page
+/Contents 27 0 R
+/Resources 25 0 R
+/MediaBox [0 0 297.638 419.528]
+/Parent 16 0 R
+/Annots [ 24 0 R ]
+>>
+endobj
+24 0 obj
+<<
+/Type /Annot
+/Ff 65537/FT/Btn/Subtype/Widget/T (pbs at ARFix@3)
+/Rect [0 416.539 2.989 419.528]
+>>
+endobj
+25 0 obj
+<<
+/ExtGState 1 0 R /ColorSpace 2 0 R /Pattern 3 0 R /Shading 4 0 R /Properties 8 0 R 
+/Font << /F8 15 0 R >>
+/ProcSet [ /PDF /Text ]
+>>
+endobj
+1 0 obj
+<<  >>
+endobj
+2 0 obj
+<<  >>
+endobj
+3 0 obj
+<<  >>
+endobj
+4 0 obj
+<<  >>
+endobj
+5 0 obj
+<< /test <</test(value)>>  >>
+endobj
+6 0 obj
+<< /test <</test(value)>> /rm at oc0 6 0 R /rm at oc1 7 0 R  >>
+endobj
+7 0 obj
+<< /test <</test(value)>> /rm at oc2 14 0 R  >>
+endobj
+8 0 obj
+<< /test <</test(value)>> /rm at oc3 6 0 R  >>
+endobj
+28 0 obj
+[277.8 500 500 500 500 500 500 500 500 500 500 500 277.8 277.8 277.8 777.8 472.2 472.2 777.8 750 708.3 722.2 763.9 680.6 652.8 784.7 750 361.1 513.9 777.8 625 916.7 750 777.8 680.6 777.8 736.1 555.6 722.2 750 750 1027.8 750 750 611.1 277.8 500 277.8 500 277.8 277.8 500 555.6 444.4 555.6 444.4 305.6 500 555.6 277.8 305.6 527.8 277.8 833.3 555.6 500 555.6 527.8 391.7 394.4 388.9 555.6 527.8 722.2 527.8 527.8]
+endobj
+29 0 obj
+<<
+/Length1 1595
+/Length2 10969
+/Length3 0
+/Length 12564     
+>>
+[BINARY STREAM]
+endobj
+30 0 obj
+<<
+/Type /FontDescriptor
+/FontName /GGEKKH+CMR10
+/Flags 4
+/FontBBox [-40 -250 1009 750]
+/Ascent 694
+/CapHeight 683
+/Descent -194
+/ItalicAngle 0
+/StemV 69
+/XHeight 431
+/CharSet (/M/S/a/d/e/l/m/o/one/period/r/t/three/two/x/y)
+/FontFile 29 0 R
+>>
+endobj
+15 0 obj
+<<
+/Type /Font
+/Subtype /Type1
+/BaseFont /GGEKKH+CMR10
+/FontDescriptor 30 0 R
+/FirstChar 46
+/LastChar 121
+/Widths 28 0 R
+>>
+endobj
+16 0 obj
+<<
+/Type /Pages
+/Count 3
+/Kids [13 0 R 20 0 R 26 0 R]
+>>
+endobj
+31 0 obj
+<<
+/Type /Catalog
+/Pages 16 0 R
+/OCProperties <</OCGs 22 0 R/D <</AS [<</Event/View/Category[/View]/OCGs 22 0 R>><</Event/Print/Category[/Print]/OCGs 22 0 R>><</Event/Export/Category[/Export]/OCGs 22 0 R>>]/BaseState/ON /Order 23 0 R/ListMode/VisiblePages>>>>
+>>
+endobj
+32 0 obj
+<<
+/Producer (pdfTeX-1.40.20)
+/Creator (TeX)
+/CreationDate (D:20160520090000Z)
+/ModDate (D:20160520090000Z)
+/Trapped /False
+/PTEX.Fullbanner (This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019/W32TeX) kpathsea version 6.3.1)
+>>
+endobj
+xref
+0 33
+0000000000 65535 f 
+0000002535 00000 n 
+0000002557 00000 n 
+0000002579 00000 n 
+0000002601 00000 n 
+0000002623 00000 n 
+0000002668 00000 n 
+0000002741 00000 n 
+0000002801 00000 n 
+0000000015 00000 n 
+0000000062 00000 n 
+0000000715 00000 n 
+0000000830 00000 n 
+0000000580 00000 n 
+0000000113 00000 n 
+0000016210 00000 n 
+0000016350 00000 n 
+0000000983 00000 n 
+0000001468 00000 n 
+0000001583 00000 n 
+0000001333 00000 n 
+0000001032 00000 n 
+0000001736 00000 n 
+0000001775 00000 n 
+0000002267 00000 n 
+0000002382 00000 n 
+0000002132 00000 n 
+0000001814 00000 n 
+0000002860 00000 n 
+0000003287 00000 n 
+0000015950 00000 n 
+0000016423 00000 n 
+0000016702 00000 n 
+trailer
+<< /Size 33
+/Root 31 0 R
+/Info 32 0 R
+/ID [<D774E23E9A73DC81DA40F867FA14BA4A> <D774E23E9A73DC81DA40F867FA14BA4A>] >>
+startxref
+16957
+%%EOF





More information about the latex3-commits mailing list