py docs done

This commit is contained in:
John Whitington 2021-08-10 14:41:18 +01:00
parent af576c0208
commit 9997462436
19 changed files with 592 additions and 872 deletions

Binary file not shown.

View File

@ -1,6 +1,6 @@
\documentclass{book}
% Edit here to produce cpdfmanual.pdf, cpdflibmanual.pdf, pycpdfmanual.pdf etc.
\usepackage{comment}\excludecomment{cpdflib}\includecomment{pycpdflib}
\usepackage{comment}\excludecomment{cpdflib}\excludecomment{pycpdflib}
\usepackage{palatino}
\usepackage{listings}
\usepackage{microtype}

View File

@ -1,31 +1,23 @@
/* CHAPTER 2. Merging and Splitting */
# CHAPTER 2. Merging and Splitting
/*
* cpdf_mergeSimple(pdfs, length) given an array of PDFs, and its length,
* merges the files into a new one, which is returned.
*/
int cpdf_mergeSimple(int *, int);
def mergeSimple(pdfs):
"""mergeSimple(pdfs), given a list of PDFs,
merges the files into a new one, which is returned."""
/*
* cpdf_merge(pdfs, len, retain_numbering, remove_duplicate_fonts) merges the
* PDFs. If retain_numbering is true page labels are not rewritten. If
* remove_duplicate_fonts is true, duplicate fonts are merged. This is useful
* when the source documents for merging originate from the same source.
*/
int cpdf_merge(int *, int, int, int);
def merge(pdfs, retain_numbering, remove_duplicate_fonts):
"""merge(pdfs, retain_numbering, remove_duplicate_fonts) merges
the list of PDFs. If retain_numbering is True page labels are not
rewritten. If remove_duplicate_fonts is True, duplicate fonts are merged.
This is useful when the source documents for merging originate from the
same source."""
/*
* cpdf_mergeSame(pdfs, len, retain_numbering, remove_duplicate_fonts,
* ranges) is the same as cpdf_merge, except that it has an additional
* argument - an array of page ranges. This is used to select the pages to
* pick from each PDF. This avoids duplication of information when multiple
* discrete parts of a source PDF are included.
*/
int cpdf_mergeSame(int *, int, int, int, int *);
/*
* cpdf_selectPages(pdf, range) returns a new document which just those pages
* in the page range.
*/
int cpdf_selectPages(int, int);
def mergeSame(pdfs, retain_numbering, remove_duplicate_fonts, ranges):
"""mergeSame(pdfs, retain_numbering, remove_duplicate_fonts, ranges)
is the same as merge, except that it has an additional argument
- an array of page ranges. This is used to select the pages to pick from
each PDF. This avoids duplication of information when multiple discrete
parts of a source PDF are included."""
def selectPages(pdf, r):
""" selectPages(pdf, range) returns a new document which just those pages
in the page range."""

View File

@ -1,152 +1,89 @@
/* CHAPTER 3. Pages */
# CHAPTER 3. Pages
/*
* cpdf_scalePages(pdf, range, x scale, y scale) scales the page dimensions
* and content by the given scale, about (0, 0). Other boxes (crop etc. are
* altered as appropriate)
*/
void cpdf_scalePages(int, int, double, double);
def scalePages(pdf, r, sx, sy):
"""scalePages(pdf, range, x scale, y scale) scales the page dimensions
and content by the given scale, about (0, 0). Other boxes (crop etc. are
altered as appropriate)"""
/*
* cpdf_scaleToFit(pdf, range, width height, scale) scales the content to fit
* new page dimensions (width x height) multiplied by scale (typically 1.0).
* Other boxed (crop etc. are altered as appropriate)
*/
void cpdf_scaleToFit(int, int, double, double, double);
def scaleToFit(pdf, r, sx, sy, scale_to_fit_scale):
"""scaleToFit(pdf, range, width height, scale) scales the content to fit
new page dimensions (width x height) multiplied by scale (typically 1.0).
Other boxed (crop etc. are altered as appropriate)"""
/*
* cpdf_scaleToFitPaper(pdf, range, papersize, scale) scales the page content
* to fit the given page size, possibly multiplied by scale (typically 1.0)
*/
void cpdf_scaleToFitPaper(int, int, enum cpdf_papersize, double);
def scaleToFitPaper(pdf, r, papersize, scale_to_fit_scale):
"""scaleToFitPaper(pdf, range, papersize, scale) scales the page content
to fit the given page size, possibly multiplied by scale (typically 1.0)"""
/* Positions on the page. Used for scaling about a point, and adding text. */
enum cpdf_anchor {
cpdf_posCentre, /* Absolute centre */
cpdf_posLeft, /* Absolute left */
cpdf_posRight, /* Absolute right */
cpdf_top, /* Top top centre of the page */
cpdf_topLeft, /* The top left of the page */
cpdf_topRight, /* The top right of the page */
cpdf_left, /* The left hand side of the page, halfway
* down */
cpdf_bottomLeft, /* The bottom left of the page */
cpdf_bottom, /* The bottom middle of the page */
cpdf_bottomRight, /* The bottom right of the page */
cpdf_right, /* The right hand side of the page, halfway
* down */
cpdf_diagonal, /* Diagonal, bottom left to top right */
cpdf_reverseDiagonal /* Diagonal, top left to bottom right */
};
"""Positions with two numbers in a tuple e.g (posLeft, 10.0, 20.0):"""
posCentre = 0
posLeft = 1
posRight = 2
"""Positions with one number in a tuple e.g (top, 5.0):"""
top = 3
topLeft = 4
topRight = 5
left = 6
bottomLeft = 7
bottomRight = 8
right = 9
"""Positions with no numbers e.g diagonal:"""
diagonal = 10
reverseDiagonal = 11
/*
* A cpdf_position is an anchor (above) and zero or one or two parameters
* (cpdf_coord1, cpdf_coord2).
*
* cpdf_posCentre: Two parameters, x and y
*
* cpdf_posLeft: Two parameters, x and y
*
* cpdf_posRight: Two parameters, x and y
*
* cpdf_top: One parameter -- distance from top
*
* cpdf_topLeft: One parameter -- distance from top left
*
* cpdf_topRight: One parameter -- distance from top right
*
* cpdf_left: One parameter -- distance from left middle
*
* cpdf_bottomLeft: One parameter -- distance from bottom left
*
* cpdf_bottom: One parameter -- distance from bottom
*
* cpdf_bottomRight: One parameter -- distance from bottom right
*
* cpdf_right: One parameter -- distance from right
*
* cpdf_diagonal: Zero parameters
*
* cpdf_reverseDiagonal: Zero parameters
*/
struct cpdf_position {
int cpdf_anchor; /* Position anchor */
double cpdf_coord1; /* Parameter one */
double cpdf_coord2; /* Parameter two */
};
def scaleContents(pdf, r, pos, scale):
"""scaleContents(pdf, range, position, scale) scales the contents of the
pages in the range about the point given by the position, by the
scale given."""
/*
* cpdf_scaleContents(pdf, range, position, scale) scales the contents of the
* pages in the range about the point given by the cpdf_position, by the
* scale given.
*/
void cpdf_scaleContents(int, int, struct cpdf_position, double);
def shiftContents(pdf, r, dx, dy):
"""shiftContents(pdf, range, dx, dy) shifts the content of the pages in
the range."""
/*
* cpdf_shiftContents(pdf, range, dx, dy) shifts the content of the pages in
* the range.
*/
void cpdf_shiftContents(int, int, double, double);
def rotate(pdf, r, rotation):
"""rotate(pdf, range, rotation) changes the viewing rotation to an
absolute value. Appropriate rotations are 0, 90, 180, 270."""
/*
* cpdf_rotate(pdf, range, rotation) changes the viewing rotation to an
* absolute value. Appropriate rotations are 0, 90, 180, 270.
*/
void cpdf_rotate(int, int, int);
def rotateBy(pdf, r, rotation):
"""rotateBy(pdf, range, rotation) changes the viewing rotation by a
given number of degrees. Appropriate values are 90, 180, 270."""
/*
* cpdf_rotateBy(pdf, range, rotation) changes the viewing rotation by a
* given number of degrees. Appropriate values are 90, 180, 270.
*/
void cpdf_rotateBy(int, int, int);
def rotateContents(pdf, r, rotation):
"""rotateContents(pdf, range, angle) rotates the content about the centre
of the page by the given number of degrees, in a clockwise direction."""
/*
* cpdf_rotateContents(pdf, range, angle) rotates the content about the
* centre of the page by the given number of degrees, in a clockwise
* direction.
*/
void cpdf_rotateContents(int, int, double);
def upright(pdf, r):
"""upright(pdf, range) changes the viewing rotation of the pages in the
range, counter-rotating the dimensions and content such that there is no
visual change."""
/*
* cpdf_upright(pdf, range) changes the viewing rotation of the pages in the
* range, counter-rotating the dimensions and content such that there is no
* visual change.
*/
void cpdf_upright(int, int);
def hFlip(pdf, r):
"""hFlip(pdf, range) flips horizontally the pages in the range."""
/* cpdf_hFlip(pdf, range) flips horizontally the pages in the range. */
void cpdf_hFlip(int, int);
def vFlip(pdf, r):
"""vFlip(pdf, range) flips vertically the pages in the range."""
/* cpdf_vFlip(pdf, range) flips vertically the pages in the range. */
void cpdf_vFlip(int, int);
def crop(pdf, r, x, y, w, h):
"""crop(pdf, range, x, y, w, h) crops a page, replacing any existing
crop box. The dimensions are in points."""
/*
* cpdf_crop(pdf, range, x, y, w, h) crops a page, replacing any existing
* crop box. The dimensions are in points.
*/
void cpdf_crop(int, int, double, double, double, double);
def removeCrop(pdf, r):
"""removeCrop(pdf, range) removes any crop box from pages in the range."""
/* cpdf_removeCrop(pdf, range) removes any crop box from pages in the range. */
void cpdf_removeCrop(int, int);
def removeTrim(pdf, r):
"""removeTrim(pdf, range) removes any crop box from pages in the range."""
/* cpdf_removeTrim(pdf, range) removes any crop box from pages in the range. */
void cpdf_removeTrim(int, int);
def removeArt(pdf, r):
"""removeArt(pdf, range) removes any crop box from pages in the range."""
/* cpdf_removeArt(pdf, range) removes any crop box from pages in the range. */
void cpdf_removeArt(int, int);
def removeBleed(pdf, r):
"""removeBleed(pdf, range) removes any crop box from pages in the range."""
/* cpdf_removeBleed(pdf, range) removes any crop box from pages in the range. */
void cpdf_removeBleed(int, int);
def trimMarks(pdf, r):
"""trimMarks(pdf, range) adds trim marks to the given pages, if the trimbox
exists."""
/*
* cpdf_trimMarks(pdf, range) adds trim marks to the given pages, if the
* trimbox exists.
*/
void cpdf_trimMarks(int, int);
/* cpdf_showBoxes(pdf, range) shows the boxes on the given pages, for debug. */
void cpdf_showBoxes(int, int);
/* cpdf_hardBox make a given box a 'hard box' i.e clips it explicitly. */
void cpdf_hardBox(int, int, const char[]);
def showBoxes(pdf, r):
"""showBoxes(pdf, range) shows the boxes on the given pages, for debug."""
def hardBox(pdf, r, boxname):
"""hardBox make a given box a 'hard box' i.e clips it explicitly."""

