如何向 ab/w 文档添加几乎看不见的跟踪点?

如何向 ab/w 文档添加几乎看不见的跟踪点?

我想添加几乎看不见的跟踪点,其风格如下这些微型跟踪点到我的黑白文档。上面提到的跟踪点如下所示:

按照 (c) EFF 跟踪点,OP 链接见上文

跟踪点排列成 15x8 矩阵,在上述情况下,包括打印机信息、有关打印文档时间的信息等。我特别不想复制编码时间戳的机制,而是能够唯一地识别打印的页面(以及您可能已经猜到的,其副本)。

我向你保证会明智地、很少地使用它,并充分注意在我的文档上使用该机制。

如果有人有更实用但仍然不太显眼的方法来为文档添加这种类型的跟踪,我会非常高兴听到您的消息。遗憾的是,仅在背景中添加水印(也感谢 stackexchange 的好心人 ;) 并没有为我解决跟踪单个文档的问题。

答案1

以下是一些选项:

方法 1:点网格,编码为“基督教”


在此处输入图片描述


\setgrid[opt arg][opt arg]{letters}

\usegrid

第一个可选参数设置网格单元的大小,默认为10 pt(未输入单位)。第二个可选参数确定点的大小。点是通过缩放的周期。\scalebox第二个参数给出比例因子,默认为0.3。给定单词中的每个字母首先转换为字母表中的位置(a=1等),然后将该字母位置转换为 5 位二进制数。每个这样的二进制数都设置为一列垂直点:0 = 无点,1 = 点。从上到下读取列(第一列始终用点填充以供参考)。因此,在上图中:

c->3rd letter->00011-> no dot, no dot, no dot, dot, dot

然后宏\usegrid设置网格。在示例中,我将其放在左侧标题中。您可以将其放在任何地方。

\documentclass{article}
\usepackage{xparse}
\usepackage{graphicx}
\usepackage{fancyhdr}
\ExplSyntaxOn

\prop_new:N \g__docmark_alph_num_prop
\seq_new:N \l__docmark_name_bin_seq
\tl_new:N \l__docmark_box_list_tl
\box_new:N \c__dot_box
\box_new:N \c__grid_box

