Add public APIs for Optional Content Groups [pdfium : main]

0 views
Skip to first unread message

Aryan Krishnan (Gerrit)

unread,
Jun 24, 2026, 2:16:06 PM (16 hours ago) Jun 24
to Lei Zhang, Tom Sepez, Andy Phan, pdfium-...@googlegroups.com
Attention needed from Andy Phan, Lei Zhang and Tom Sepez

Aryan Krishnan voted and added 1 comment

Votes added by Aryan Krishnan

Commit-Queue+1

1 comment

Patchset-level comments
File-level comment, Patchset 3 (Latest):
Aryan Krishnan . resolved

Hey guys, decided to add a CL to add support for querying the names of and the visibility of OCGs. So far this only adds a few APIs which were requested by the initial CL, however more can be perhaps added in future in terms of write support perhaps. Thanks!

Open in Gerrit

Related details

Attention is currently required from:
  • Andy Phan
  • Lei Zhang
  • Tom Sepez
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: pdfium
Gerrit-Branch: main
Gerrit-Change-Id: I42f4c289be5a5f8100612d2a2108948f32cd1a3d
Gerrit-Change-Number: 150770
Gerrit-PatchSet: 3
Gerrit-Owner: Aryan Krishnan <aryankr...@gmail.com>
Gerrit-Reviewer: Andy Phan <andy...@chromium.org>
Gerrit-Reviewer: Aryan Krishnan <aryankr...@gmail.com>
Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
Gerrit-Attention: Lei Zhang <the...@chromium.org>
Gerrit-Attention: Tom Sepez <tse...@chromium.org>
Gerrit-Attention: Andy Phan <andy...@chromium.org>
Gerrit-Comment-Date: Wed, 24 Jun 2026 18:15:59 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
unsatisfied_requirement
open
diffy

Aryan Krishnan (Gerrit)

unread,
Jun 24, 2026, 2:37:08 PM (15 hours ago) Jun 24
to pdfium...@luci-project-accounts.iam.gserviceaccount.com, Lei Zhang, Tom Sepez, Andy Phan, pdfium-...@googlegroups.com
Attention needed from Andy Phan, Lei Zhang and Tom Sepez

Aryan Krishnan voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Andy Phan
  • Lei Zhang
  • Tom Sepez
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: pdfium
Gerrit-Branch: main
Gerrit-Change-Id: I42f4c289be5a5f8100612d2a2108948f32cd1a3d
Gerrit-Change-Number: 150770
Gerrit-PatchSet: 4
Gerrit-Owner: Aryan Krishnan <aryankr...@gmail.com>
Gerrit-Reviewer: Andy Phan <andy...@chromium.org>
Gerrit-Reviewer: Aryan Krishnan <aryankr...@gmail.com>
Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
Gerrit-Attention: Lei Zhang <the...@chromium.org>
Gerrit-Attention: Tom Sepez <tse...@chromium.org>
Gerrit-Attention: Andy Phan <andy...@chromium.org>
Gerrit-Comment-Date: Wed, 24 Jun 2026 18:37:00 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
open
diffy

Tom Sepez (Gerrit)

unread,
Jun 24, 2026, 3:07:26 PM (15 hours ago) Jun 24
to Aryan Krishnan, pdfium...@luci-project-accounts.iam.gserviceaccount.com, Lei Zhang, Andy Phan, pdfium-...@googlegroups.com
Attention needed from Andy Phan, Aryan Krishnan and Lei Zhang

Tom Sepez added 10 comments

File core/fpdfapi/page/cpdf_occontext.cpp
Line 201, Patchset 4 (Latest): ocg_names.push_back(ocg_dict->GetByteStringFor("Name"));
Tom Sepez . unresolved

do we want to push blank strings if there isn't this key?

Line 223, Patchset 4 (Latest): break;
Tom Sepez . unresolved

just return here?

Line 227, Patchset 4 (Latest): return queried_ocg;
Tom Sepez . unresolved

null return on not found?

