[texhax] [pdftex] image XObjects in pdfTeX or XeTeX PDF output?

Paul Isambert zappathustra at free.fr
Fri Nov 19 21:46:10 CET 2010

Here's a simple way to use images in pdfTeX:



  \pdfximage #2 {#3}%
#1 at image\endcsname{\pdfrefximage\the\pdflastximage\relax}%

  \ifcsname #1 at image\endcsname
    \csname #1 at image\endcsname
    \errmessage{Image `#1' hasn't been loaded}%


Then you can use \loadimage{<name>}<specs>{<file>} and \useimage{<name>}.

The <specs> are optional, and are of the form:

width <length> height <length> depth <length>

in any order. If none is present, the image is loaded at its natural size. If
one is present, the others are scaled accordingly. Naturally an image has a
depth of 0, but you can use it anyway. For instance:

% Natural size

% Height scaled to match width
\loadimage{myimg} width 3cm {img.jpg}

% Image deformed, probably
\loadimage{myimg} width 3cm height 1cm {img.jpg}

I don't think multiple posting is necessary. Please stick to one list or
another, and then turn to another list if you get no answer. Which is quite rare
if you post on texhax.


Selon Peter Davis <pfd at pfdstudio.com>:

> Is there a way in LaTeX, with either pdfTeX or XeTeX, to specify image and
> form XObjects for the final PDF document?  I want to generate a document
> which uses the same images multiple times, so I'd prefer the image just be
> included once, and then referenced each time it's needed on a page.
> Is this possible?
> Thank you!
> -pd

More information about the texhax mailing list