groff
[Top][All Lists]
Advanced

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

Re: [Groff] EPS vs PDF support in MOM


From: Deri James
Subject: Re: [Groff] EPS vs PDF support in MOM
Date: Tue, 04 Dec 2012 13:06:08 +0000
User-agent: KMail/4.8.5 (Linux/3.3.8-desktop-2.mga2; KDE/4.8.5; x86_64; ; )

On Monday 03 Dec 2012 11:48:15 Kobus Botha wrote:
> The problem I have now is that PDF_IMAGE does not act as a replacement 
> for PSPIC

The reason the pdf driver for groff cannot behave like pspic is because groff 
has no way of knowing the media size of the pdf graphic which you are 
importing. For postscript it has a request .psbb which returns the bounding 
box of the postscript file, there is no equivalent for pdf files, and would be 
extremely difficult to implement for pdf files. In addition the BoundingBox of 
a postscript file is not the same as the MediaBox of a pdf file, the former 
describes the extent of the drawn strokes, while the latter describes the size 
of the media upon which the pdf graphic is stroked. Imagine a logo centred 
with a transparent centimetre border around it, the bounding box and media box 
would be different.

Due to the above it is not even possible to use ghostscripts bbox device on 
the pdf graphic since this will give the extent of the strokes, not the actual 
size of the media. A tool such as "pdfinfo" will tell you the page size of the 
pdf file, and once you have this data you are in business.

To use pdf included graphics you must tell groff the actual height of the 
graphic you want to embed in the document (so that it can continue flowing 
text after the graphic), the width will be set in proportion to the height you 
specify. I use this little macro as a helper. The flag parameter can be -L 
(left) -C (centred) or -R (right) control allignment within the current line 
length. (Caution: the right and centre flags have a bug in current versions of 
gropdf, it may not do quite what you want!!).

\# params fname flag height
.de PDFPIC_HEIGHT
.sp -.6v
.ne 0\\$3+1v
\\X'pdf: pdfpic \\$1 \\$2 0 \\$3 \\n[.l]z'
.sp 0\\$3-.3v
.ne 1v
..

You can use it with a call such as:-

.PDFPIC_HEIGHT ChuzLogoPlain.pdf -L 5c

Which would include the pdf scaled so that it was a height of 5cm (and its 
width proportionally scaled), left alligned. If there is insufficient room on 
the current page it will throw to a new page and place the graphic at the top. 
I have not tested this in conjunction with the MOM macros.

Using the information from "pdfinfo", and a bit of arithmetic, you can use 
this macro to control the width of the graphic as well by calculating what 
height would provide the desired width using the page proportions provided by 
"pdfinfo".

Cheers 

Deri





reply via email to

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