pdfium/core/fpdfdoc/cpdf_bookmark.h
Aryan 49701ff07b Add FPDFBookmark_GetColor public API
This CL introduces a new public API function, FPDFBookmark_GetColor,
which allows emedders to retrieve the RGB color components of a PDF
outline item (bookmark).

To support this, this CL adds the CPDF_Bookmark::GetColor() method to
get values from the optional "/C" array from the underlying bookmark
dictionary. The API validates that the RGB color components are present,
correctly formed, and conform to the PDF specification limits (values
between 0.0 and 1.0).

Bug: 362787705
Change-Id: I246243c32c7c4b35a7f4200b610712282e66b35a
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/150430
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
2026-06-24 13:09:16 -07:00

41 lines
1.1 KiB
C++

// Copyright 2016 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#ifndef CORE_FPDFDOC_CPDF_BOOKMARK_H_
#define CORE_FPDFDOC_CPDF_BOOKMARK_H_
#include <optional>
#include "core/fpdfdoc/cpdf_action.h"
#include "core/fpdfdoc/cpdf_dest.h"
#include "core/fxcrt/retain_ptr.h"
#include "core/fxcrt/widestring.h"
#include "core/fxge/dib/fx_dib.h"
class CPDF_Dictionary;
class CPDF_Document;
class CPDF_Bookmark {
public:
CPDF_Bookmark();
CPDF_Bookmark(const CPDF_Bookmark& that);
explicit CPDF_Bookmark(RetainPtr<const CPDF_Dictionary> dict);
~CPDF_Bookmark();
const CPDF_Dictionary* GetDict() const { return dict_.Get(); }
WideString GetTitle() const;
CPDF_Dest GetDest(CPDF_Document* document) const;
CPDF_Action GetAction() const;
std::optional<FX_RGB_STRUCT<float>> GetColor() const;
int GetCount() const;
private:
RetainPtr<const CPDF_Dictionary> dict_;
};
#endif // CORE_FPDFDOC_CPDF_BOOKMARK_H_