summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/intopdf/intopdf.sty
blob: 40214d20e89878a0cf197dd5d14a1927e96c985c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
%%
%% This is file `intopdf.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% intopdf.dtx  (with options: `package')
%% 
%% Copyright (C) 2018 by Marcel Krueger
%%
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any later
%% version. The latest version of this license is in:
%%
%% http://www.latex-project.org/lppl.txt
%%
%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{expl3}
\ProvidesExplPackage
  {intopdf}
  {2018/03/13}
  {0.0.1}
  {Embed non-PDF files into PDF with hyperlink}

\RequirePackage{hyperref}
\cs_new_eq:NN\__intopdf_escape_name:n\pdfescapename
\cs_new_eq:NN\__intopdf_escape_string:n\pdfescapestring
\cs_new:Nn\__intopdf_pdfobj:n{
  \tex_immediate:D\pdftex_pdfobj:D{<<#1>>}
}
\cs_new:Nn\__intopdf_pdfstream_file:nn{
  \tex_immediate:D\pdftex_pdfobj:D stream attr {#1} file {#2}
}
\cs_new:Nn\__intopdf_lastobj_ref:{
  \c_space_tl
  \int_use:N\pdftex_pdflastobj:D
  \c_space_tl
  0
  \c_space_tl
  R
}
\cs_new:Npn\__intopdf_annot:nnw#1#2{
  \leavevmode
  \pdftex_pdfstartlink:D attr{#1} user {#2}
}
\cs_new:Nn\__intopdf_annot_end:{
  \pdftex_pdfendlink:D
}
\cs_new:Nn\__intopdf_annot:nnn{
  \__intopdf_annot:nnw{#1}{#2}
  #3
  \__intopdf_annot_end:
}
\cs_new_protected:Nn\intopdf_attach_link:nnnn{
  \__intopdf_pdfstream_file:nn{
    /Subtype /\__intopdf_escape_name:n{#2}
  }{#1}
  \__intopdf_pdfobj:n{
    /Type /Filespec
    /F (\__intopdf_escape_string:n{#1})
    /EF << /F \__intopdf_lastobj_ref: >>
    /Desc (\__intopdf_escape_string:n{#3})
  }%
  \__intopdf_annot:nnn{
    \Hy@setpdfborder
    \tl_if_empty:NF\@pdfhighlight{
      /H\@pdfhighlight
    }
    \cs_if_free:NF\@urlbordercolor{
      /C[\@urlbordercolor]
    }
  }{
    /Subtype /Link
  }{
    \__intopdf_annot:nnn{}{
      /Subtype /FileAttachment
      /FS \__intopdf_lastobj_ref:
      /F\c_space_tl 416
      /CA\c_space_tl 0
      /Contents (\__intopdf_escape_string:n{#3})
    }{
      #4
    }
  }
}
\cs_new_protected:Npn\attachandlink#1[#2]#3#4{
  \intopdf_attach_link:nnnn{#1}{#2}{#3}{#4}
}
\endinput
%%
%% End of file `intopdf.sty'.