View File

@ -1,4 +1,3 @@
/* CHAPTER 4. Encryption */
/* Encryption covered under Chapter 1 in cpdflib. */
# CHAPTER 4. Encryption
# Encryption covered under Chapter 1 in pycpdflib

View File

@ -1,17 +1,12 @@
/* CHAPTER 5. Compression */
# CHAPTER 5. Compression
/*
* cpdf_compress(pdf) compresses any uncompressed streams in the given PDF
* using the Flate algorithm.
*/
void cpdf_compress(int);
def compress(pdf):
"""compress(pdf) compresses any uncompressed streams in the given PDF
using the Flate algorithm."""
/*
* cpdf_uncompress(pdf) uncompresses any streams in the given PDF, so long as
* the compression method is supported.
*/
void cpdf_decompress(int);
/* cpdf_squeezeToMemory(pdf) squeezes a pdf in memory. */
void cpdf_squeezeInMemory(int);
def decompress(pdf):
"""uncompress(pdf) uncompresses any streams in the given PDF, so long as
the compression method is supported."""
def squeezeInMemory(pdf):
"""squeezeToMemory(pdf) squeezes a pdf in memory."""

View File

@ -1,70 +1,9 @@
/* CHAPTER 6. Bookmarks */
# CHAPTER 6. Bookmarks
/*
* cpdf_startGetBookmarkInfo(pdf) start the bookmark retrieval process for a
* given PDF.
*/
void cpdf_startGetBookmarkInfo(int);
/*
* cpdf_numberBookmarks gets the number of bookmarks for the PDF given to
* cpdf_startGetBookmarkInfo.
*/
int cpdf_numberBookmarks(void);
/*
* cpdf_getBookmarkLevel(serial) get bookmark level for the given bookmark
* (0...(n - 1)).
*/
int cpdf_getBookmarkLevel(int);
/*
* cpdf_getBookmarkPage gets the bookmark target page for the given PDF
* (which must be the same as the PDF passed to cpdf_startSetBookmarkInfo)
* and bookmark (0...(n - 1)).
*/
int cpdf_getBookmarkPage(int, int);
/* cpdf_getBookmarkText returns the text of bookmark (0...(n - 1)). */
char *cpdf_getBookmarkText(int);
/* cpdf_getBookmarkOpenStatus(pdf) is true if the bookmark is open. */
int cpdf_getBookmarkOpenStatus(int);
/* cpdf_endGetBookmarkInfo ends the bookmark retrieval process, cleaning up. */
void cpdf_endGetBookmarkInfo(void);
/*
* cpdf_startGetBookmarkInfo(n) start the bookmark setting process for n
* bookmarks.
*/
void cpdf_startSetBookmarkInfo(int);
/*
* cpdf_setBookmarkLevel(n, level) set bookmark level for the given bookmark
* (0...(n - 1)).
*/
void cpdf_setBookmarkLevel(int, int);
/*
* cpdf_setBookmarkPage(pdf, bookmark, targetpage) sets the bookmark target
* page for the given PDF (which must be the same as the PDF to be passed to
* cpdf_endSetBookmarkInfo) and bookmark (0...(n - 1)).
*/
void cpdf_setBookmarkPage(int, int, int);
/*
* cpdf_setBookmarkOpenStatus(n, status) set the open status of a bookmark,
* true or false.
*/
void cpdf_setBookmarkOpenStatus(int, int);
/* cpdf_setBookmarkText(n, text) sets the text of bookmark (0...(n - 1)). */
void cpdf_setBookmarkText(int, const char[]);
/*
* cpdf_endSetBookmarkInfo(pdf) end the bookmark setting process, writing the
* bookmarks to the given PDF.
*/
void cpdf_endSetBookmarkInfo(int);
def getBookmarks(pdf):
"""Get the bookmarks for a PDF as a list of tuples.
(level : int, page : int, text : string, openstatus : bool)"""
def setBookmarks(pdf, marks):
"""Set the bookmarks for a PDF as a list of tuples.
(level : int, page : int, text : string, openstatus : bool)"""

