[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#260132: tetex-bin: what does pdftosrc do?



On 20.07.04 Frank Küster (frank@debian.org) wrote:
> Hilmar Preusse <hille42@web.de> schrieb:

Hi,

> > Must have missed that. Preliminary man page attached.
> 
> I think this is not the whole story. I cannot give you references, but I
> think that one can generally include several "stream objects" into a pdf
> file. The objects need not be TeX source code, it can as well be an
> arbitrary text or just any file.
> 
> See e.g.
> 
> http://www.sics.se/~joe/erlpdf.pdf "Using PDF to distribute code"
> 
Complete rewrite of the man page attached. Well, some things don't
satisfy me yet. Should we mention \pdfobj and \pdflastobj, but not
\pdfrefobj? What is the special thing at stream objects vs. normal
objects?
I've included some TeX example code. I have here the permission of C.
V. Radhakrishnan to use his code.

Suggestions, comments?
  Hilmar
-- 
sigmentation fault
.\" Hey, Emacs!  This is an -*- nroff -*- source file.
.\" 
.\" Copyright (C) 2004 Hilmar Preusse <hille42@web.de>
.\" 
.\" This is free software; you can redistribute it and/or modify it under
.\" the terms of the GNU General Public License as published by the Free
.\" Software Foundation; either version 2, or (at your option) any later
.\" version.
.\" 
.\" This is distributed in the hope that it will be useful, but WITHOUT
.\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
.\" FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
.\" for more details.
.\" 
.\" You should have received a copy of the GNU General Public License with
.\" your Debian GNU/Linux system, in /usr/share/common-licenses/GPL, or with
.\" the dpkg source package as the file COPYING.  If not, write to the Free
.\" Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
.\" 
.\"
.\" =====================================================================
.\" HELP!!!! I found no convenient way to include the TeX source code
.\" verbatim. If there is a better way to do that, feel free to improve!
.\" =====================================================================
.\"
.\"
.TH "PDFTOSRC" "1" "July 2004" "Debian/GNU Linux" ""
.SH "NAME"
pdftosrc \- extracts stream objects from pdf\-Files.
.SH "SYNOPSIS"
\fBpdftosrc\fR \fI<PDF\-file>\fR [<stream\-object\-number>]
.SH "DESCRIPTION"
A pdf\-file simply consists of a set of different kind of objects,
which are linked to each other and refer to each other. One special
kind of objects are stream objects. \fBpdftosrc\fR is written to extract
single stream objects out of a pdf file.
.br 
The idea behind that program is that one can include the TeX-source code
(or parts of it) into the pdf file as stream object.
pdfTeX provides the low level command \fB\\pdfobj\fR to put objects
into a pdf-file. Further there exist \fB\\pdflastobj\fR to return the
number of the object created.
.P
A simple example could look like:
.P
 \\documentclass{minimal}
 \\usepackage{times}

 \\begingroup\\pdfcompresslevel=0
 \\immediate\\pdfobj 
 stream attr {/Type /SourceFile /SourceName 
 (The TeX sources)}
 file{\\jobname.tex}
 \\pdfcatalog{/SourceObject \\the\\pdflastobj\\space 0 R}
 \\endgroup

 \\begin{document}
 test
 \\end{document}
.P
Call "\fBpdftosrc\fR \fI<PDF\-file>\fR 1" to extract the first stream
object, which contains the complete TeX-Code of the compiled pdf.
.br
\\pdfcompresslevel=0 were used to make sure the included streams will
not be compressed (and hence will be unreadable by human) when written
into the pdf\-file. \fBpdftosrc\fR will automatically
uncompress compressed streams, when they are extracted, so this is only
necessary if anybody wants to view at the pdf\-file using a text editor.
.br
\\usepackage{times} were used to get a font, which comes with Acrobat\*R
(and Ghostscript) and to not clutter up the pdf\-file by too much binary
stuff, cause no fonts have to be included.
.br 
A more complete example can be found in the section \fBEXAMPLE\fR.
.SH "SEE ALSO"
.BR pdftex (1),
.BR pdflatex (1),
The pdfTeX user manual,
PDF specification by Adobe.
.SH "EXAMPLE"
The example was contributed by C. V. Radhakrishnan and later simplified.
Thanks! Stream 1 is the complete source code. Stream 2-4 are the 3
equations of the document.
.P
 \\documentclass[a4paper]{article}

 \\begingroup\\pdfcompresslevel=0
  \\immediate\\pdfobj
  stream attr {/Type /SourceFile /SourceName
  (The TeX sources)}
  file{\jobname.tex}
  \\pdfcatalog{/SourceObject \\the\\pdflastobj\\space 0 R}
 \\endgroup

 \\begin{document}

 \\pdfcompresslevel=9
 \\makeatletter

 \\def\\keepsrc{%
  \\begingroup\\pdfcompresslevel=0
   \\immediate\\pdfobj
   stream attr {/Type /SourceFile /SourceName
   (The TeX sources)}
   file{tmp.tex}
   \\pdfcatalog{/SourceObject \\the\\pdflastobj\\space 0 R}
  \\endgroup
 }
 \\newwrite\\srcout

 \\long\\def\\srceqn#1{\\def\\next{#1}
  \\immediate\\openout\\srcout=src.tex
  \\immediate\\write\\srcout
   {\\expandafter\\strip@prefix\\meaning\\next}
  \\immediate\\closeout\\srcout
  \\keepsrc
 #1}

 \\makeatother

 \\srceqn{\\[
 a+b=c
 \\]}

 \\srceqn{\\[
 c-a=b
 \\]}

 \\srceqn{\\[
 c-b=a
 \\]}

\\end{document}
.SH "AUTHOR"
This manual page was written by Hilmar Preusse <hille42@web\&.de>, for
the Debian GNU/Linux system\&.  It may be used by other distributions
without contacting the author\&.  Any mistakes or omissions in the
manual page are my fault; inquiries about or corrections to this
manual page should be directed to me (and not to the primary author)\&.
.SH "THANKS TO"
C. V. Radhakrishnan (for the example code),
Frank Küster.
.\" David H. Silber, 
.\" Carl Streeter.

Reply to: