[pdftex] inverse operation to \pdffiledump

Alexander Grahn A.Grahn at fzd.de
Wed Jan 6 10:27:57 CET 2010


Hi,

I am looking for a way to embed binary files, such as png image files, as
hex-encoded strings into the TeX source of a document and to restore them
on the disk just before using them. As pdftex does not provide a primitive
to reverse the \pdffiledump operation, I tried to use the \pdfunescapehex
command, put as an argument to the \write command. However, the binary
file written is corrupt as can be demonstrated with the following example:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newwrite\grfFile
\immediate\openout\grfFile=tmp.png
\immediate\write\grfFile{%
  \pdfunescapehex {%
89504E470D0A1A0A0000000D494844520000001800000012080300000076
32EEAC00000060504C5445423212CA9A0AF1D21A986D06D4A00AA68008E1
BB13DAD5CB6A5312AC8E107A6A3AEAEAE2DBB012EECA1A8A62029A7A0EA5
9A7D948A64654A0EFEE29AFEFEF27262327A623AFEE222EEC20AE2E2DABA
8202BA8E0AC6AA12FEF2F2FEDA1A00000079EDA0BB0000002074524E53FF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
005C5C1BED00000001624B47441F050D10BD000000097048597300000048
000000480046C96B3E00000009767041670000001A0000001200CF6BEC27
000000CD4944415418D36D91EBB2C2200C8423D080353952DA9E4651FAFE
6F69E8F4A2A33B933FFBCD125860560D3EB629B5D10FF32ED0B9C47026E6
4713E2E51DF8F16A8ACA30DAD11FE0161E655A548CE470DBC0B33BAB0F53
9DC278ED861940CF011FCCB481C908250FFD5D94C51AD84061B250C11DE0
1F3F0042BF82C4EBEA65BD0251D27F033A29E96B622473005D9E5B10F567
880D17D80280CEC6FDBA68565240C825BF3FB01136B0487DDB3D8F4A320A
AB04C9354725B5444B8448E44E7FEF25D6DA93CDCE659B3E6BFFFD512FE7
BE2090ECBAD6BE0000000049454E44AE426082
  }%
}
\immediate\closeout\grfFile

\pdfximage {tmp.png}\pdfrefximage\pdflastximage

\bye
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Is it possible to somehow achieve the desired result?

Regards,
Alexander


More information about the pdftex mailing list