View File

@ -1,4 +1,3 @@
/* CHAPTER 7. Presentations */
/* Not included in the library version. */
# CHAPTER 7. Presentations
# Not included in the library version

View File

@ -1,175 +1,130 @@
/* CHAPTER 8. Logos, Watermarks and Stamps */
# CHAPTER 8. Logos, Watermarks and Stamps
/*
* cpdf_stampOn(stamp_pdf, pdf, range) stamps stamp_pdf on top of all the
* pages in the document which are in the range. The stamp is placed with its
* origin at the origin of the target document.
*/
void cpdf_stampOn(int, int, int);
def stampOn(pdf, pdf2, r):
"""stampOn(stamp_pdf, pdf, range) stamps stamp_pdf on top of all the
pages in the document which are in the range. The stamp is placed with its
origin at the origin of the target document."""
/*
* cpdf_stampUnder(stamp_pdf, pdf, range) stamps stamp_pdf under all the
* pages in the document which are in the range. The stamp is placed with its
* origin at the origin of the target document.
*/
void cpdf_stampUnder(int, int, int);
def stampUnder(pdf, pdf2, r):
"""stampUnder(stamp_pdf, pdf, range) stamps stamp_pdf under all the pages
in the document which are in the range. The stamp is placed with its origin
at the origin of the target document."""
/*
* cpdf_stampExtended(pdf, pdf2, range, isover, scale_stamp_to_fit, pos,
* relative_to_cropbox) is a stamping function with extra features. - isover
* true, pdf goes over pdf2, isover false, pdf goes under pdf2 -
* scale_stamp_to_fit scales the stamp to fit the page - pos gives the
* position to put the stamp - relative_to_cropbox: if true, pos is relative
* to cropbox not mediabox.
*/
void cpdf_stampExtended(int, int, int, int, int, struct cpdf_position, int);
def stampExtended(pdf, pdf2, r, isover, scale_stamp_to_fit, pos,
relative_to_cropbox):
"""stampExtended(pdf, pdf2, range, isover, scale_stamp_to_fit, pos,
relative_to_cropbox) is a stamping function with extra features.
- isover True, pdf goes over pdf2, isover False, pdf goes under pdf2
- scale_stamp_to_fit scales the stamp to fit the page
- pos gives the position to put the stamp
- relative_to_cropbox: if True, pos is relative to cropbox not mediabox"""
/*
* cpdf_combinePages(under, over) combines the PDFs page-by-page, putting
* each page of 'over' over each page of 'under'.
*/
int cpdf_combinePages(int, int);
def combinePages(pdf, pdf2):
"""combinePages(under, over) combines the PDFs page-by-page, putting
each page of 'over' over each page of 'under'"""
/* Adding text. Adds text to a PDF, if the characters exist in the font. */
"""Fonts."""
timesRoman
timesBold
timesItalic
timesBoldItalic
helvetica
helveticaBold
helveticaOblique
helveticaBoldOblique
courier
courierBold
courierOblique
courierBoldOblique
/*
* Special codes
*
* %Page Page number in arabic notation (1, 2, 3...)
*
* %roman Page number in lower-case roman notation (i, ii, iii...)
*
* %Roman Page number in upper-case roman notation (I, II, III...)
*
* %EndPage Last page of document in arabic notation
*
* %Label The page label of the page
*
* %EndLabel The page label of the last page
*
* %filename The full file name of the input document
*
* %a Abbreviated weekday name (Sun, Mon etc.)
*
* %A Full weekday name (Sunday, Monday etc.)
*
* %b Abbreviated month name (Jan, Feb etc.)
*
* %B Full month name (January, February etc.)
*
* %d Day of the month (01-31)
*
* %e Day of the month (1-31)
*
* %H Hour in 24-hour clock (00-23)
*
* %I Hour in 12-hour clock (01-12)
*
* %j Day of the year (001-366)
*
* %m Month of the year (01-12)
*
* %M Minute of the hour (00-59)
*
* %p "a.m" or "p.m"
*
* %S Second of the minute (00-61)
*
* %T Same as %H:%M:%S
*
* %u Weekday (1-7, 1 = Monday)
*
* %w Weekday (0-6, 0 = Monday)
*
* %Y Year (0000-9999)
*
* %% The % character
*/
"""Jusitifications."""
leftJustify
centreJustify
rightJustify
/* The standard fonts */
enum cpdf_font {
cpdf_timesRoman, /* Times Roman */
cpdf_timesBold, /* Times Bold */
cpdf_timesItalic, /* Times Italic */
cpdf_timesBoldItalic, /* Times Bold Italic */
cpdf_helvetica, /* Helvetica */
cpdf_helveticaBold, /* Helvetica Bold */
cpdf_helveticaOblique, /* Helvetica Oblique */
cpdf_helveticaBoldOblique, /* Helvetica Bold Oblique */
cpdf_courier, /* Courier */
cpdf_courierBold, /* Courier Bold */
cpdf_courierOblique, /* Courier Oblique */
cpdf_courierBoldOblique /* Courier Bold Oblique */
};
/* Justifications for multi line text */
enum cpdf_justification {
cpdf_leftJustify, /* Left justify */
cpdf_CentreJustify, /* Centre justify */
cpdf_RightJustify /* Right justify */
};
def addText(metrics, pdf, r, text, p, line_spacing, bates, font, size, red,
green, blue, underneath, relative_to_cropbox, outline, opacity,
justification, midline, topline, filename, line_width,
embed_fonts):
"""Adding text. Adds text to a PDF, if the characters exist in the font.
/* Add text */
void cpdf_addText(int, /* If true, don't actually add text but
* collect metrics. */
int, /* Document */
int, /* Page Range */
const char[], /* The text to add */
struct cpdf_position, /* Position to add text at */
double, /* Linespacing, 1.0 = normal */
int, /* Starting Bates number */
enum cpdf_font, /* Font */
double, /* Font size in points */
double, /* Red component of colour, 0.0 - 1.0 */
double, /* Green component of colour, 0.0 - 1.0 */
double, /* Blue component of colour, 0.0 - 1.0 */
int, /* If true, text is added underneath rather
* than on top */
int, /* If true, position is relative to crop box
* not media box */
int, /* If true, text is outline rather than
* filled */
double, /* Opacity, 1.0 = opaque, 0.0 = wholly
* transparent */
enum cpdf_justification, /* Justification */
int, /* If true, position is relative to midline
* of text, not baseline */
int, /* If true, position is relative to topline
* of text, not baseline */
const char[], /* filename that this document was read from
* (optional) */
double, /* line width */
int /* embed fonts */
);
* metrics: If True, don't actually add text but collect metrics.
* pdf: Document
* r: Page Range
* text: The text to add
* p: Position to add text at
* line_spacing: Linespacing, 1.0 = normal
* bates: Starting Bates number
* font: Font
* size: Font size in points
* red: Red component of colour, 0.0 - 1.0
* green: Green component of colour, 0.0 - 1.0
* blue: Blue component of colour, 0.0 - 1.0
* underneath: If True, text is added underneath rather than on top
* relative_to_cropbox: If True, position is relative to crop box not
media box
* outline: If True, text is outline rather than filled
* opacity: Opacity, 1.0 = opaque, 0.0 = wholly transparent
* justification: Justification
* midline: If True, position is relative to midline of text, not
baseline
* topline: If True, position is relative to topline of text, not
baseline
* filename: filename that this document was read from (optional)
* line_width: line width
* embed_fonts: embed fonts
/* Add text, with most parameters default. */
void cpdf_addTextSimple(int, /* Document */
int, /* Page range */
const char[], /* The text to add */
struct cpdf_position, /* Position to add text
* at */
enum cpdf_font, /* font */
double); /* font size */
Special codes
/*
* cpdf_removeText(pdf, range) will remove any text added by libcpdf from the
* given pages.
*/
void cpdf_removeText(int, int);
* %Page Page number in arabic notation (1, 2, 3...)
* %roman Page number in lower-case roman notation (i, ii, iii...)
* %Roman Page number in upper-case roman notation (I, II, III...)
* %EndPage Last page of document in arabic notation
* %Label The page label of the page
* %EndLabel The page label of the last page
* %filename The full file name of the input document
* %a Abbreviated weekday name (Sun, Mon etc.)
* %A Full weekday name (Sunday, Monday etc.)
* %b Abbreviated month name (Jan, Feb etc.)
* %B Full month name (January, February etc.)
* %d Day of the month (01-31)
* %e Day of the month (1-31)
* %H Hour in 24-hour clock (00-23)
* %I Hour in 12-hour clock (01-12)
* %j Day of the year (001-366)
* %m Month of the year (01-12)
* %M Minute of the hour (00-59)
* %p "a.m" or "p.m"
* %S Second of the minute (00-61)
* %T Same as %H:%M:%S
* %u Weekday (1-7, 1 = Monday)
* %w Weekday (0-6, 0 = Monday)
* %Y Year (0000-9999)
* %% The % character"""
/*
* Return the width of a given string in the given font in thousandths of a
* point.
*/
int cpdf_textWidth(enum cpdf_font, const char[]);
def addTextSimple(pdf, r, text, p, font, size):
"""like addText, but with most parameters default
* pdf = the document
* r = the range
* p = the position
* font = the font
* size = the font size"""
/* cpdf_addContent(content, before, range, pdf) adds page content before (if
* true) or after (if false) the existing content to pages in the given range
* in the given PDF. */
void cpdf_addContent(const char[], int, int, int);
def removeText(pdf, r):
"""removeText(pdf, range) will remove any text added by libcpdf from the
given pages."""
/* cpdf_stampAsXObject(pdf, range, stamp_pdf) stamps stamp_pdf onto the pages
* in the given range in pdf as a shared Form XObject. The name of the
* newly-created XObject is returned. */
char *cpdf_stampAsXObject(int, int, int);
def textWidth(font, string):
"""Return the width of a given string in the given font in thousandths of a
point."""
def addContent(content, before, pdf, r):
"""addContent(content, before, range, pdf) adds page content before (if
True) or after (if False) the existing content to pages in the given range
in the given PDF."""
def stampAsXObject(pdf, r, stamp_pdf):
"""stampAsXObject(pdf, range, stamp_pdf) stamps stamp_pdf onto the pages
in the given range in pdf as a shared Form XObject. The name of the
newly-created XObject is returned."""

