Documents without /Info reference in trailer will result in 0 when calling FPDF_GetMetaText

115 views
Skip to first unread message

Jeroen Bobbeldijk

unread,
Mar 22, 2023, 11:04:04 AM3/22/23
to pdfium
Hi there,

In go-pdfium, I use the response of FPDF_GetMetaText to detect whether something went wrong or not, mainly because FPDF_GetMetaText return 2 (string), whether the tag exists or not. However, when opening a PDF without any /Info reference in the trailer always returns 0, which doesn't really match the behavior of other PDF's in my opinion that do have /Info but do not have that specific Tag.

My proposal would be to also return 2 (empty string) when the /Info reference doesn't exist.
I attched a demo PDF, created with the commands:
exiftool -all:all= foo.pdf
qpdf --linearize foo.pdf bar.pdf

It would also be great to have some method to list the available tags in a document.

Kind regards,
Jeroen Bobbeldijk
test.cleaned.pdf

Jeroen Bobbeldijk

unread,
Mar 22, 2023, 11:06:21 AM3/22/23
to pdfium
Correction:

  mainly because FPDF_GetMetaText return 2 (empty string), when the tag is actually empty, but also when it doesn't exist

Also, I could also live with having 0 being that the tag doesn't exist or that there is no info at all in the document, but that would break how it currently works.

Lei Zhang

unread,
Apr 21, 2023, 9:17:28 PM4/21/23
to Jeroen Bobbeldijk, pdfium
Would adding FPDF_BOOL FPDF_HasMetaText(FPDF_DOCUMENT document,
FPDF_BYTESTRING tag) help?
> --
> You received this message because you are subscribed to the Google Groups "pdfium" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to pdfium+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/pdfium/3a1a67c1-d997-4f22-be84-08b1c8bea0e5n%40googlegroups.com.

Jeroen Bobbeldijk

unread,
Apr 22, 2023, 4:33:46 AM4/22/23
to pdfium
Yes, I think it would :) A method to get all the meta tags of a document would also work, since you can basically add anything to the Info tag right?

geisserml

unread,
Apr 23, 2023, 7:13:00 AM4/23/23
to pdfium
On comment 2: I agree. We noticed this problem, too, while implementing a python wrapper for FPDF_GetMetaText().
With the current API, it's not possible to distinguish between "empty" and "not set".

Jeroen Bobbeldijk

unread,
Jun 28, 2023, 4:34:05 PM6/28/23
to pdfium
@Lei, are there any plans to add the FPDF_HasMetaText and/or a method to list the tags of a document?

Jeroen Bobbeldijk

unread,
Apr 2, 2024, 7:39:22 AMApr 2
to pdfium
I'd still like to see this implemented, also willing to build it myself. 

@Lei can you confirm whether adding "FPDF_HasMetaText" and making "FPDF_GetMetaText" always return a buflen of at least 2 (empty string), even if /Info doesn't exist, is something that would be merged?
Reply all
Reply to author
Forward
0 new messages