[luatex] combining files with pure LuaTeX
Reinhard Kotucha
reinhard.kotucha at web.de
Sun Sep 26 16:17:06 CEST 2010
On 26 September 2010 Pablo Rodríguez wrote:
> Hi there,
>
> I have to combine PDF of two kinds in a way I describe bellow using only
> the LuaTeX win32 binary distributed at
> http://foundry.supelec.fr/gf/project/luatex (installing a complete TeX
> distribution isn't an option for me). I guess that this could be
> achieved with a LuaTeX script, but I don't know how.
>
> I have two kind of PDF documents: A4-paged document and an image. Both
> are given to me. I don't have to modify them, only to combine them in a
> new document. The only thing is to place the image.pdf on a specific
> location on the pages of the document.pdf. document.pdf could have
> multiple pages and image.pdf must be added on all pages, but not all on
> the same position.
>
> How could this be achieved? (The whole thing is a more complex process,
> but this is the first step.)
I did this with pdftex a week ago, but it works with luatex too. The
first step is to place the image on a single A4 page and call this file
background.pdf
Then copy the stuff below to a file called add-background.tex:
-------------------------------------------------------------------
% add-background.tex
%
% Usage: luatex add-background <some_file>.pdf
%
% Copyright (C) 2010 Reinhard Kotucha.
% You may freely use, modify and/or distribute this file.
\newlinechar`^^J \ifdefined\documentclass\nonstopmode
\errmessage{^^J! ERROR: Use luatex, not lualatex!^^J!
================================^^J}
\batchmode\fi
\pdfcompresslevel=9 \pdfmapfile{}
\pdfoutput=1 \pdfminorversion=5 \pdfobjcompresslevel=3
\pdfhorigin0pt \pdfvorigin0pt \count0=1 \catcode`\_=12
\pdfximage page 1 {background.pdf}
\newcount\background \background=\pdflastximage
\def\recurse{\pdfximage page \count0 {\file}%
\setbox0\hbox{\rlap{\expandafter\pdfrefximage\background}%
\pdfrefximage\pdflastximage}%
\pdfpagewidth=\wd0 \pdfpageheight=\ht0 \shipout\box0
\advance\count0 by 1
\ifnum\count0>\pdflastximagepages\expandafter\end
\else\expandafter\recurse\fi}
\def\process#1 {\def\file{#1}\recurse}\catcode32=13 \let\ \space
\everypar{\setbox2\lastbox\process}
-------------------------------------------------------------------
Then run
luatex add-background <your-file>
on the command line, where <your-file> is the PDF file you want to put
the background image on each page.
You can set
\pdfminorversion=4 \pdfobjcompresslevel=0
if necessary, it depends on the software you are using in further
steps. I had to do this because the Multivalent library I was using
didn't support object stream compression.
Regards,
Reinhard
--
----------------------------------------------------------------------------
Reinhard Kotucha Phone: +49-511-3373112
Marschnerstr. 25
D-30167 Hannover mailto:reinhard.kotucha at web.de
----------------------------------------------------------------------------
Microsoft isn't the answer. Microsoft is the question, and the answer is NO.
----------------------------------------------------------------------------
More information about the luatex
mailing list