groff
[Top][All Lists]
Advanced

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

Re: pdfroff in groff 1.23.0.rc3 changes compared to 1.22.4


From: G. Branden Robinson
Subject: Re: pdfroff in groff 1.23.0.rc3 changes compared to 1.22.4
Date: Tue, 4 Apr 2023 11:58:52 -0500

At 2023-04-04T16:26:30+0000, Michał Kruszewski wrote:
> I use pdfroff only because of 2 reasons.  If you know how to do the
> same with groff I would even prefer to use groff instead:

Sure, maybe I can help.

> 1. ToC. I haven't managed to generate ToC with groff at the beginning
> of the document.

When creating a PDF, you can use a groff pdf driver macro
called 'pdfswitchtopage' to achieve this.

For instance, I just did the following to our doc/ms.ms document in our
source tree...

$ git di
diff --git a/doc/ms.ms b/doc/ms.ms
index 8376a71ed..359b586a1 100644
--- a/doc/ms.ms
+++ b/doc/ms.ms
@@ -4422,6 +4422,7 @@ the curious may consult its source in the file
 .I ms.ms
 to see how its formatting was achieved.
 .\" ------------------------
+.if '\*[.T]'pdf' .pdfswitchtopage after top
 .TC
 .
 .

...and it worked just fine.

> I do not ask for a lot.  Just print me the info about header pages
> (stdout or file) and I will easily generate ToC with Perl/Python
> script and Makefile target.  I guess it is currently not possible?

No, I think it's quite possible; see above.  :)

> 2. PDF meta data.
> pdfroff has .pdfinfo, how to achieve the same with groff?

groff's pdf output driver supports it as well, with the same syntax I
think; but to my surprise it is not documented in the gropdf(1) man
page.

So here's another quick patch to our ms.ms document, by way of
illustration.

diff --git a/doc/ms.ms b/doc/ms.ms
index 8376a71ed..7903b4569 100644
--- a/doc/ms.ms
+++ b/doc/ms.ms
@@ -41,6 +41,10 @@
 .EF ''''
 .OH 'Using \f[I]groff\f[] with the \f[I]ms\f[] macros''%'
 .OF ''''
+.pdfinfo /Title Using groff with the ms Macro Package
+.pdfinfo /Author Larry Kollar, G. Branden Robinson
+.pdfinfo /Subject composing 2023 documents with a 1975 macro package
+.pdfinfo /Keywords groff ms troff nroff
 .TL
 Using
 .BI groff

These items show up in the "Properties" pop-up dialog box of the
"evince" and "okular" PDF viewers for me.

I'm attaching the document in source and rendered forms so you can
verify whether they work as well for you.

Regards,
Branden

Attachment: ms.ms
Description: Troff MS-macros document

Attachment: ms.pdf
Description: Adobe PDF document

Attachment: signature.asc
Description: PGP signature


reply via email to

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