View File

@ -1,37 +1,30 @@
/* CHAPTER 9. Multipage facilities */
# CHAPTER 9. Mulitpage facilities
/*
* Impose a document two up. cpdf_twoUp does so by retaining the existing
* page size, scaling pages down. cpdf_twoUpStack does so by doubling the
* page size, to fit two pages on one.
*/
void cpdf_twoUp(int);
void cpdf_twoUpStack(int);
def twoUp(pdf):
"""Impose a document two up. twoUp does so by retaining the existing page
size, scaling pages down. twoUpStack does so by doubling the page size,
to fit two pages on one."""
/*
* cpdf_padBefore(pdf, range) adds a blank page before each page in the given
* range.
*/
void cpdf_padBefore(int, int);
def twoUpStack(pdf):
"""Impose a document two up. twoUp does so by retaining the existing page
size, scaling pages down. twoUpStack does so by doubling the page size,
to fit two pages on one."""
/*
* cpdf_padAfter(pdf, range) adds a blank page after each page in the given
* range.
*/
void cpdf_padAfter(int, int);
def padBefore(pdf, r):
"""padBefore(pdf, range) adds a blank page before each page in the given
range"""
/* cpdf_pageEvery(pdf, n) adds a blank page after every n pages. */
void cpdf_padEvery(int, int);
def padAfter(pdf, r):
"""padAfter(pdf, range) adds a blank page after each page in the given
range"""
/*
* cpdf_padMultiple(pdf, n) adds pages at the end to pad the file to a
* multiple of n pages in length.
*/
void cpdf_padMultiple(int, int);
def padEvery(pdf, n):
"""pageEvery(pdf, n) adds a blank page after every n pages"""
/*
* cpdf_padMultiple(pdf, n) adds pages at the beginning to pad the file to a
* multiple of n pages in length.
*/
void cpdf_padMultipleBefore(int, int);
def padMultiple(pdf, n):
"""padMultiple(pdf, n) adds pages at the end to pad the file to a multiple
of n pages in length."""
def padMultipleBefore(pdf, n):
"""padMultiple(pdf, n) adds pages at the beginning to pad the file to a
multiple of n pages in length."""

View File

@ -1,4 +1,3 @@
/* CHAPTER 10. Annotations */
/* Not in the library version */
# CHAPTER 10. Annotations
# Not in the library version.

View File

