[dvipdfmx] Patch to support named destinations in "pdf:image" specials

Max Chernoff mseven at telus.net
Wed Feb 21 10:11:24 CET 2024


Hi all,

I've attached a patch to let (x)dvipdfmx select pages by name instead of
number with the "pdf:image" special. This is already directly supported
by pdfTeX, and indirectly supported in LuaTeX (via Lua).

The feature isn't documented anywhere in the pdfTeX manual, but it's
fairly easy to demonstrate. If you copy the dvipdfmx manual to the
current directory

    $ cp "$(kpsewhich --format=doc dvipdfmx.pdf)" .

and compile the following document with pdftex,

    \pdfximage named {1c} {dvipdfmx.pdf}
    \pdfrefximage\pdflastximage
    \bye

then you get the page with the internal PDF name "1c", which should be
"Figure 4.2" with a big "X" at the top. With this patch, the following
document should give the same results with xetex (or *tex + dvipdfmx):

    \special{pdf:minorversion 7}
    \vbox to 0pt{
        \leavevmode
        \lower 10in \hbox{
            \special{pdf:image named "1c" (dvipdfmx.pdf)}
        }
        \vss
    }
    \bye

For a more useful example, download and install

    https://github.com/gucci-on-fleek/unnamed-emoji

then compile the following with tex + dvipdfmx:

    \input unnamed-emoji
    \font\seventeenrm=cmr17

    \emoji{goose}
    \emoji{🦢}
    {\def\emojifont{openmoji}\emoji{duck}}
    \emoji{0x1f427}
    \emoji{man: medium skin tone, curly hair}

    X\emoji{duck}X \seventeenrm X\emoji{duck}X

    \bye

or the following with xelatex:

    \documentclass{article}
    \usepackage{unnamed-emoji}

    \begin{document}
        \emoji{goose}          \emoji{🦢}
        \emoji[openmoji]{duck} \emoji{0x1f427}
    \end{document}

There are two separate patch files -- the first adds basic support for
"pdf:image named" for pages with direct /MediaBox'es; the second
builds on the first and does some more complex refactoring to support
pages with inherited /MediaBox'es. 

Both patches compile without any errors or warnings, and they appear to
work properly based off of my testing. Still, I'm really not much of a
C programmer, so I've probably made some mistakes. Please let me know if
you want me to make any changes.

Thanks,
-- Max
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-named-keyword-to-pdf-image-special.patch
Type: text/x-patch
Size: 12645 bytes
Desc: 
URL: <https://tug.org/pipermail/dvipdfmx/attachments/20240221/0eb8dd80/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Add-support-for-inherited-MediaBox-es-with-named-pdf.patch
Type: text/x-patch
Size: 18445 bytes
Desc: 
URL: <https://tug.org/pipermail/dvipdfmx/attachments/20240221/0eb8dd80/attachment-0003.bin>


More information about the dvipdfmx mailing list.