File fpdfsdk/fpdf_doc.cpp
Line 584, Patchset 4 (Latest):FPDF_GetOCGCount(FPDF_DOCUMENT document) {
Tom Sepez . unresolved

nit: no line breaking before.

Line 589, Patchset 4 (Latest): CPDF_Document* doc = CPDFDocumentFromFPDFDocument(document);
Tom Sepez . unresolved

this handles null, maybe convert first then check in case this someday does more checking besides straight cast?

Line 592, Patchset 4 (Latest): return static_cast<uint32_t>(oc_context->GetOCGNames().size());
Tom Sepez . unresolved

uint32_t isn't always unsigned long.

Line 595, Patchset 4 (Latest):FPDF_EXPORT unsigned long FPDF_CALLCONV FPDF_GetOCGName(FPDF_DOCUMENT document,
Tom Sepez . unresolved

Check for null documents maybe rather than relying on downstrea.

File public/fpdf_doc.h
Line 470, Patchset 4 (Latest):// FPDF_LoadDocument(). name - The OCG name, encoded in UTF-8.
Tom Sepez . unresolved

formatting.

Line 450, Patchset 4 (Latest):// document - Handle to the document. Returned by
// FPDF_LoadDocument(). index - Zero-based index of the OCG.
// Must be less than the
// value returned by FPDF_GetOCGCount().
// buffer - Buffer to receive the name, in UTF-16LE. Can be
// NULL if |buflen| is 0.
// buflen - Length of |buffer|, in bytes.
// Return value:
Tom Sepez . unresolved

watch formatting.

Line 444, Patchset 4 (Latest):FPDF_GetOCGCount(FPDF_DOCUMENT document);
Tom Sepez . unresolved

again, line break.

Open in Gerrit

Related details

Attention is currently required from:
  • Andy Phan
  • Aryan Krishnan
  • Lei Zhang
Submit Requirements:
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: pdfium
    Gerrit-Branch: main
    Gerrit-Change-Id: I42f4c289be5a5f8100612d2a2108948f32cd1a3d
    Gerrit-Change-Number: 150770
    Gerrit-PatchSet: 4
    Gerrit-Owner: Aryan Krishnan <aryankr...@gmail.com>
    Gerrit-Reviewer: Andy Phan <andy...@chromium.org>
    Gerrit-Reviewer: Aryan Krishnan <aryankr...@gmail.com>
    Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
    Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
    Gerrit-Attention: Lei Zhang <the...@chromium.org>
    Gerrit-Attention: Aryan Krishnan <aryankr...@gmail.com>
    Gerrit-Attention: Andy Phan <andy...@chromium.org>
    Gerrit-Comment-Date: Wed, 24 Jun 2026 19:07:22 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Aryan Krishnan (Gerrit)

    unread,
    Jun 24, 2026, 3:31:19 PM (14 hours ago) Jun 24
    to pdfium...@luci-project-accounts.iam.gserviceaccount.com, Lei Zhang, Tom Sepez, Andy Phan, pdfium-...@googlegroups.com
    Attention needed from Andy Phan, Lei Zhang and Tom Sepez

    Aryan Krishnan voted and added 10 comments

    Votes added by Aryan Krishnan

    Commit-Queue+1

    10 comments

    File core/fpdfapi/page/cpdf_occontext.cpp
    Line 201, Patchset 4: ocg_names.push_back(ocg_dict->GetByteStringFor("Name"));
    Tom Sepez . resolved

    do we want to push blank strings if there isn't this key?

    Aryan Krishnan

    Nope we don't want to push back the strings in that case. Added the check.

    FWIW: /Name is mandatory per spec so valid PDFs should be fine, but adding the check just in case.

    Line 223, Patchset 4: break;
    Tom Sepez . resolved

    just return here?

    Aryan Krishnan

    Done

    Line 227, Patchset 4: return queried_ocg;
    Tom Sepez . resolved

    null return on not found?

    Aryan Krishnan

    The variable used to take care of that as if nothing was found it would return nullptr because it was initialized to that on 215, but after directly returning at 223 the variable isn't needed. edited.

    File fpdfsdk/fpdf_doc.cpp
    Line 584, Patchset 4:FPDF_GetOCGCount(FPDF_DOCUMENT document) {
    Tom Sepez . resolved

    nit: no line breaking before.

    Aryan Krishnan

    This is 83 cols so CL format wraps it.

    Line 589, Patchset 4: CPDF_Document* doc = CPDFDocumentFromFPDFDocument(document);
    Tom Sepez . resolved

    this handles null, maybe convert first then check in case this someday does more checking besides straight cast?

    Aryan Krishnan

    Done

    Line 592, Patchset 4: return static_cast<uint32_t>(oc_context->GetOCGNames().size());
    Tom Sepez . resolved

    uint32_t isn't always unsigned long.

    Aryan Krishnan

    Done

    Line 595, Patchset 4:FPDF_EXPORT unsigned long FPDF_CALLCONV FPDF_GetOCGName(FPDF_DOCUMENT document,
    Tom Sepez . resolved

    Check for null documents maybe rather than relying on downstrea.

    Aryan Krishnan

    Done

    File public/fpdf_doc.h
    Line 470, Patchset 4:// FPDF_LoadDocument(). name - The OCG name, encoded in UTF-8.
    Tom Sepez . resolved

    formatting.

    Aryan Krishnan

    Done

    Line 450, Patchset 4:// document - Handle to the document. Returned by

    // FPDF_LoadDocument(). index - Zero-based index of the OCG.
    // Must be less than the
    // value returned by FPDF_GetOCGCount().
    // buffer - Buffer to receive the name, in UTF-16LE. Can be
    // NULL if |buflen| is 0.
    // buflen - Length of |buffer|, in bytes.
    // Return value:
    Tom Sepez . resolved

    watch formatting.

    Aryan Krishnan

    Done

    Line 444, Patchset 4:FPDF_GetOCGCount(FPDF_DOCUMENT document);
    Tom Sepez . resolved

    again, line break.

    Aryan Krishnan

    This wraps to 83, hence CL format adds in the break.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Andy Phan
    • Lei Zhang
    • Tom Sepez
    Submit Requirements:
      • requirement is not satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: pdfium
      Gerrit-Branch: main
      Gerrit-Change-Id: I42f4c289be5a5f8100612d2a2108948f32cd1a3d
      Gerrit-Change-Number: 150770
      Gerrit-PatchSet: 5
      Gerrit-Owner: Aryan Krishnan <aryankr...@gmail.com>
      Gerrit-Reviewer: Andy Phan <andy...@chromium.org>
      Gerrit-Reviewer: Aryan Krishnan <aryankr...@gmail.com>
      Gerrit-Reviewer: Lei Zhang <the...@chromium.org>
      Gerrit-Reviewer: Tom Sepez <tse...@chromium.org>
      Gerrit-Attention: Lei Zhang <the...@chromium.org>
      Gerrit-Attention: Tom Sepez <tse...@chromium.org>
      Gerrit-Attention: Andy Phan <andy...@chromium.org>
      Gerrit-Comment-Date: Wed, 24 Jun 2026 19:31:04 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      Comment-In-Reply-To: Tom Sepez <tse...@chromium.org>
      unsatisfied_requirement
      open
      diffy
      Reply all
      Reply to author
      Forward
      0 new messages