@ -1,303 +1,298 @@
/* CHAPTER 11. Document Information and Metadata */
# CHAPTER 11. Document Information and Metadata
/*
* cpdf_isLinearized(filename) finds out if a document is linearized as
* quickly as possible without loading it.
*/
int cpdf_isLinearized(const char[]);
def isLinearized(filename):
"""isLinearized(filename) finds out if a document is linearized as quickly
as possible without loading it."""
/* cpdf_getVersion(pdf) returns the minor version number of a document. */
int cpdf_getVersion(int);
def getVersion(pdf):
"""vetVersion(pdf) returns the minor version number of a document."""
/* cpdf_getMajorVersion(pdf) returns the minor version number of a document. */
int cpdf_getMajorVersion(int);
def getMajorVersion(pdf):
"""getMajorVersion(pdf) returns the minor version number of a document."""
/* cpdf_getTitle(pdf) returns the title of a document. */
char *cpdf_getTitle(int);
def getTitle(pdf):
"""getTitle(pdf) returns the title of a document."""
/* cpdf_getAuthor(pdf) returns the author of a document. */
char *cpdf_getAuthor(int);
def getAuthor(pdf):
"""getSubject(pdf) returns the subject of a document."""
/* cpdf_getSubject(pdf) returns the subject of a document. */
char *cpdf_getSubject(int);
def getSubject(pdf):
"""getSubject(pdf) returns the subject of a document."""
/* cpdf_getKeywords(pdf) returns the keywords of a document. */
char *cpdf_getKeywords(int);
def getKeywords(pdf):
"""getKeywords(pdf) returns the keywords of a document."""
/* cpdf_getCreator(pdf) returns the creator of a document. */
char *cpdf_getCreator(int);
def getCreator(pdf):
"""getCreator(pdf) returns the creator of a document."""
/* cpdf_getProducer(pdf) returns the producer of a document. */
char *cpdf_getProducer(int);
def getProducer(pdf):
"""getProducer(pdf) returns the producer of a document."""
/* cpdf_getCreationDate(pdf) returns the creation date of a document. */
char *cpdf_getCreationDate(int);
def getCreationDate(pdf):
"""getCreationDate(pdf) returns the creation date of a document."""
/* cpdf_getModificationDate(pdf) returns the modification date of a document. */
char *cpdf_getModificationDate(int);
def getModificationDate(pdf):
"""getModificationDate(pdf) returns the modification date of a document."""
/* cpdf_getTitleXMP(pdf) returns the XMP title of a document. */
char *cpdf_getTitleXMP(int);
def getTitleXMP(pdf):
"""getTitleXMP(pdf) returns the XMP title of a document."""
/* cpdf_getAuthorXMP(pdf) returns the XMP author of a document. */
char *cpdf_getAuthorXMP(int);
def getAuthorXMP(pdf):
"""getAuthorXMP(pdf) returns the XMP author of a document."""
/* cpdf_getSubjectXMP(pdf) returns the XMP subject of a document. */
char *cpdf_getSubjectXMP(int);
def getSubjectXMP(pdf):
"""getSubjectXMP(pdf) returns the XMP subject of a document."""
/* cpdf_getKeywordsXMP(pdf) returns the XMP keywords of a document. */
char *cpdf_getKeywordsXMP(int);
def getKeywordsXMP(pdf):
"""getKeywordsXMP(pdf) returns the XMP keywords of a document."""
/* cpdf_getCreatorXMP(pdf) returns the XMP creator of a document. */
char *cpdf_getCreatorXMP(int);
def getCreatorXMP(pdf):
"""getCreatorXMP(pdf) returns the XMP creator of a document."""
/* cpdf_getProducerXMP(pdf) returns the XMP producer of a document. */
char *cpdf_getProducerXMP(int);
def getProducerXMP(pdf):
"""getProducerXMP(pdf) returns the XMP producer of a document."""
/* cpdf_getCreationDateXMP(pdf) returns the XMP creation date of a document. */
char *cpdf_getCreationDateXMP(int);
def getCreationDateXMP(pdf):
"""getCreationDateXMP(pdf) returns the XMP creation date of a document."""
/*
* cpdf_getModificationDateXMP(pdf) returns the XMP modification date of a
* document.
*/
char *cpdf_getModificationDateXMP(int);
def getModificationDateXMP(pdf):
"""getModificationDateXMP(pdf) returns the XMP modification date of a
document."""
/* cpdf_setTitle(pdf) sets the title of a document. */
void cpdf_setTitle(int, const char[]);
def setTitle(pdf, s):
"""setTitle(pdf) sets the title of a document."""
/* cpdf_setAuthor(pdf) sets the author of a document. */
void cpdf_setAuthor(int, const char[]);
def setAuthor(pdf, s):
"""setAuthor(pdf) sets the author of a document."""
/* cpdf_setSubject(pdf) sets the subject of a document. */
void cpdf_setSubject(int, const char[]);
def setSubject(pdf, s):
"""setSubject(pdf) sets the subject of a document."""
/* cpdf_setKeywords(pdf) sets the keywords of a document. */
void cpdf_setKeywords(int, const char[]);
def setKeywords(pdf, s):
"""setKeywords(pdf) sets the keywords of a document."""
/* cpdf_setCreator(pdf) sets the creator of a document. */
void cpdf_setCreator(int, const char[]);
def setCreator(pdf, s):
"""setCreator(pdf) sets the creator of a document."""
/* cpdf_setProducer(pdf) sets the producer of a document. */
void cpdf_setProducer(int, const char[]);
def setProducer(pdf, s):
"""setProducer(pdf) sets the producer of a document."""
/* cpdf_setCreationDate(pdf) sets the creation date of a document. */
void cpdf_setCreationDate(int, const char[]);
def setCreationDate(pdf, s):
"""setCreationDate(pdf) sets the creation date of a document."""
/* cpdf_setModificationDate(pdf) sets the modifcation date of a document. */
void cpdf_setModificationDate(int, const char[]);
def setModificationDate(pdf, s):
"""setModificationDate(pdf) sets the modifcation date of a document."""
/* cpdf_setTitleXMP(pdf) set the XMP title of a document. */
void cpdf_setTitleXMP(int, const char[]);
def setTitleXMP(pdf, s):
"""setTitleXMP(pdf) set the XMP title of a document."""
/* cpdf_setAuthorXMP(pdf) set the XMP author of a document. */
void cpdf_setAuthorXMP(int, const char[]);
def setAuthorXMP(pdf, s):
"""setAuthorXMP(pdf) set the XMP author of a document."""
/* cpdf_setSubjectXMP(pdf) set the XMP subject of a document. */
void cpdf_setSubjectXMP(int, const char[]);
def setSubjectXMP(pdf, s):
"""setSubjectXMP(pdf) set the XMP subject of a document."""
/* cpdf_setKeywordsXMP(pdf) set the XMP keywords of a document. */
void cpdf_setKeywordsXMP(int, const char[]);
/* cpdf_setCreatorXMP(pdf) set the XMP creator of a document. */
void cpdf_setCreatorXMP(int, const char[]);
/* cpdf_setProducerXMP(pdf) set the XMP producer of a document. */
void cpdf_setProducerXMP(int, const char[]);
def setKeywordsXMP(pdf, s):
"""setKeywordsXMP(pdf) set the XMP keywords of a document."""
/* cpdf_setCreationDateXMP(pdf) set the XMP creation date of a document. */
void cpdf_setCreationDateXMP(int, const char[]);
def setCreatorXMP(pdf, s):
"""setCreatorXMP(pdf) set the XMP creator of a document."""
/*
* cpdf_setModificationDateXMP(pdf) set the XMP modification date of a
* document.
*/
void cpdf_setModificationDateXMP(int, const char[]);
def setProducerXMP(pdf, s):
"""setProducerXMP(pdf) set the XMP producer of a document."""
/*
* Dates: Month 1-31, day 1-31, hours (0-23), minutes (0-59), seconds (0-59),
* hour_offset is the offset from UT in hours (-23 to 23); minute_offset is
* the offset from UT in minutes (-59 to 59).
*/
def setCreationDateXMP(pdf, s):
"""setCreationDateXMP(pdf) set the XMP creation date of a document."""
/*
* cpdf_getDateComponents(datestring, year, month, day, hour, minute, second,
* hour_offset, minute_offset) returns the components from a PDF date string.
*/
void cpdf_getDateComponents(const char[], int *, int *, int *, int *, int *,
int *, int *, int *);
def setModificationDateXMP(pdf, s):
"""setModificationDateXMP(pdf) set the XMP modification date of a
document."""
/*
* cpdf_dateStringOfComponents(year, month, day, hour, minute, second,
* hour_offset, minute_offset) builds a PDF date string from individual
* components.
*/
char *cpdf_dateStringOfComponents(int, int, int, int, int, int, int, int);
/*
* cpdf_getPageRotation(pdf, pagenumber) gets the viewing rotation for a
* given page.
*/
int cpdf_getPageRotation(int, int);
/*
* cpdf_hasBox(pdf, pagenumber, boxname) returns true, if that page has the
* given box. E.g "/CropBox".
*/
int cpdf_hasBox(int, int, const char[]);
/*
* These functions get a box given the document, page range, min x, max x,
* min y, max y in points. Only succeeds if such a box exists, as checked by
* cpdf_hasBox.
*/
void cpdf_getMediaBox(int, int, double *, double *, double *, double *);
void cpdf_getCropBox(int, int, double *, double *, double *, double *);
void cpdf_getTrimBox(int, int, double *, double *, double *, double *);
void cpdf_getArtBox(int, int, double *, double *, double *, double *);
void cpdf_getBleedBox(int, int, double *, double *, double *, double *);
/*
* These functions set a box given the document, page range, min x, max x,
* min y, max y in points.
*/
void cpdf_setMediabox(int, int, double, double, double, double);
void cpdf_setCropBox(int, int, double, double, double, double);
void cpdf_setTrimBox(int, int, double, double, double, double);
void cpdf_setArtBox(int, int, double, double, double, double);
void cpdf_setBleedBox(int, int, double, double, double, double);
/* cpdf_markTrapped(pdf) marks a document as trapped. */
void cpdf_markTrapped(int);
/* cpdf_markUntrapped(pdf) marks a document as untrapped. */
void cpdf_markUntrapped(int);
/* cpdf_markTrappedXMP(pdf) marks a document as trapped in XMP metadata. */
void cpdf_markTrappedXMP(int);
/* cpdf_markUntrappedXMP(pdf) marks a document as untrapped in XMP metadata. */
void cpdf_markUntrappedXMP(int);
/* Document Layouts. */
enum cpdf_layout {
cpdf_singlePage,
cpdf_oneColumn,
cpdf_twoColumnLeft,
cpdf_twoColumnRight,
cpdf_twoPageLeft,
cpdf_twoPageRight
};
/* cpdf_setPageLayout(pdf, layout) sets the page layout for a document. */
void cpdf_setPageLayout(int, enum cpdf_layout);
/* Document page modes. */
enum cpdf_pageMode {
cpdf_useNone,
cpdf_useOutlines,
cpdf_useThumbs,
cpdf_useOC,
cpdf_useAttachments
};
/* cpdf_setPageMode(pdf, mode) sets the page mode for a document. */
void cpdf_setPageMode(int, enum cpdf_pageMode);
/* cpdf_hideToolbar(pdf, flag) sets the hide toolbar flag. */
void cpdf_hideToolbar(int, int);
/* cpdf_hideMenubar(pdf, flag) sets the hide menu bar flag. */
void cpdf_hideMenubar(int, int);
/* cpdf_hideWindowUi(pdf, flag) sets the hide window UI flag. */
void cpdf_hideWindowUi(int, int);
/* cpdf_fitWindow(pdf, flag) sets the fit window flag. */
void cpdf_fitWindow(int, int);
/* cpdf_centerWindow(pdf, flag) sets the center window flag. */
void cpdf_centerWindow(int, int);
/* cpdf_displayDocTitle(pdf, flag) sets the display doc title flag. */
void cpdf_displayDocTitle(int, int);
/* cpdf_openAtPage(pdf, fit, pagenumber) sets the PDF to open, possibly with
* zoom-to-fit, at the given page number. */
void cpdf_openAtPage(int, int, int);
/*
* cpdf_setMetadataFromFile(pdf, filename) set the XMP metadata of a
* document, given a file name.
*/
void cpdf_setMetadataFromFile(int, const char[]);
/*
* cpdf_setMetadataFromByteArray(pdf, data, length) set the XMP metadata from
* an array of bytes.
*/
void cpdf_setMetadataFromByteArray(int, void *, int);
/*
* cpdf_getMetadata(pdf, &length) returns the XMP metadata and fills in
* length.
*/
void *cpdf_getMetadata(int, int *);
/* cpdf_removeMetadata(pdf) removes the XMP metadata from a document. */
void cpdf_removeMetadata(int);
/*
* cpdf_createMetadata(pdf) builds fresh metadata as best it can from
* existing metadata in the document.
*/
void cpdf_createMetadata(int);
/*
* cpdf_setMetadataDate(pdf, date) sets the metadata date for a PDF. The date
* is given in PDF date format -- cpdf will convert it to XMP format. The
* date 'now' means now.
*/
void cpdf_setMetadataDate(int, const char[]);
/* Styles of page label */
enum cpdf_pageLabelStyle {
cpdf_decimalArabic, /* 1, 2, 3... */
cpdf_uppercaseRoman, /* I, II, III... */
cpdf_lowercaseRoman, /* i, ii, iii... */
cpdf_uppercaseLetters, /* A, B, C... */
cpdf_lowercaseLetters /* a, b, c... */
};
/*
* Add page labels.
*
* cpdf_addPageLabels(pdf, style, prefix, offset, range, progress)
*
* The prefix is prefix text for each label. The range is the page range the
* labels apply to. Offset can be used to shift the numbering up or down.
*/
void cpdf_addPageLabels(int, enum cpdf_pageLabelStyle, const char[], int, int,
int);
/* cpdf_removePageLabels(pdf) removes the page labels from the document. */
void cpdf_removePageLabels(int);
/*
* cpdf_getPageLabelStringForPage(pdf, page number) calculates the full label
* string for a given page, and returns it.
*/
char *cpdf_getPageLabelStringForPage(int, int);
/*
* Get page label data. Call cpdf_startGetPageLabels to find out how many
* there are, then use these serial numbers to get the style, prefix, offset
* and range. Call cpdf_endGetPageLabels to clean up.
*/
int cpdf_startGetPageLabels(int);
enum cpdf_pageLabelStyle cpdf_getPageLabelStyle(int);
char *cpdf_getPageLabelPrefix(int);
int cpdf_getPageLabelOffset(int);
int cpdf_getPageLabelRange(int);
void cpdf_endGetPageLabels();
def getDateComponents(string):
"""Dates: Month 1-31, day 1-31, hours (0-23), minutes (0-59), seconds
(0-59), hour_offset is the offset from UT in hours (-23 to 23);
minute_offset is the offset from UT in minutes (-59 to 59).
getDateComponents(datestring, year, month, day, hour, minute, second,
hour_offset, minute_offset) returns the components from a PDF date
string."""
def dateStringOfComponents(cs):
"""Dates: Month 1-31, day 1-31, hours (0-23), minutes (0-59), seconds
(0-59), hour_offset is the offset from UT in hours (-23 to 23);
minute_offset is the offset from UT in minutes (-59 to 59).
dateStringOfComponents(year, month, day, hour, minute, second,
hour_offset, minute_offset) builds a PDF date string from individual
components."""
def getPageRotation(pdf, pagenumber):
"""getPageRotation(pdf, pagenumber) gets the viewing rotation for a given
page."""
def hasBox(pdf, pagenumber, boxname):
"""hasBox(pdf, pagenumber, boxname) returns True, if that page has the
given box. E.g "/CropBox" """
def getMediaBox(pdf, pagenumber):
"""These functions get a box given the document, page range, min x, max x,
min y, max y in points. Only suceeds if such a box exists, as checked by
hasBox"""
def getCropBox(pdf, pagenumber):
"""These functions get a box given the document, page range, min x, max x,
min y, max y in points. Only suceeds if such a box exists, as checked by
hasBox"""
def getTrimBox(pdf, pagenumber):
"""These functions get a box given the document, page range, min x, max x,
min y, max y in points. Only suceeds if such a box exists, as checked by
hasBox"""
def getArtBox(pdf, pagenumber):
"""These functions get a box given the document, page range, min x, max x,
min y, max y in points. Only suceeds if such a box exists, as checked by
hasBox"""
def getBleedBox(pdf, pagenumber):
"""These functions get a box given the document, page range, min x, max x,
min y, max y in points. Only suceeds if such a box exists, as checked by
hasBox"""
def setMediaBox(pdf, r, minx, maxx, miny, maxy):
"""These functions set a box given the document, page range, min x, max x,
min y, max y in points."""
def setCropBox(pdf, r, minx, maxx, miny, maxy):
"""These functions set a box given the document, page range, min x, max x,
min y, max y in points."""
def setTrimBox(pdf, r, minx, maxx, miny, maxy):
"""These functions set a box given the document, page range, min x, max x,
min y, max y in points."""
def setArtBox(pdf, r, minx, maxx, miny, maxy):
"""These functions set a box given the document, page range, min x, max x,
min y, max y in points."""
def setBleedBox(pdf, r, minx, maxx, miny, maxy):
"""These functions set a box given the document, page range, min x, max x,
min y, max y in points."""
def markTrapped(pdf):
"""markTrapped(pdf) marks a document as trapped."""
def markUntrapped(pdf):
"""markUntrapped(pdf) marks a document as untrapped."""
def markTrappedXMP(pdf):
"""markTrappedXMP(pdf) marks a document as trapped in XMP metadata."""
def markUntrappedXMP(pdf):
"""markUntrappedXMP(pdf) marks a document as untrapped in XMP metadata."""
"""Page layouts."""
singlePage
oneColumn
twoColumnLeft
twoColumnRight
twoPageLeft
twoPageRight
def setPageLayout(pdf, layout):
"""setPageLayout(pdf, layout) sets the page layout for a document."""
"""Page modes."""
useNone
useOutlines
useThumbs
useOC
useAttachments
def setPageMode(pdf, mode):
"""setPageMode(pdf, mode) sets the page mode for a document."""
def hideToolbar(pdf, flag):
"""hideToolbar(pdf, flag) sets the hide toolbar flag"""
def hideMenubar(pdf, flag):
"""hideMenubar(pdf, flag) sets the hide menu bar flag"""
def hideWindowUi(pdf, flag):
"""hideWindowUi(pdf, flag) sets the hide window UI flag"""
def fitWindow(pdf, flag):
"""fitWindow(pdf, flag) sets the fit window flag"""
def centerWindow(pdf, flag):
"""centerWindow(pdf, flag) sets the center window flag"""
def displayDocTitle(pdf, flag):
"""displayDocTitle(pdf, flag) sets the display doc title flag"""
def openAtPage(pdf, flag, pagenumber):
"""openAtPage(pdf, fit, pagenumber)"""
def setMetadataFromFile(pdf, filename):
"""setMetadataFromFile(pdf, filename) set the XMP metadata of a document,
given a file name."""
def setMetadataFromByteArray(pdf, data):
"""setMetadataFromByteArray(pdf, data, length) set the XMP metadata from
an array of bytes."""
def getMetadata(pdf):
"""getMetadata(pdf, &length) returns the XMP metadata as a byte array of
type bytes"""
def removeMetadata(pdf):
"""removeMetadata(pdf) removes the XMP metadata from a document"""
def createMetadata(pdf):
"""createMetadata(pdf) builds fresh metadata as best it can from existing
metadata in the document."""
def setMetadataDate(pdf, date):
"""setMetadataDate(pdf, date) sets the metadata date for a PDF. The date
is given in PDF date format -- cpdf will convert it to XMP format. The date
'now' means now."""
"""Label styles."""
decimalArabic
uppercaseRoman
lowercaseRoman
uppercaseLetters
lowercaseLetters
def getPageLabels(pdf):
"""Get page labels as a list of tuples (style, prefix, offset, startvalue)
For example, a document might have five pages of introduction with roman
numerals, followed by the rest of the pages in decimal arabic, numbered
from one:
labelstyle = LowercaseRoman
labelprefix = ""
startpage = 1
startvalue = 1
labelstyle = DecimalArabic
labelprefix = ""
startpage = 6
startvalue = 1 """
def addPageLabels(pdf, label, progress):
"""Add page labels.
addPageLabels(pdf, style, prefix, offset, range, progress)
The prefix is prefix text for each label. The range is the page range the
labels apply to. Offset can be used to shift the numbering up or down."""
def removePageLabels(pdf):
"""removePageLabels(pdf) removes the page labels from the document."""
def getPageLabelStringForPage(pdf, pagenumber):
"""getPageLabelStringForPage(pdf, page number) calculates the full label

View File

@ -1,55 +1,24 @@
/* CHAPTER 12. File Attachments */
# CHAPTER 12. File Attachments
/*
* cpdf_attachFile(filename, pdf) attaches a file to the pdf. It is attached
* at document level.
*/
void cpdf_attachFile(const char[], int);
def attachFile(filename, pdf):
"""attachFile(filename, pdf) attaches a file to the pdf. It is attached at
document level."""
/*
* cpdf_attachFileToPage(filename, pdf, pagenumber) attaches a file, given
* its file name, pdf, and the page number to which it should be attached.
*/
void cpdf_attachFileToPage(const char[], int, int);
def attachFileToPage(filename, pdf, pagenumber):
"""attachFileToPage(filename, pdf, pagenumber) attaches a file, given its
file name, pdf, and the page number to which it should be attached."""
/*
* cpdf_attachFileFromMemory(memory, length, filename, pdf) attaches from
* memory, just like cpdf_attachFile.
*/
void cpdf_attachFileFromMemory(void *, int, const char[], int);
def attachFileFromMemory(data, filename, pdf):
"""attachFileFromMemory(memory, length, filename, pdf) attaches from
memory, just like attachFile."""
/*
* cpdf_attachFileToPageFromMemory(memory, length, filename, pdf, pagenumber)
* attaches from memory, just like cpdf_attachFileToPage.
*/
void cpdf_attachFileToPageFromMemory(void *, int, const char[], int, int);
def attachFileToPageFromMemory(data, filename, pdf, pagenumber):
"""attachFileToPageFromMemory(memory, length, filename, pdf, pagenumber)
attaches from memory, just like attachFileToPage."""
/* Remove all page- and document-level attachments from a document */
void cpdf_removeAttachedFiles(int);
/*
* List information about attachments. Call cpdf_startGetAttachments(pdf)
* first, then cpdf_numberGetAttachments to find out how many there are. Then
* cpdf_getAttachmentName to return each one 0...(n - 1). Finally, call
* cpdf_endGetAttachments to clean up.
*/
void cpdf_startGetAttachments(int);
/* Get the number of attachments. */
int cpdf_numberGetAttachments(void);
/* Get the name of the attachment. */
char *cpdf_getAttachmentName(int);
/* Gets the page number. 0 = document level. */
int cpdf_getAttachmentPage(int);
/*
* cpdf_getAttachmentData(serial number, &length) returns a pointer to the
* data, and its length.
*/
void *cpdf_getAttachmentData(int, int *);
/* Clean up after getting attachments. */
void cpdf_endGetAttachments(void);
def removeAttachedFiles(pdf):
"""Remove all page- and document-level attachments from a document"""
def getAttachments(pdf):
"""List information about attachements. Returns a list of tuples
(name, page number, byte array of data)"""

View File

@ -1,20 +1,6 @@
/* CHAPTER 13. Images. */
/*
* Get image data, including resolution at all points of use. Call
* cpdf_startGetImageResolution(pdf, min_required_resolution) will begin the
* process of obtaining data on all image uses below min_required_resolution,
* returning the total number. So, to return all image uses, specify a very
* high min_required_resolution. Then, call the other functions giving a
* serial number 0..<total number> - 1, to retrieve the data. Finally, call
* cpdf_endGetImageResolution to clean up.
*/
int cpdf_startGetImageResolution(int, float);
int cpdf_getImageResolutionPageNumber(int);
char *cpdf_getImageResolutionImageName(int);
int cpdf_getImageResolutionXPixels(int);
int cpdf_getImageResolutionYPixels(int);
double cpdf_getImageResolutionXRes(int);
double cpdf_getImageResolutionYRes(int);
void cpdf_endGetImageResolution(void);
# CHAPTER 13. Images
def getImageResolution(pdf, min_required_resolution):
"""Return a list of all uses of images in the PDF which do not meet the
minimum required resolution in dpi as tuples of:
(pagenumber, name, x pixels, y pixels, x resolution, y resolution)"""

View File

@ -1,27 +1,13 @@
/* CHAPTER 14. Fonts. */
# CHAPTER 14. Fonts
/*
* Retrieving font information. First, call cpdf_startGetFontInfo(pdf). Now
* call cpdf_numberFonts to return the number of fonts. For each font, call
* one or more of cpdf_getFontPage, cpdf_getFontName, cpdf_getFontType, and
* cpdf_getFontEncoding giving a serial number 0..<number of fonts> - 1 to
* return information. Finally, call cpdf_endGetFontInfo to clean up.
*/
void cpdf_startGetFontInfo(int);
int cpdf_numberFonts(void);
int cpdf_getFontPage(int);
char *cpdf_getFontName(int);
char *cpdf_getFontType(int);
char *cpdf_getFontEncoding(int);
void cpdf_endGetFontInfo(void);
def getFontInfo(pdf):
"""Get a list of (pagenumber, fontname, fonttype, fontencoding) tuples,
showing each font used on each page."""
/* cpdf_removeFonts(pdf) removes all font data from a file. */
void cpdf_removeFonts(int);
/*
* cpdf_copyFont(from, to, range, pagenumber, fontname) copies the given font
* from the given page in the 'from' PDF to every page in the 'to' PDF. The
* new font is stored under it's font name.
*/
void cpdf_copyFont(int, int, int, int, const char[]);
def removeFonts(pdf):
"""removeFonts(pdf) removes all font data from a file."""
def copyFont(pdf, pdf2, r, pagenumber, fontname):
"""copyFont(from, to, range, pagenumber, fontname) copies the given font
from the given page in the 'from' PDF to every page in the 'to' PDF. The
new font is stored under it's font name."""