% key = val: key -> letter, val -> binary rep of letter pos in alphabet
\int_step_inline:nnnn {1}{1}{26}
    {
        \tl_set:Nx \l_tmpa_tl {\int_to_binary:n {#1}}
        \int_while_do:nn {\tl_count:N \l_tmpa_tl < 5}
            {
                \tl_put_left:Nn \l_tmpa_tl 0
            }
        \tl_set:Nx \l_tmpb_tl {\int_to_alph:n {#1}}
        \prop_put:NVV \g__docmark_alph_num_prop \l_tmpb_tl \l_tmpa_tl
    }

\NewDocumentCommand{\setgrid}{ O{10} O{.5} m }
    {
        \docmark_name_to_grid:nnn {#1}{#2}{#3}
    }

\cs_generate_variant:Nn \hbox_gset:Nn {NV}
\cs_new:Npn \docmark_name_to_grid:nnn #1#2#3
    {
        % scaled period, aka dot
        \hbox_gset:Nn \c__dot_box {\hbox_to_zero:n {\scalebox{#2}{.}}}

        % map letters of mandatory arg to 5 digit binaries
        \tl_map_inline:nn {#3}
            {
                \seq_put_right:Nx \l__docmark_name_bin_seq {\prop_get:Nn \g__docmark_alph_num_prop {##1}}
            }

        % "bookend" for reference
        \seq_put_left:Nn \l__docmark_name_bin_seq {11111}

        % for each 5 digit binary rep
        \seq_map_variable:NNn \l__docmark_name_bin_seq \l_tmpa_tl
            {
                \int_step_inline:nnnn {1}{1}{5}
                    {
                        % for each of the 5 digits in the rep
                        \tl_set:Nx \l_tmpb_tl {\tl_item:Nn \l_tmpa_tl {##1}}

                        % if zero, no dot
                        \tl_if_in:NnF \l_tmpb_tl {0}
                            {
                                % if not zero then dot, left/right in list --> up/down in dots
                                \fp_set:Nn \l_tmpa_fp {-(##1-1)*(\tl_item:Nn \l_tmpa_tl {##1})*(#1)}
                                \tl_put_right:Nx \l__docmark_box_list_tl {\box_move_up:nn {\fp_to_dim:N \l_tmpa_fp}{\box_use:N \c__dot_box}}
                            }
                    }

                % move to next column of dots
                \tl_put_right:Nn \l__docmark_box_list_tl {\hspace{#1pt}}
            }
        % box the dots
        \hbox_gset:NV \c__grid_box \l__docmark_box_list_tl
    }

\NewDocumentCommand{\usegrid}{}
    {
        \box_use:N \c__grid_box
    }

\ExplSyntaxOff

\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\lhead{\usegrid}

\begin{document}

\setgrid[5][.3]{christian}
Hi! I am a lovely sentence.

\end{document}

方法 2:文本中的点,编码为“abba”


在此处输入图片描述


这给出:

\markdoc{arg}{letters}

第一个参数再次设置点大小,第二个参数是字母。字母a1,...,aj将转换为整数,n1..nj如上所述。在ith文本行中,一个点将放置在ni第个字形下方。可以通过从左侧开始计数字形(字母、标点符号等)直到到达一个点,然后使用字母表中的相应字母来恢复字母。这将在每一页上发生。使用 进行编译lualatex。代码大量借用自此处:https://tex.stackexchange.com/a/58327/14100

\documentclass{article}
\usepackage{luacode,luatexbase}
\begin{luacode}
local GLYPH_ID = node.id("glyph")

-- adapted from https://tex.stackexchange.com/a/58327/14100
local number_sp_in_a_pdf_point = 65782

function math.round(num)
    return math.floor(num * 1000 + 0.5) / 1000
end

-- char width, whatsit, char pos, line number
local wd,w,pos,line

-- head is a linked list (next/prev entries pointing to the next node)
function mark_chars(head)
    while head do
      if head.id == 0 then
        -- an hbox
            pos = 0
        mark_chars(head.list)
            line = line + 1
      elseif head.id == GLYPH_ID then
            pos = pos + 1
            if pos == t[line] then
            -- if (character position) = (number of current character in name) 
        w = node.new("whatsit","pdf_literal")
        wd = math.round(head.width  / number_sp_in_a_pdf_point)
                -- cf. http://www.tug.org/TUGboat/tb32-2/tb101isambert.pdf
        w.data = string.format("q 0.2 G %g w %g -2.8 m %g %g l s Q",p,-wd/2,-wd/2,-2.8+p)
        -- insert this new node after the current glyph and move pointer (head) to
        -- the new whatsit node
        w.next = head.next
        w.prev = head
        head.next = w
        head = w
            end
      end -- if
      head = head.next
  end -- while
  return true
end -- function

char_tab = {a=1, b=2, c=3, d=4, e=5, f=6, g=7, h=8, i=9, j=10, k=11, l=12, m=13, n=14, o=15, p=16, q=17, r=18, s=19, t=20, u=21, v=22, w=23, x=24, y=25, z=26}

t = {}
function encode(name)
    -- step through name
    for i = 1, #name do
            -- read each char
        local s = string.sub(name, i, i)
            -- store its numeric equiv in table
        t[i]=char_tab[s]
    end
end

function mark_page(head)
    line = 0
    mark_chars(head)
    return head
end
\end{luacode}
\newcommand\markdoc[2]{%
    \directlua{encode("#2")}%
    \directlua{p=#1}
    \directlua{luatexbase.add_to_callback('pre_output_filter', mark_page, "mark_page")}%
}
\begin{document}
\markdoc{.3}{abba}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer tincidunt condimentum quam, quis dignissim felis adipiscing rhoncus. Mauris quis imperdiet ligula. Maecenas quis dolor vel nunc egestas consectetur. Donec porttitor dictum tincidunt. Nunc orci ipsum, mattis vitae lobortis ut, porta eget mi. Quisque adipiscing, lacus quis molestie fermentum, nunc odio consectetur arcu, nec luctus dolor nisi quis erat. Aliquam sit amet venenatis est. Sed ut venenatis elit. Maecenas lacus leo, aliquam nec fringilla eu, lobortis quis augue.

Mauris vestibulum, augue non convallis vestibulum, ante enim aliquam eros, sit amet sollicitudin sapien ante ac diam. Quisque mi purus, vehicula eu feugiat a, blandit facilisis est. Etiam sit amet dui eget purus ultricies volutpat. Integer eu enim leo, eu faucibus neque. Donec ut sollicitudin nunc. Etiam tincidunt justo eu ante consectetur consequat. Suspendisse ultricies faucibus odio. Donec felis risus, lobortis eu pellentesque quis, imperdiet non augue. Sed massa dolor, ultrices at ultricies in, dapibus a ante. Sed sit amet augue felis. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

\end{document}

答案2

在我看来,这类似于二维码。然后,您可以根据需要设置大小和对比度。显然,越明显,打印和复制效果就越好。

相关内容