texmacs-dev
[Top][All Lists]
Advanced

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

RE: [Texmacs-dev] conversion to pdf


From: hadar raz
Subject: RE: [Texmacs-dev] conversion to pdf
Date: Sun, 26 Mar 2006 12:29:05 +0200

Henri,

Some answers:

> 
> 
> hadar raz wrote:
> 
> >Hi all,
> >
> >Searching this list, I found a few posts about pdf 
> conversion, and even
> >one attempt at creating a new converter that dates back to 
> 2002, but I
> >don't think anything came out of it.
> >
> As far as I can remember, there have been problems with fonts,
> and also with inserting images connected to the PS/PDF exports,
> but at least part of these problems have been solved. In
> order to be able to give a more detailed answer about the
> past attempts / current state of TeXmacs, I would need you
> to provide more precise references about this attempt of
> creating a new converter (or other things), because I can't
> find it on the mailing list archives.
> 
I don't know much about this last attempt, but searching the dev-list for "pdf" 
brings up this thread, and some related massages:

http://lists.gnu.org/archive/html/texmacs-dev/2002-04/msg00056.html

Maybe Joris will know what it's about...


> 
> >Looking at the internal ps converter, I realized that it is a printer
> >device, and as such can convert directly to pdf as well, 
> since the pdf
> >file structure contains the same drawing and text routines. 
> Ofcoarse the
> >file header and some other pdf specific data will have to change as
> >well, but it is of no importance at the moment.
> >The two biggest problems as I see them are:
> >
> >1. pdf file contains a 'catalog' which is located at the end of the
> >file, and points to all the different pieces of information 
> in the file.
> >It will have to be implimented.
> >
> >2. The pdf format is at it's best when it contains 
> hyperlinks, just like
> >the TeXmacs files themselves. The internal ps printer device ignores
> >them at the moment.
> >
> >  
> >
> What you want is not clearly described. Given that you discuss
> the (lack of :-( ) implementation of the PDF catalog together
> with the lack of implementation of the PDF hyperlinks, I would
> guess that your problem is to write a TeXmacs document with links,
> and have it automatically converted to a PDF file with the same
> links (i.e. : *working* links :-).
> 
> Am I right, or do you have in fact a more detailed, a little
> bit different, or a more specific, etc. idea in your mind ?
> 
The so called 'catalog' points to the different parts of the document, like 
fonts, streams, text,etc', and is located at the end of the file. For example, 
this is a minimal pdf file taken from PDF_reference_1.6 from the Adobe site:

%PDF−1.4
1 0 obj                            <--- object no. 1
<< /Type /Catalog           <--- this is a bookmark, not the 'catalog' we 
discuss
/Outlines 2 0 R
/Pages 3 0 R
>>
endobj
2 0 obj                      <--- object no. 2
<< /Type Outlines
/Count 0
>>
endobj
3 0 obj                     <--- object no. 3
<< /Type /Pages
/Kids [4 0 R]          <--- object no. 4 (a page) is part of all the pages
/Count 1
>>
endobj
4 0 obj                     <--- object no. 4
<< /Type /Page
/Parent 3 0 R
/MediaBox [0 0 612 792]
/Contents 5 0 R
/Resources << /ProcSet 6 0 R >>
>>
endobj
5 0 obj                     <--- object no. 5
<< /Length 35 >>
stream
…Page-marking operators…
endstream
endobj
6 0 obj                     <--- object no. 6
[/PDF]
endobj
Xref               <--- this is where our 'catalog' starts
0 7                <--- there are 7 entries in it
0000000000 65535 f         <--- the first entry is always the same
0000000009 00000 n        <--- this line points to the 1st object, which
0000000074 00000 n              is located 9 bytes from the file start.
0000000120 00000 n
0000000179 00000 n        <--- this line points to the 4th object, which
0000000300 00000 n              is located 179 bytes from the file start.
0000000384 00000 n
trailer
<< /Size 7
/Root 1 0 R
>>
Startxref                  <--- pointer to the catalog after this line
408                  <--- the catalog is located 408 bytes from file start.
%%EOF

As you can see, we need to calculate each object's position in the file and 
insert it in the catalog. It is possible, but coding takes time :-)
There are no hyperlinks in this file. Hyperlinks are just another kind of  
objects that point to other objects.
So, our problem is first to implement the catalog computation, and then to 
implement the insertion of hyperlink objects.

> 
> >There is a workaround for the first problem. The gs 
> converter ps-->pdf
> >we currently use can handle a subset of commands called 
> "pdfmark". These
> >commands can be embedded in the ps file TeXmacs outputs, and when
> >converted to pdf they will show as hyperlinks, bookmarks, etc'.
> >
> >The second problem remains. How can we (I) embed these 
> commands in the
> >ps device? There must be a way to let the device know when 
> it proccesses
> >a certain block, that this block is a <label> or a <ref>, 
> for example.
> >Does anyone know how can this be done?
> >
> >  
> >
> Supposing that what you want is the correct native TeXmacs
> translation of hyperlinks from .tm files to PDF files, the
> answer is that to do this, you need to patch a dozen of C++
> files, not only the PsDevice. ==> You need to discuss this
> with Joris, when he will be back in some weeks (he's the
> one that deals with patches in this part of TeXmacs).
> 
> 
> Best, Henri
> 
Assuming that we want (as a first step) to do the conversion via gs, as we do 
today, we can use the 'pdfmark' commands. Now, 'pdfmark' commands should be 
embedded inside the postscript file, but they don’t have to be :). For example, 
assume we have in.ps and we want to distill it into out.pdf with bookmarks, 
hyperlinks, crop-pages etc'. We will make a file called pdfmarks with our 
commands, and distill all our input files together:

   gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite \
   -sOutputFile=out.pdf in.ps pdfmarks

My thought is this: Can we implement the generation of the 'pdfmark' commands 
in scheme, and then just distill everything into pdf?
For example, in order to make a hyperlink, we will need to calculate the 
rectangle area on the page where the the hyperlink will be active, and then 
write in our pdfmarks file the command. In the same fashion, the date, author 
name, title, crop-pages and many more items can be inserted. Some examples of 
'pdfmark' commands:

General info:

   [ /Title A Feature Rich PDF File
   /Author Hadar Raz
   /Creator TeXmacs
   /Keywords whatever......
   /ModDate D:20011004101012
   /DOCINFO pdfmark

Bookmarks:

   [ /Page 1 /View [/XYZ 0 842 1.0] /Title (1stpage) /OUT pdfmark
   [ /Page 2 /View [/XYZ 0 842 1.0] /Title (2ndpage) /OUT pdfmark

Initial view:

   [ /PageMode /UseOutlines /DOCVIEW pdfmark

Labels:

   [ /Dest /MyNamedDest
   /Page 1
   /View [/FitH 5]
   /DEST pdfmark

Link to label:

   [ /Rect [70 650 210 675]
   /Border [16 16 1 [3 10]]
   /Color [0 .7 1]
   /Dest /MyNamedDest
   /Subtype /Link
   /ANN pdfmark

Can these attributes be calculated by scheme (I don't know scheme at all...) ?

Hadar.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]