View File

@ -1,8 +1,7 @@
/* CHAPTER 15. PDF and JSON */
/* cpdf_outputJSON(filename, parse_content, no_stream_data, pdf) outputs a PDF
* in JSON format to the given filename. If parse_content is true, page content
* is parsed. If no_stream_data is true, all stream data is suppressed entirely.
* */
void cpdf_outputJSON(const char[], int, int, int);
# CHAPTER 15. PDF and JSON
def outputJSON(filename, parse_content, no_stream_data, pdf):
"""outputJSON(filename, parse_content, no_stream_data, pdf) outputs a PDF
in JSON format to the given filename. If parse_content is True, page
content is parsed. If no_stream_data is True, all stream data is suppressed
entirely."""

View File

@ -1,24 +1,16 @@
/* CHAPTER 16. Optional Content Groups */
# CHAPTER 16. Optional Content Groups
/* Begin retrieving optional content group names. The serial number 0..<n - 1>
* is returned. */
int cpdf_startGetOCGList(int pdf);
def getOCGList(pdf):
"""Return a list of Optional Content Groups in the given pdf."""
/* Retrieve an OCG name, given its serial number 0..<n - 1>. */
char *cpdf_OCGListEntry(int i);
def OCGRename(pdf, n_from, n_to):
"""OCGRename(pdf, n_from, n_to) will rename an optional content group."""
/* End retrieval of optional content group names. */
void cpdf_endGetOCGList(void);
/* cpdf_OCGRename(pdf, from, to) will rename an optional content group. */
void cpdf_OCGRename(int, const char[], const char[]);
/* Ensure that every optional content group appears in the OCG order list. */
void cpdf_OCGOrderAll(int);
/* Coalesce optional content groups. For example, if we merge or stamp two
* files both with an OCG called "Layer 1", we will have two different optional
* content groups. This function will merge the two into a single optional
* content group. */
void cpdf_OCGCoalesce(int);
def OCGOrderAll(pdf):
"""Ensure that every optional content group appears in the OCG order list."""
def OCGCoalesce(pdf):
"""Coalesce optional content groups. For example, if we merge or stamp two
files both with an OCG called "Layer 1", we will have two different
optional content groups. This function will merge the two into a single
optional content group."""

