diff -ru pdfium.orig/fpdfsdk/fpdf_edittext.cpp pdfium/fpdfsdk/fpdf_edittext.cpp --- pdfium.orig/fpdfsdk/fpdf_edittext.cpp 2025-08-21 16:56:03.855282337 +0100 +++ pdfium/fpdfsdk/fpdf_edittext.cpp 2025-08-21 17:18:56.347453326 +0100 @@ -960,6 +960,26 @@ return true; } +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFFont_GetToUnicodeContent(FPDF_FONT font, + uint8_t* buffer, + size_t buflen, + size_t* out_buflen) +{ + auto* cfont = CPDFFontFromFPDFFont(font); + if (!cfont || !out_buflen) + return false; + + RetainPtr pStream = cfont->GetFontDict()->GetStreamFor("ToUnicode"); + if (!pStream) + return false; + + // SAFETY: caller ensures `buffer` points to at least `buflen` bytes. + *out_buflen = DecodeStreamMaybeCopyAndReturnLength( + pStream, UNSAFE_BUFFERS(pdfium::span(buffer, buflen))); + + return true; +} + FPDF_EXPORT int FPDF_CALLCONV FPDFFont_GetIsEmbedded(FPDF_FONT font) { auto* cfont = CPDFFontFromFPDFFont(font); if (!cfont) { diff -ru pdfium.orig/public/fpdf_edit.h pdfium/public/fpdf_edit.h --- pdfium.orig/public/fpdf_edit.h 2025-08-21 16:56:03.860206877 +0100 +++ pdfium/public/fpdf_edit.h 2025-08-21 17:15:06.289917550 +0100 @@ -1496,6 +1496,11 @@ size_t buflen, size_t* out_buflen); +FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFFont_GetToUnicodeContent(FPDF_FONT font, + uint8_t* buffer, + size_t buflen, + size_t* out_buflen); + // Experimental API. // Get whether |font| is embedded or not. //