[latex3-commits] [git/LaTeX3-latex3-pdfresources] develop, name-trees: test file for landscape pages (53d7b1f)
Ulrike Fischer
fischer at troubleshooting-tex.de
Fri Jul 23 00:21:12 CEST 2021
Repository : https://github.com/latex3/pdfresources
On branches: develop,name-trees
Link : https://github.com/latex3/pdfresources/commit/53d7b1f035f41cc815c1114b9bc5ef232eec8d82
>---------------------------------------------------------------
commit 53d7b1f035f41cc815c1114b9bc5ef232eec8d82
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Fri Jul 23 00:21:12 2021 +0200
test file for landscape pages
>---------------------------------------------------------------
53d7b1f035f41cc815c1114b9bc5ef232eec8d82
.../l3backend-testphase-dvips-test-landscape.def | 294 +++++++++++++++++++++
experiments/xform-dvips/xformtest2.tex | 35 +++
2 files changed, 329 insertions(+)
diff --git a/experiments/xform-dvips/l3backend-testphase-dvips-test-landscape.def b/experiments/xform-dvips/l3backend-testphase-dvips-test-landscape.def
new file mode 100644
index 0000000..740d3df
--- /dev/null
+++ b/experiments/xform-dvips/l3backend-testphase-dvips-test-landscape.def
@@ -0,0 +1,294 @@
+%%
+%% This is file `l3backend-testphase-dvips.def',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% l3backend-testphase.dtx (with options: `drivers,dvips')
+%%
+%% Copyright (C) 2019-2021 The LaTeX Project
+%%
+%% It may be distributed and/or modified under the conditions of
+%% the LaTeX Project Public License (LPPL), either version 1.3c of
+%% this license or (at your option) any later version. The latest
+%% version of this license is in the file:
+%%
+%% https://www.latex-project.org/lppl.txt
+%%
+%% This file is part of the "LaTeX PDF management testphase bundle" (The Work in LPPL)
+%% and all files in that bundle must be distributed together.
+%%
+%% File: l3backend-testphase.dtx
+\ProvidesExplFile
+ {l3backend-testphase-dvips.def}{2021-06-29}{}
+ {LaTeX~PDF~management~testphase~bundle~backend~support: dvips}
+\RequirePackage{l3ref-tmp}
+\cs_generate_variant:Nn \ref_label:nn {en}
+\cs_generate_variant:Nn \ref_value:nn {en}
+\cs_new_protected:Npn \__pdf_backend_ref_label:nn #1 #2
+ {
+ \@bsphack
+ \ref_label:nn{#1}{abspage}
+ \@esphack
+ }
+\cs_new:Npn \__pdf_backend_ref_value:nn #1 #2
+ {
+ \ref_value:nn{#1}{#2}
+ }
+\cs_generate_variant:Nn \__pdf_backend_ref_label:nn {en}
+\cs_generate_variant:Nn \__pdf_backend_ref_value:nn {en}
+\prop_new:N \g__pdf_tmpa_prop
+\tl_new:N \l__pdf_tmpa_tl
+\box_new:N \l__pdf_backend_tmpa_box
+\box_new:N \l__pdf_backend_tmpb_box
+\int_new:N \g__pdf_backend_resourceid_int
+\int_new:N \g__pdf_backend_name_int
+\int_new:N \g__pdf_backend_page_int
+\cs_new:Npn \__kernel_pdf_name_from_unicode_e:n #1
+ {
+ ~ ( \text_expand:n { #1 } ) ~ cvn
+ }
+\tl_gput_right:Nn\@kernel at after@shipout at lastpage
+ {
+ \g__kernel_pdfmanagement_end_run_code_tl
+ }
+\tl_if_exist:NTF \@kernel at after@shipout at background
+ {
+ \g at addto@macro \@kernel at before@shipout at background{\relax}
+ \g at addto@macro \@kernel at after@shipout at background
+ {
+ \g__kernel_pdfmanagement_thispage_shipout_code_tl
+ }
+ }
+ {
+ \hook_gput_code:nnn{shipout/background}{pdf}
+ {
+ \g__kernel_pdfmanagement_thispage_shipout_code_tl
+ }
+ }
+
+\cs_new_protected:Npx \__pdf_backend_Pages_primitive:n #1
+ {
+ \tex_special:D{ps:~[#1~/PAGES~pdfmark} %]
+ }
+\cs_new_protected:Npn \__pdf_backend_Page_primitive:n #1
+ {
+ \tex_special:D{ps:~[{ThisPage}<<#1>>~/PUT~pdfmark} %]
+ }
+ % the command to store default values.
+ % Uses a prop with pdflatex + dvi,
+ % sets a lua table with lualatex
+\cs_new_protected:Npn \__pdf_backend_Page_gput:nn #1 #2
+ {
+ \pdfdict_gput:nnn {g__pdf_Core/Page}{ #1 }{ #2 }
+ }
+ % the command to remove a default value.
+ % Uses a prop with pdflatex + dvi,
+ % changes a lua table with lualatex
+\cs_new_protected:Npn \__pdf_backend_Page_gremove:n #1
+ {
+ \pdfdict_gremove:nn {g__pdf_Core/Page}{ #1 }
+ }
+ % the command used in the document.
+ % direct call of the primitive special with dvips/dvipdfmx
+ % \latelua: fill a page related table with lualatex, merge it with the page
+ % table and push it directly
+ % write to aux and store in prop with pdflatex
+\cs_new_protected:Npn \__pdf_backend_ThisPage_gput:nn #1 #2
+ {
+ \__pdf_backend_Page_primitive:n { /#1~#2 }
+ }
+ %the code to push the values, used in shipout
+ %merges the two props and then fills the register in pdflatex
+ %merges the two tables (the one is probably still empty)
+ %and then fills (in lua) in luatex
+ %issues the values stored in the global prop with dvi
+\cs_new_protected:Npn \__pdf_backend_ThisPage_gpush:n #1
+ {
+ \exp_args:Nx \__pdf_backend_Page_primitive:n
+ { \pdfdict_use:n { g__pdf_Core/Page} }
+ }
+\clist_const:Nn \c__pdf_backend_PageResources_clist
+ {
+ ExtGState,
+ ColorSpace,
+ Pattern,
+ Shading,
+ }
+\cs_new_protected:Npn \__pdf_backend_PageResources:n #1 {}
+\cs_new_protected:Npn \__pdf_backend_PageResources_gput:nnn #1 #2 #3
+ { %only for the show command TEST!!
+ \pdfdict_gput:nnn {g__pdf_Core/Page/Resources/#1} { #2 }{ #3 }
+ }
+\cs_new_protected:Npn \__pdf_backend_PageResources_obj_gpush: {}
+\bool_new:N \l__pdf_backend_xform_bool
+\cs_set_protected:Npn \__pdf_backend_bdc:nn #1 #2 % #1 eg. Span, #2: dict_content
+ {
+ \__pdf_backend_pdfmark:x{/#1~<<#2>>~/BDC}
+ }
+\cs_set_protected:Npn \__pdf_backend_bdcobject:nn #1 #2 % #1 eg. Span, #2: object name
+ {
+ \__pdf_backend_pdfmark:x{/#1~\__pdf_backend_object_ref:n{#2}~/BDC}
+ }
+\cs_set_protected:Npn \__pdf_backend_bdcobject:n #1 % #1 eg. Span,
+ {
+ \__pdf_backend_pdfmark:x{/#1~\__pdf_backend_object_last:~/BDC}
+ }
+\cs_set_protected:Npn \__pdf_backend_emc:
+ {
+ \__pdf_backend_pdfmark:n{/EMC} %
+ }
+\cs_set_protected:Npn \__pdf_backend_bmc:n #1
+ {
+ \__pdf_backend_pdfmark:n{/#1~/BMC} %
+ }
+\cs_new_protected:Npn \__pdf_backend_PageResources_gpush:n #1 {}
+
+
+
+\cs_new_protected:Npn \__pdf_backend_NamesEmbeddedFiles_gpush:n #1 {}
+
+\int_new:N \g__pdf_backend_EmbeddedFiles_int
+\cs_new:Npn \__pdf_backend_EmbeddedFiles_name:
+ {
+ (
+ l3ef
+ \int_compare:nNnT {\g__pdf_backend_EmbeddedFiles_int} < {10}
+ {0}
+ \int_compare:nNnT {\g__pdf_backend_EmbeddedFiles_int} < {100}
+ {0}
+ \int_compare:nNnT {\g__pdf_backend_EmbeddedFiles_int} < {1000}
+ {0}
+ \int_use:N \g__pdf_backend_EmbeddedFiles_int
+ )
+ }
+\seq_new:N \g__pdf_backend_EmbeddedFiles_seq
+\prop_new:N \g__pdf_backend_EmbeddedFiles_named_prop
+\cs_new_protected:Npn \__pdf_backend_NamesEmbeddedFiles_add:n #1
+ {
+ \int_gincr:N \g__pdf_backend_EmbeddedFiles_int
+ \prop_gput:Nnx \g__pdf_backend_EmbeddedFiles_named_prop
+ { #1 }
+ { \__pdf_backend_EmbeddedFiles_name: }
+ \__pdf_backend_pdfmark:x
+ {
+ /Name~\__pdf_backend_EmbeddedFiles_name:~
+ /FS~#1~
+ /EMBED
+ }
+ }
+\cs_new_protected:Npn\__pdf_backend_xform_new:nnnn #1 #2 #3 #4 % #1 name, #2 attribute, #4 content
+ {
+ \int_gincr:N \g__pdf_backend_object_int
+ \int_const:cn
+ { c__pdf_backend_xform_ \tl_to_str:n {#1} _int }
+ { \g__pdf_backend_object_int }
+
+ \hbox_set:Nn \l__pdf_backend_tmpa_box
+ {
+ \bool_set_true:N \l__pdf_backend_xform_bool
+ \prop_gclear:c {\__kernel_pdfdict_name:n { g__pdf_Core/Xform/Resources/Properties }}
+ #4
+ }
+ %store the dimensions
+ \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 }
+ \hbox_set:Nn\l__pdf_backend_tmpb_box
+ {
+ \__kernel_backend_postscript:x
+ {
+ gsave~currentpoint~translate~
+ mark~
+ /_objdef~{ pdf.obj \int_use:N\g__pdf_backend_object_int }\c_space_tl~
+ /BBox[
+ isls {
+ landplus90 {
+ % geometry with landscape
+ \dim_to_decimal:n{\box_ht:N \l__pdf_backend_tmpa_box}~72.27~div~VResolution~mul~neg~
+ \dim_to_decimal:n{\box_wd:N \l__pdf_backend_tmpa_box}~72.27~div~Resolution~mul~
+ \dim_to_decimal:n{\box_dp:N \l__pdf_backend_tmpa_box}~72.27~div~VResolution~mul~0
+ }{
+ % landscape as class option
+ \dim_to_decimal:n{\box_dp:N \l__pdf_backend_tmpa_box}~72.27~div~VResolution~mul~neg~0~
+ \dim_to_decimal:n{\box_ht:N \l__pdf_backend_tmpa_box}~72.27~div~VResolution~mul~
+ \dim_to_decimal:n{\box_wd:N \l__pdf_backend_tmpa_box}~72.27~div~Resolution~mul~neg
+ } ifelse
+ }{
+ % portrait
+ 0~\dim_to_decimal:n{\box_ht:N \l__pdf_backend_tmpa_box}~72.27~div~VResolution~mul~
+ \dim_to_decimal:n{\box_wd:N \l__pdf_backend_tmpa_box}~72.27~div~Resolution~mul~
+ \dim_to_decimal:n{\box_dp:N \l__pdf_backend_tmpa_box}~72.27~div~VResolution~mul~neg
+ } ifelse
+ ]
+ \str_if_eq:eeF{#1}{}
+ {
+ product~(Distiller)~search~{pop~pop~pop~#2}{pop}ifelse~
+ }
+ /BP~pdfmark~grestore~
+ % content transformations required for appearances
+ gsave~currentpoint~currentpoint~translate~1~-1~scale~
+ isls { 90~landplus90 {neg} if~rotate } if~
+ neg~exch~neg~exch~translate
+ }
+ \box_use_drop:N\l__pdf_backend_tmpa_box
+ \__kernel_backend_postscript:n
+ {
+ grestore ~ mark ~ /EP~pdfmark
+ }
+ \str_if_eq:eeF{#1}{}
+ {
+ \__kernel_backend_postscript:x
+ {
+ product~(Ghostscript)~search~
+ {
+ pop~pop~pop~
+ mark~
+ { pdf.obj \int_use:c{c__pdf_backend_xform_ \tl_to_str:n {#1} _int} }
+ ~<<#2>>~/PUT~pdfmark
+ }{pop}ifelse
+ }
+ }
+ }
+ \box_set_dp:Nn \l__pdf_backend_tmpb_box { \c_zero_dim }
+ \box_set_ht:Nn \l__pdf_backend_tmpb_box { \c_zero_dim }
+ \box_set_wd:Nn \l__pdf_backend_tmpb_box { \c_zero_dim }
+ \mode_leave_vertical:
+ \box_use:N\l__pdf_backend_tmpb_box
+ }
+
+\cs_new_protected:Nn\__pdf_backend_xform_use:n
+ {
+ \__kernel_backend_postscript:x
+ {
+ gsave~currentpoint~translate~
+ % undo appearance-related content transformations
+ isls { 90~landplus90~not {neg} if~rotate } if~1~-1~scale~
+ mark~{ pdf.obj \int_use:c{c__pdf_backend_xform_ \tl_to_str:n {#1} _int }}~
+ /SP~pdfmark ~ grestore
+ }
+ }
+
+\cs_new:Npn \__pdf_backend_xform_ref:n #1
+ {
+ { pdf.obj \int_use:c{c__pdf_backend_xform_ \tl_to_str:n {#1} _int} }
+ }
+
+%% all
+\prg_new_conditional:Npnn \__pdf_backend_xform_if_exist:n #1 { p , T , F , TF }
+ {
+ \int_if_exist:cTF { c__pdf_backend_xform_ \tl_to_str:n {#1} _int }
+ { \prg_return_true: }
+ { \prg_return_false:}
+ }
+\prg_new_eq_conditional:NNn \pdfxform_if_exist:n\__pdf_backend_xform_if_exist:n
+ { TF , T , F , p }
+%%
+%%
+%% End of file `l3backend-testphase-dvips.def'.
diff --git a/experiments/xform-dvips/xformtest2.tex b/experiments/xform-dvips/xformtest2.tex
new file mode 100644
index 0000000..fe392d8
--- /dev/null
+++ b/experiments/xform-dvips/xformtest2.tex
@@ -0,0 +1,35 @@
+\RequirePackage{pdfmanagement-testphase}
+\DeclareDocumentMetadata{backend=dvips,uncompress,pdfversion=2.0}
+
+\documentclass[dvips]{article}
+%\usepackage[landscape]{geometry}
+% or
+%\documentclass[dvips,landscape]{article}
+
+\usepackage{l3pdffield-testphase,bearwear}
+\usepackage{attachfile2}
+\usepackage{pdfbase}
+\usepackage{xsavebox}
+
+\begin{document}\parindent=0pt
+\verb+l3backend-testphase-dvips.def+ (new):\\[2ex]
+\ExplSyntaxOn
+\pdfxform_new:nnn {test}{}{\mbox{qXFORMp}} % text with decenders
+some~text~with~decenders$\rightarrow$\pdfxform_use:n{test}
+\quad\quad\quad\quad\quad\quad again$\rightarrow$\pdfxform_use:n{test}
+\par
+\pdffield_appearance:nn {pdffield/bear}
+ {
+ \tikz\bear\bearwear[shirt=red,body~deco={\node[font=\tiny\bfseries,white]~at~(beartummy){Push};}];
+ }
+\group_begin:
+Push button:\pdfannot_dict_put:nnn {widget}{A}{<</S/Named /N/LastPage>>}
+\sffamily\bfseries\pdffield_pushbutton:n
+ {name=my/go,width=4cm,height=5cm,appearance=pdffield/bear,caption=GO~TO~LAST~PAGE,rollover-caption=click~me!}
+\group_end:
+
+\ExplSyntaxOff
+\newpage
+\Huge The End.
+\end{document}
+
More information about the latex3-commits
mailing list.