summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/media9/pdfbase.sty
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/media9/pdfbase.sty')
-rw-r--r--macros/latex/contrib/media9/pdfbase.sty228
1 files changed, 104 insertions, 124 deletions
diff --git a/macros/latex/contrib/media9/pdfbase.sty b/macros/latex/contrib/media9/pdfbase.sty
index eeab650bf6..fd21ee6c3b 100644
--- a/macros/latex/contrib/media9/pdfbase.sty
+++ b/macros/latex/contrib/media9/pdfbase.sty
@@ -84,7 +84,7 @@
%
% \pbs_pdfxform:nnnnn
% #1: add pgf/tikz resources (transparency, shading)? (1|0) %dvipdfmx/xetex
-% #2: used as PDF annotation appearance? (1|0) %dvips/pdftex
+% #2: (not used)
% #3: additional resources %all BUT dvips
% #4: additional dictionary entries
% #5: savebox number
@@ -158,8 +158,8 @@
\RequirePackage{l3keys2e}
-\def\g@pbs@date@tl{2021/06/11}
-\def\g@pbs@version@tl{0.47}
+\def\g@pbs@date@tl{2021/07/25}
+\def\g@pbs@version@tl{0.48}
\NeedsTeXFormat{LaTeX2e}[2020-10-01]
\ProvidesExplPackage{pdfbase}{\g@pbs@date@tl}{\g@pbs@version@tl}
@@ -605,7 +605,7 @@
}
}
- \cs_new_protected_nopar:Nn\pbs_pdfxform:nnnnn{ % #2 not used
+ \cs_new_protected_nopar:Nn\pbs_pdfxform:nnnnn{
\group_begin:
\hbox_set:Nn\l_tmpa_box{
\special{pdf:bxobj~@pbs@obj\int_use:N\g_pbs_obj_int\space
@@ -1071,8 +1071,8 @@
output.
}
- \cs_new_protected_nopar:Nn\pbs_pdfxform:nnnnn{ % #1, #3 not used (resources
- \mode_leave_vertical: % are managed automatically)
+ \cs_new_protected_nopar:Nn\pbs_pdfxform:nnnnn{% #1, #3 not used (resources
+ \mode_leave_vertical: % are managed automatically)
%rescale box to fit within the papersize while distilling
\tl_gset:cx{scale_{pbs@obj\int_use:N\g_pbs_obj_int}}{\fp_eval:n{min(1.0,
\dim_ratio:nn{\paperwidth}{\box_wd:N#5},
@@ -1083,23 +1083,13 @@
}{
\tl_use:c{scale_{pbs@obj\int_use:N\g_pbs_obj_int}}
}
- \group_begin:
- %mark bbox of box#5
- \hbox_set:Nn\l_tmpa_box{
- % lower left
- \box_move_down:nn{\box_dp:N#5}{\hbox_to_zero:n{\pbs_special:n{
- currentpoint~/pbs@lly~exch~def~/pbs@llx~exch~def
- }}}
- \skip_horizontal:n{\box_wd:N#5}
- % upper right
- \box_move_up:nn{\box_ht:N#5}{\hbox_to_zero:n{\pbs_special:n{
- currentpoint~/pbs@ury~exch~def~/pbs@urx~exch~def
- }}}
- }
- \box_set_wd:Nn\l_tmpa_box{\c_zero_dim}
- \box_set_ht:Nn\l_tmpa_box{\c_zero_dim}
- \box_set_dp:Nn\l_tmpa_box{\c_zero_dim}\box_use_drop:N\l_tmpa_box
- \group_end:
+ %store dimensions (in "dots" units)
+ \tl_set:Nx\l_pbs_width_tl{
+ \dim_to_decimal:n{\box_wd:N#5}~72.27~div~Resolution~mul~}
+ \tl_set:Nx\l_pbs_height_tl{
+ \dim_to_decimal:n{\box_ht:N#5}~72.27~div~VResolution~mul~}
+ \tl_set:Nx\l_pbs_depth_tl{
+ \dim_to_decimal:n{\box_dp:N#5}~72.27~div~VResolution~mul~}
%additional dict entries
\tl_set:Nx\l_tmpa_tl{#4} \tl_trim_spaces:N\l_tmpa_tl
\pbs_special:n{
@@ -1109,61 +1099,58 @@
%clipbox (i. e. page area) available for distilling; outlying parts
%get clipped
{
- clippath~pathbbox~newpath~pop~pop~translate~
- pbs@llx~neg~pbs@ury~neg~translate
+ clippath~pathbbox~newpath~pop~pop~
+ isls {
+ landplus90 {
+ % pkg geometry with landscape option
+ exch~pbs@curx~sub~\l_pbs_height_tl~add~
+ exch~pbs@cury~sub
+ }{
+ % landscape as class option
+ exch~pbs@curx~sub~\l_pbs_depth_tl~add~
+ exch~pbs@cury~sub~\l_pbs_width_tl~add
+ } ifelse
+ }{
+ % portrait
+ exch~pbs@curx~sub~
+ exch~pbs@cury~sub~\l_pbs_depth_tl~add
+ } ifelse~translate
}?pdfmark~
%move origin (0,0) to the current position
gsave~pbs@curx~pbs@cury~translate~
- %distillation-bbox left and top coords
- clippath~pathbbox~newpath~pop~pop~/pbs@bbox@top~exch~def~
- /pbs@bbox@left~exch~def~
%distill graphics to XObject
mark~
/_objdef~{pbs@obj\int_use:N\g_pbs_obj_int}~
/BBox~[
- pbs@bbox@left~pbs@bbox@top~pbs@bbox@left~pbs@urx~
- pbs@llx~sub~add~pbs@bbox@top~pbs@lly~pbs@ury~sub~add
- ]~
+ isls {
+ landplus90 {
+ % geometry with landscape
+ \l_pbs_height_tl~neg~\l_pbs_width_tl~\l_pbs_depth_tl~0
+ }{
+ % landscape as class option
+ \l_pbs_depth_tl~neg~0~\l_pbs_height_tl~\l_pbs_width_tl~neg
+ } ifelse
+ }{
+ % portrait
+ 0~\l_pbs_height_tl~\l_pbs_width_tl~\l_pbs_depth_tl~neg
+ } ifelse
+ ]
%insert additional dict entries (the Distiller way)
\str_if_eq:eeF{\l_tmpa_tl}{}{
product~(Distiller)~search~{pop~pop~pop~\l_tmpa_tl}{pop}ifelse~
}
/BP~pdfmark~grestore~
- \int_compare:nT{#2>\c_zero_int}{
- %operations needed if used as annotation appearance
- {
- % landscape mode (as class option, powerdot,
- % geometry or typearea /w pkg option)
- isls{
- /pbs@dxdy~{
- pbs@urx~pbs@llx~sub~abs~pbs@ury~pbs@lly~sub~abs~div
- }~bind~def~
- /pbs@dydx~{1~pbs@dxdy~div}~bind~def~
- /pbs@cx~{pbs@urx~pbs@llx~add~2~div}~bind~def~
- /pbs@cy~{pbs@ury~pbs@lly~add~2~div}~bind~def~
- % graphics needs to be rescaled for some reason ...
- [pbs@dxdy~0~0~pbs@dydx~1~pbs@dxdy~sub~pbs@cx~mul~
- 1~pbs@dydx~sub~pbs@cy~mul]~concat~
- %... rotated by 270 degrees ...
- [0~-1~1~0~pbs@cx~pbs@cy~sub~pbs@cx~pbs@cy~add]~concat~
- landplus90{
- %... and flipped around vertical axis (geometry, powerdot)
- [-1~0~0~1~pbs@llx~pbs@urx~add~0]~concat
- }{
- %... and flipped around horizontal axis (other)
- [1~0~0~-1~0~pbs@lly~pbs@ury~add]~concat
- }ifelse
- }{
- % flip around horizontal axis in portrait mode
- [1~0~0~-1~0~pbs@lly~pbs@ury~add]~concat
- }ifelse
- }?pdfmark
- }
+ % content transformations required for appearances
+ {
+ pbs@curx~pbs@cury~2~copy~translate~1~-1~scale~
+ isls {90~landplus90 {neg} if~rotate} if~
+ neg~exch~neg~exch~translate
+ }?pdfmark
}
\box_set_wd:Nn#5{\c_zero_dim}
\box_set_ht:Nn#5{\c_zero_dim}
\box_set_dp:Nn#5{\c_zero_dim}\box_use_drop:N#5
- \pbs_special:n{~mark~/EP~pdfmark~grestore}
+ \pbs_special:n{mark~/EP~pdfmark~grestore}
%insert additional dict entries (the Ghostscript way)
\str_if_eq:eeF{\l_tmpa_tl}{}{
\pbs_special:n{
@@ -1200,7 +1187,10 @@
}
}
\pbs_special:n{
- gsave~currentpoint~translate~1~\tl_use:c{scale_#1}~div~dup~scale~
+ gsave~currentpoint~translate~
+ % undo appearance-related content transformations
+ isls {90~landplus90~not {neg} if~rotate} if~
+ 1~\tl_use:c{scale_#1}~div~dup~neg~scale~
mark~#1~/SP~pdfmark~grestore
}
}
@@ -1518,8 +1508,8 @@
\RequirePackage{l3keys2e}
-\def\g@pbs@date@tl{2021/06/11}
-\def\g@pbs@version@tl{0.47}
+\def\g@pbs@date@tl{2021/07/25}
+\def\g@pbs@version@tl{0.48}
\NeedsTeXFormat{LaTeX2e}[2020-10-01]
\ProvidesExplPackage{pdfbase}{\g@pbs@date@tl}{\g@pbs@version@tl}
@@ -2381,8 +2371,8 @@
output.
}
- \cs_new_protected_nopar:Nn\pbs_pdfxform:nnnnn{ % #1, #3 not used (resources
- \mode_leave_vertical: % are managed automatically)
+ \cs_new_protected_nopar:Nn\pbs_pdfxform:nnnnn{% #1, #3 not used (resources
+ \mode_leave_vertical: % are managed automatically)
%rescale box to fit within the papersize while distilling
\tl_gset:cx{scale_{pbs@obj\int_use:N\g_pbs_obj_int}}{\fp_eval:n{min(1.0,
\dim_ratio:nn{\paperwidth}{\box_wd:N#5},
@@ -2393,23 +2383,13 @@
}{
\tl_use:c{scale_{pbs@obj\int_use:N\g_pbs_obj_int}}
}
- \group_begin:
- %mark bbox of box#5
- \hbox_set:Nn\l_tmpa_box{
- % lower left
- \box_move_down:nn{\box_dp:N#5}{\hbox_to_zero:n{\pbs_special:n{
- currentpoint~/pbs@lly~exch~def~/pbs@llx~exch~def
- }}}
- \skip_horizontal:n{\box_wd:N#5}
- % upper right
- \box_move_up:nn{\box_ht:N#5}{\hbox_to_zero:n{\pbs_special:n{
- currentpoint~/pbs@ury~exch~def~/pbs@urx~exch~def
- }}}
- }
- \box_set_wd:Nn\l_tmpa_box{\c_zero_dim}
- \box_set_ht:Nn\l_tmpa_box{\c_zero_dim}
- \box_set_dp:Nn\l_tmpa_box{\c_zero_dim}\box_use_drop:N\l_tmpa_box
- \group_end:
+ %store dimensions (in "dots" units)
+ \tl_set:Nx\l_pbs_width_tl{
+ \dim_to_decimal:n{\box_wd:N#5}~72.27~div~Resolution~mul~}
+ \tl_set:Nx\l_pbs_height_tl{
+ \dim_to_decimal:n{\box_ht:N#5}~72.27~div~VResolution~mul~}
+ \tl_set:Nx\l_pbs_depth_tl{
+ \dim_to_decimal:n{\box_dp:N#5}~72.27~div~VResolution~mul~}
%additional dict entries
\tl_set:Nx\l_tmpa_tl{#4} \tl_trim_spaces:N\l_tmpa_tl
\pbs_special:n{
@@ -2419,61 +2399,58 @@
%clipbox (i. e. page area) available for distilling; outlying parts
%get clipped
{
- clippath~pathbbox~newpath~pop~pop~translate~
- pbs@llx~neg~pbs@ury~neg~translate
+ clippath~pathbbox~newpath~pop~pop~
+ isls {
+ landplus90 {
+ % pkg geometry with landscape option
+ exch~pbs@curx~sub~\l_pbs_height_tl~add~
+ exch~pbs@cury~sub
+ }{
+ % landscape as class option
+ exch~pbs@curx~sub~\l_pbs_depth_tl~add~
+ exch~pbs@cury~sub~\l_pbs_width_tl~add
+ } ifelse
+ }{
+ % portrait
+ exch~pbs@curx~sub~
+ exch~pbs@cury~sub~\l_pbs_depth_tl~add
+ } ifelse~translate
}?pdfmark~
%move origin (0,0) to the current position
gsave~pbs@curx~pbs@cury~translate~
- %distillation-bbox left and top coords
- clippath~pathbbox~newpath~pop~pop~/pbs@bbox@top~exch~def~
- /pbs@bbox@left~exch~def~
%distill graphics to XObject
mark~
/_objdef~{pbs@obj\int_use:N\g_pbs_obj_int}~
/BBox~[
- pbs@bbox@left~pbs@bbox@top~pbs@bbox@left~pbs@urx~
- pbs@llx~sub~add~pbs@bbox@top~pbs@lly~pbs@ury~sub~add
- ]~
+ isls {
+ landplus90 {
+ % geometry with landscape
+ \l_pbs_height_tl~neg~\l_pbs_width_tl~\l_pbs_depth_tl~0
+ }{
+ % landscape as class option
+ \l_pbs_depth_tl~neg~0~\l_pbs_height_tl~\l_pbs_width_tl~neg
+ } ifelse
+ }{
+ % portrait
+ 0~\l_pbs_height_tl~\l_pbs_width_tl~\l_pbs_depth_tl~neg
+ } ifelse
+ ]
%insert additional dict entries (the Distiller way)
\str_if_eq:eeF{\l_tmpa_tl}{}{
product~(Distiller)~search~{pop~pop~pop~\l_tmpa_tl}{pop}ifelse~
}
/BP~pdfmark~grestore~
- \int_compare:nT{#2>\c_zero_int}{
- %operations needed if used as annotation appearance
- {
- % landscape mode (as class option, powerdot,
- % geometry or typearea /w pkg option)
- isls{
- /pbs@dxdy~{
- pbs@urx~pbs@llx~sub~abs~pbs@ury~pbs@lly~sub~abs~div
- }~bind~def~
- /pbs@dydx~{1~pbs@dxdy~div}~bind~def~
- /pbs@cx~{pbs@urx~pbs@llx~add~2~div}~bind~def~
- /pbs@cy~{pbs@ury~pbs@lly~add~2~div}~bind~def~
- % graphics needs to be rescaled for some reason ...
- [pbs@dxdy~0~0~pbs@dydx~1~pbs@dxdy~sub~pbs@cx~mul~
- 1~pbs@dydx~sub~pbs@cy~mul]~concat~
- %... rotated by 270 degrees ...
- [0~-1~1~0~pbs@cx~pbs@cy~sub~pbs@cx~pbs@cy~add]~concat~
- landplus90{
- %... and flipped around vertical axis (geometry, powerdot)
- [-1~0~0~1~pbs@llx~pbs@urx~add~0]~concat
- }{
- %... and flipped around horizontal axis (other)
- [1~0~0~-1~0~pbs@lly~pbs@ury~add]~concat
- }ifelse
- }{
- % flip around horizontal axis in portrait mode
- [1~0~0~-1~0~pbs@lly~pbs@ury~add]~concat
- }ifelse
- }?pdfmark
- }
+ % content transformations required for appearances
+ {
+ pbs@curx~pbs@cury~2~copy~translate~1~-1~scale~
+ isls {90~landplus90 {neg} if~rotate} if~
+ neg~exch~neg~exch~translate
+ }?pdfmark
}
\box_set_wd:Nn#5{\c_zero_dim}
\box_set_ht:Nn#5{\c_zero_dim}
\box_set_dp:Nn#5{\c_zero_dim}\box_use_drop:N#5
- \pbs_special:n{~mark~/EP~pdfmark~grestore}
+ \pbs_special:n{mark~/EP~pdfmark~grestore}
%insert additional dict entries (the Ghostscript way)
\str_if_eq:eeF{\l_tmpa_tl}{}{
\pbs_special:n{
@@ -2510,7 +2487,10 @@
}
}
\pbs_special:n{
- gsave~currentpoint~translate~1~\tl_use:c{scale_#1}~div~dup~scale~
+ gsave~currentpoint~translate~
+ % undo appearance-related content transformations
+ isls {90~landplus90~not {neg} if~rotate} if~
+ 1~\tl_use:c{scale_#1}~div~dup~neg~scale~
mark~#1~/SP~pdfmark~grestore
}
}