module Pdftext: sig
.. end
Parsing fonts and extracting text from content streams and PDF strings
Data Types
type
type3_glpyhs = {
}
type
simple_fonttype =
type
fontmetrics = float array
type
fontfile =
| |
FontFile of int |
| |
FontFile2 of int |
| |
FontFile3 of int |
type
fontdescriptor = {
|
ascent : float ; |
|
descent : float ; |
|
leading : float ; |
|
avgwidth : float ; |
|
maxwidth : float ; |
|
fontfile : fontfile option ; |
}
type
differences = (string * int) list
type
encoding =
| |
ImplicitInFontFile |
| |
StandardEncoding |
| |
MacRomanEncoding |
| |
WinAnsiEncoding |
| |
MacExpertEncoding |
| |
CustomEncoding of encoding * differences |
| |
FillUndefinedWithStandard of encoding |
type
simple_font = {
}
type
standard_font =
| |
TimesRoman |
| |
TimesBold |
| |
TimesItalic |
| |
TimesBoldItalic |
| |
Helvetica |
| |
HelveticaBold |
| |
HelveticaOblique |
| |
HelveticaBoldOblique |
| |
Courier |
| |
CourierBold |
| |
CourierOblique |
| |
CourierBoldOblique |
| |
Symbol |
| |
ZapfDingbats |
type
cid_system_info = {
|
registry : string ; |
|
ordering : string ; |
|
supplement : int ; |
}
type
composite_CIDfont = {
|
cid_system_info : cid_system_info ; |
|
cid_basefont : string ; |
|
cid_fontdescriptor : fontdescriptor ; |
|
cid_widths : (int * float) list ; |
|
cid_default_width : int ; |
}
type
cmap_encoding =
| |
Predefined of string |
| |
CMap of int |
type
font =
String representations of fonts
val string_of_standard_font : standard_font -> string
Returns a string such as "Times-Bold" for Pdftext.TimesBold etc.
val standard_font_of_name : string -> standard_font option
Parses a string such as "/Times-Bold" or "/TimesNewRoman,Bold" to Pdftext.TimesRomanBold etc.
val string_of_font : font -> string
A debug string for the whole font datatype.
Reading a Font
val read_font : Pdf.t -> Pdf.pdfobject -> font
Read a font from a given document and object
Writing a Font
val write_font : Pdf.t -> font -> int
Write a font to a given document, returning the object number for the main
font dictionary
Utility functions
val codepoints_of_utf8 : string -> int list
A list of unicode codepoints for a UTF8 string
val utf8_of_codepoints : int list -> string
A UTF8 string for a list of unicode codepoints
Text from strings outside page content
val utf8_of_pdfdocstring : string -> string
Take a pdf string (which will be either pdfdocencoding or UTF16BE) and
return a string representing the same unicode codepoints in UTF8
val pdfdocstring_of_utf8 : string -> string
Take a UTF8 string and convert to pdfdocencoding (if no unicode-only
characters are used) or UTF16BE (if they are))
val pdfdocstring_of_codepoints : int list -> string
Build a pdf string in pdfdocencoding (if no unicode-only characters are
used) or UTF16BE (if they are)
val codepoints_of_pdfdocstring : string -> int list
Produce a list of unicode codepoints from a pdfdocencoding or UTF16BE pdf
document string
Text from strings inside page content
The type of text extractors.
: Pdf.t -> Pdf.pdfobject -> text_extractor
Build a text extractor from a document and font object
val codepoints_of_text : text_extractor -> string -> int list
Return a list of unicode points from a given extractor and string (for
example from a Pdfpages.Op_Tj
or Op_TJ
operator).
val glyphnames_of_text : text_extractor -> string -> string list
Return a list of glyph names from a given extractor and string
Building text for strings inside page content
: encoding -> int -> int option
Return the character code for a given unicode codepoint, if it exists in
this encoding. This is only really suitable for simple stuff like standard 14
fonts, or editing text in existing fonts.
val table_of_encoding : encoding -> (int, string) Hashtbl.t
Table of all the entries in an encoding.
val reverse_table_of_encoding : encoding -> (string, int) Hashtbl.t
Reverse table of all the entries in an encoding.