View File

@ -1,54 +1,43 @@
/* CHAPTER 17. Miscellaneous */
# CHAPTER 17. Miscellaneous
/*
* cpdf_draft(pdf, range, boxes) removes images on the given pages, replacing
* them with crossed boxes if 'boxes' is true
*/
void cpdf_draft(int, int, int);
def draft(pdf, r, boxes):
"""draft(pdf, range, boxes) removes images on the given pages, replacing
them with crossed boxes if 'boxes' is true"""
/*
* cpdf_removeAllText(pdf, range) removes all text from the given pages in a
* given document.
*/
void cpdf_removeAllText(int, int);
def removeAllText(pdf, r):
"""removeAllText(pdf, range) removes all text from the given pages in a
given document."""
/* cpdf_blackText(pdf, range) blackens all text on the given pages. */
void cpdf_blackText(int, int);
def blackText(pdf, r):
"""blackText(pdf, range) blackens all text on the given pages."""
/* cpdf_blackLines(pdf, range) blackens all lines on the given pages. */
void cpdf_blackLines(int, int);
def blackLines(pdf, r):
"""blackLines(pdf, range) blackens all lines on the given pages."""
/* cpdf_blackFills(pdf, range) blackens all fills on the given pages. */
void cpdf_blackFills(int, int);
def blackFills(pdf, r):
"""blackFills(pdf, range) blackens all fills on the given pages."""
/*
* cpdf_thinLines(pdf, range, min_thickness) thickens every line less than
* min_thickness to min_thickness. Thickness given in points.
*/
void cpdf_thinLines(int, int, double);
def thinLines(pdf, r, linewidth):
"""thinLines(pdf, range, min_thickness) thickens every line less than
min_thickness to min_thickness. Thickness given in points."""
/* cpdf_copyId(from, to) copies the /ID from one document to another. */
void cpdf_copyId(int, int);
def copyId(pdf, pdf2):
"""copyId(from, to) copies the /ID from one document to another."""
/* cpdf_removeId(pdf) removes a document's /ID. */
void cpdf_removeId(int);
def removeId(pdf):
"""removeId(pdf) removes a document's /ID"""
/* cpdf_setVersion(pdf, version) sets the minor version number of a document. */
void cpdf_setVersion(int, int);
def setVersion(pdf, version):
"""setVersion(pdf, version) sets the minor version number of a document."""
/* cpdf_setFullVersion(pdf, major_version, minor_version) sets the full version
* number of a document. */
void cpdf_setFullVersion(int, int, int);
def setFullVersion(pdf, major, minor):
"""setFullVersion(pdf, version) sets the major and minor version number of
a document."""
/*
* cpdf_removeDictEntry(pdf, key) removes any dictionary entry with the given
* key anywhere in the document.
*/
void cpdf_removeDictEntry(int, const char[]);
/*
* cpdf_removeClipping(pdf, range) removes all clipping from pages in the
* given range.
*/
void cpdf_removeClipping(int, int);
def removeDictEntry(pdf, key):
"""removeDictEntry(pdf, key) removes any dictionary entry with the given
key anywhere in the document"""
def removeClipping(pdf, r):
"""removeClipping(pdf, range) removes all clipping from pages in the given
range"""

View File

@ -1,4 +0,0 @@
/* CHAPTER X. Internal or undocumented. */
/* Internal. Used for demo versions of the commercial version of cpdflib. */
void cpdf_setDemo(int);