[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Multiline Subject as PDF metadata
From: |
Deri |
Subject: |
Re: Multiline Subject as PDF metadata |
Date: |
Tue, 25 Jan 2022 23:31:57 +0000 |
On Tuesday, 25 January 2022 19:18:58 GMT Tadziu Hoffmann wrote:
> > This metadata is held in the "document information dictionary"
> > of the pdf. In the pdf 1.4 standard the items
> > Title/Author/Keywords/Subject are all defined as text strings,
> > so I believe that precludes them from being multiline.
>
> You can embed \n into the strings, but not all programs will
> display this as a newline -- pdfinfo does, but my version of
> acroread displays a boxed "000A" instead.
>
> \X'ps: exec mark \
> /Title (\\nMy\\nmultiline\\ndocument\\ntitle\\n) \
> /Synopsis (A short description of the document content.) \
> /CreationDate (Jan 25, 2022) \
> /ModDate (Jan 25, 2022) \
> /DOCINFO pdfmark'
> Hello, world!
>
> I used groff -Tps and ps2pdf to create the PDF file,
This works:-
.sp 1i
.pdfinfo /Title "\[u000a]My\[u000a]multiline\[u000a]document\[u000a]title\
[u000a]"
.pdfinfo /Synopsis "A short description of the document content."
Hello, world!
BUT, you will need a small tweak to the program gropdf. This patch should
allow multi-line .pdfinfo using \[u000a] as the line separator and -Tpdf:-
--- a/src/devices/gropdf/gropdf.pl
+++ b/src/devices/gropdf/gropdf.pl
@@ -876,9 +876,9 @@ sub do_x
$pdfmark=~s((\d{4,6}) u)(sprintf("%.1f",$1/
$desc{sizescale}))eg;
$pdfmark=~s(\\\[u00(..)\])(chr(hex($1)))eg;
- if ($pdfmark=~m/(.+) \/DOCINFO\s*$/)
+ if ($pdfmark=~m/(.+) \/DOCINFO\s*$/s)
{
- my @xwds=split(' ',"<< $1 >>");
+ my @xwds=split(/ /,"<< $1 >>");
my $docinfo=ParsePDFValue(\@xwds);
foreach my $k (sort keys %{$docinfo})
I will soon be adding this patch to groff git.
Cheers
Deri