PoDoFo 0.9.20
Public Member Functions | List of all members
PoDoFo::PdfEncoding Class Reference

#include <PdfEncoding.h>

Inheritance diagram for PoDoFo::PdfEncoding:
PoDoFo::PdfDynamicEncoding PoDoFo::PdfEncodingShim

Public Member Functions

 PdfEncoding ()
 
std::string ConvertToUtf8 (const PdfString &encodedStr) const
 
bool TryConvertToUtf8 (const PdfString &encodedStr, std::string &str) const
 
charbuff ConvertToEncoded (const std::string_view &str) const
 
std::vector< PdfCID > ConvertToCIDs (const PdfString &encodedStr) const
 
bool TryConvertToCIDs (const PdfString &encodedStr, std::vector< PdfCID > &cids) const
 
char32_t GetCodePoint (const PdfCharCode &codeUnit) const
 
char32_t GetCodePoint (unsigned charCode) const
 
const PdfCharCode & GetFirstChar () const
 
const PdfCharCode & GetLastChar () const
 
bool IsNull () const
 
bool HasCIDMapping () const
 
bool IsSimpleEncoding () const
 
bool HasParsedLimits () const
 
virtual bool IsDynamicEncoding () const
 
size_t GetId () const
 
const PdfEncodingLimits & GetLimits () const
 
const PdfEncodingMap & GetToUnicodeMap () const
 
bool GetToUnicodeMapSafe (const PdfEncodingMap *&toUnicode) const
 
const PdfEncodingMap & GetToUnicodeMapSafe () const
 

Detailed Description

A PdfEncoding is in PdfFont to transform a text string into a representation so that it can be displayed in a PDF file.

PdfEncoding can also be used to convert strings from a PDF file back into a PdfString.

Constructor & Destructor Documentation

◆ PdfEncoding()

PdfEncoding::PdfEncoding ( )

Null encoding

Member Function Documentation

◆ ConvertToCIDs()

vector< PdfCID > PdfEncoding::ConvertToCIDs ( const PdfString & encodedStr) const
Remarks
Doesn't throw if conversion failed, totally or partially

◆ ConvertToEncoded()

charbuff PdfEncoding::ConvertToEncoded ( const std::string_view & str) const
Remarks
It throws if conversion failed, totally or partially

◆ ConvertToUtf8()

string PdfEncoding::ConvertToUtf8 ( const PdfString & encodedStr) const
Remarks
Doesn't throw if conversion failed, totally or partially

◆ GetCodePoint() [1/2]

char32_t PdfEncoding::GetCodePoint ( const PdfCharCode & codeUnit) const

Get code point from char code unit

Returns
the found code point or U'\0' if missing or multiple matched codepoints

◆ GetCodePoint() [2/2]

char32_t PdfEncoding::GetCodePoint ( unsigned charCode) const

Get code point from char code

Returns
the found code point or U'\0' if missing or multiple matched codepoints
Remarks
it will iterate available code sizes

◆ GetFirstChar()

const PdfCharCode & PdfEncoding::GetFirstChar ( ) const

This return the first char code used in the encoding

Remarks
Mostly useful for non cid-keyed fonts to export /FirstChar

◆ GetId()

size_t PoDoFo::PdfEncoding::GetId ( ) const
inline

Return an Id to be used in hashed containers. Id 0 has a special meaning to create a PdfDynamicEncoding

See also
PdfDynamicEncoding

◆ GetLastChar()

const PdfCharCode & PdfEncoding::GetLastChar ( ) const

This return the last char code used in the encoding

Remarks
Mostly useful for non cid-keyed fonts to export /LastChar

◆ GetLimits()

const PdfEncodingLimits & PdfEncoding::GetLimits ( ) const

Get actual limits of the encoding

May be the limits inferred from /Encoding or the limits inferred by /FirstChar, /LastChar

◆ GetToUnicodeMap()

const PdfEncodingMap & PdfEncoding::GetToUnicodeMap ( ) const

Get the ToUnicode map, throws if missing

◆ GetToUnicodeMapSafe() [1/2]

const PdfEncodingMap & PdfEncoding::GetToUnicodeMapSafe ( ) const

Get the ToUnicode map, fallback to the normal encoding if missing

Returns
the retrieved map
Remarks
As a general rule, we always use this method when converting encoded -> Unicode

◆ GetToUnicodeMapSafe() [2/2]

bool PdfEncoding::GetToUnicodeMapSafe ( const PdfEncodingMap *& toUnicode) const

Get the ToUnicode map, fallback to the normal encoding if missing

Parameters
toUnicodethe retrieved map
Returns
true if the retrieved map is valid, false otherwise

◆ HasCIDMapping()

bool PdfEncoding::HasCIDMapping ( ) const

Return true if the encoding does CID mapping

◆ HasParsedLimits()

bool PdfEncoding::HasParsedLimits ( ) const

Returns true if /FirstChar and /LastChar were parsed from object

◆ IsDynamicEncoding()

bool PdfEncoding::IsDynamicEncoding ( ) const
virtual

Return true if the encoding is a dynamic CID mapping

Reimplemented in PoDoFo::PdfDynamicEncoding.

◆ IsNull()

bool PdfEncoding::IsNull ( ) const

Return true if the encoding is a dummy null encoding

◆ IsSimpleEncoding()

bool PdfEncoding::IsSimpleEncoding ( ) const

Return true if the encoding is simple and has a non-CID mapping /Encoding entry

◆ TryConvertToCIDs()

bool PdfEncoding::TryConvertToCIDs ( const PdfString & encodedStr,
std::vector< PdfCID > & cids ) const
Remarks
Produces a partial result also in case of failure

◆ TryConvertToUtf8()

bool PdfEncoding::TryConvertToUtf8 ( const PdfString & encodedStr,
std::string & str ) const
Remarks
Produces a partial result also in case of failure