Final v2.7 splits for C

This commit is contained in:
John Whitington 2024-04-16 09:44:25 +08:00
parent 3671c2d14b
commit d53c8bf327
12 changed files with 99 additions and 48 deletions

View File

@ -15,8 +15,8 @@ void cpdf_setFast();
void cpdf_setSlow();
/* Calling this function with a true argument sets embedding for the Standard
* 14 fonts. You must also set the directory to load them from with the next
* function. Default value: false. */
* 14 fonts. You must also set the directory to load them from with the
* cpdf_embedStd14Dir function. Default value: false. */
void cpdf_embedStd14(int);
/* Set the directory to load Standard 14 fonts for embedding. */
@ -33,7 +33,7 @@ extern int cpdf_lastError;
extern char *cpdf_lastErrorString;
/* In some contexts, for example, .NET or JNI, constants in DLLs can be
* difficult or impossible to access. we provide functions in addition. */
* difficult or impossible to access. We provide functions in addition. */
int cpdf_fLastError(void);
char *cpdf_fLastErrorString(void);

View File

@ -196,6 +196,10 @@ int cpdf_pagesFast(const char[], const char[]);
* cpdf_toFile (pdf, filename, linearize, make_id) writes the file to a given
* filename. If linearize is true, it will be linearized if a linearizer is
* available. If make_id is true, it will be given a new ID.
*
* NB: Unlike with the command line tool, cpdf, streams decompressed during
* processing will not automatically be compressed when writing. Call
* cpdf_compress() first.
*/
void cpdf_toFile(int, const char[], int, int);
@ -212,8 +216,12 @@ void cpdf_toFile(int, const char[], int, int);
void cpdf_toFileExt(int, const char[], int, int, int, int, int);
/*
* cpdf_toFileMemory (pdf, linearize, make_id, &length) writes a PDF file it
* and returns the buffer. The buffer length is filled in &length.
* cpdf_toFileMemory (pdf, linearize, make_id, sizse) writes a PDF file it
* and returns the buffer. The buffer length is filled in.
*
* NB: Unlike with the command line tool, cpdf, streams decompressed during
* processing will not automatically be compressed when writing. Call
* cpdf_compress() first.
*/
void *cpdf_toMemory(int, int, int, int *);

View File

@ -79,5 +79,5 @@ void cpdf_setBookmarksJSON(int, void *, int);
/* cpdf_tableOfContents(pdf, font, fontsize, title, bookmark) typesets a table
* of contents from existing bookmarks and prepends it to the document. If
* bookmark is set, the table of contents gets its own bookmark. */
void cpdf_tableOfContents(int, int, double, const char[], int);
void cpdf_tableOfContents(int, const char[], double, const char[], int);

View File

@ -47,6 +47,8 @@ int cpdf_combinePages(int, int);
*
* %EndLabel The page label of the last page
*
* %Filename The file name
*
* %a Abbreviated weekday name (Sun, Mon etc.)
*
* %A Full weekday name (Sunday, Monday etc.)
@ -85,20 +87,18 @@ int cpdf_combinePages(int, int);
*/
/* 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 */
};
char *cpdf_timesRoman = "Times-Roman";
char *cpdf_timesBold = "Times-Bold";
char *cpdf_timesItalic = "Times-Italic";
char *cpdf_timesBoldItalic = "Times-BoldItalic";
char *cpdf_helvetica = "Helvetica";
char *cpdf_helveticaBold = "Helvetica-Bold";
char *cpdf_helveticaOblique = "Helvetica-Oblique";
char *cpdf_helveticaBoldOblique = "Helvetica-BoldOblique";
char *cpdf_courier = "Courier";
char *cpdf_courierBold = "Courier-Bold";
char *cpdf_courierOblique = "Courier-Oblique";
char *cpdf_courierBoldOblique = "Courier-BoldOblique";
/* Justifications for multi line text */
enum cpdf_justification {
@ -116,7 +116,7 @@ void cpdf_addText(int, /* If true, don't actually add text but
struct cpdf_position, /* Position to add text at */
double, /* Linespacing, 1.0 = normal */
int, /* Starting Bates number */
enum cpdf_font, /* Font */
const char[], /* Font */
double, /* Font size in points */
double, /* Red component of colour, 0.0 - 1.0 */
double, /* Green component of colour, 0.0 - 1.0 */
@ -140,13 +140,13 @@ void cpdf_addText(int, /* If true, don't actually add text but
int /* embed fonts */
);
/* Add text, with most parameters default. */
/* Add text, with most parameters default. NB %filename cannot be used here. */
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 */
const char[], /* font */
double); /* font size */
/*
@ -156,10 +156,10 @@ void cpdf_addTextSimple(int, /* Document */
void cpdf_removeText(int, int);
/*
* Return the width of a given string in the given font in thousandths of a
* point.
* Return the width of a given string in the given standard font in thousandths
* of a point.
*/
int cpdf_textWidth(enum cpdf_font, const char[]);
int cpdf_textWidth(const char[], const char[]);
/* cpdf_addContent(content, before, pdf, range) adds page content before (if
* true) or after (if false) the existing content to pages in the given range

View File

@ -36,13 +36,20 @@ void cpdf_padMultipleBefore(int, int);
void cpdf_impose(int, double, double, int, int, int, int, int, double, double,
double);
/* cpdf_chop(pdf, range, x, y, columns, rtl, btt) */
/* cpdf_chop(pdf, range, x, y, columns, rtl, btt) chops each page in the range
* into x * y pieces. If columns is set, the pieces go by columns instead of
* rows. If rtl is set, the pieces are taken right-to-left. If btt is set, the
* pieces are taken from bottom to top. */
void cpdf_chop(int, int, int, int, int, int, int);
/* cpdf_choph(pdf, range, columns, y) */
/* cpdf_chopH(pdf, range, columns, y) chops each page in the range horizontally
* at position y. If columns is set, the pieces are arranged in reverse order.
* */
void cpdf_chopH(int, int, int, double);
/* cpdf_chopv(pdf, range, columns, x) */
/* cpdf_chopV(pdf, range, columns, x) chops each page in the range vertically
* at position x. If columns is set, the pieces are arranged in reverse order.
* */
void cpdf_chopV(int, int, int, double);
/*

View File

@ -9,6 +9,6 @@ void *cpdf_annotationsJSON(int, int *);
void cpdf_removeAnnotations(int, int);
/* cpdf_setAnnotationsJSON(pdf, data, length) adds the annotations given in
* JSON format to the PDF, on top of any exisiting annotations. */
* JSON format to the PDF, on top of any existing annotations. */
void cpdf_setAnnotationsJSON(int, void *, int);

View File

@ -6,18 +6,27 @@
*/
int cpdf_isLinearized(const char[]);
/* cpdf_hasObjectStreams(pdf) finds out if a document was written using object
* streams. */
int cpdf_hasObjectStreams(int);
/* cpdf_id1(pdfs) returns the first ID string of the PDF, if any, in
* hexadecimal string format. */
char *cpdf_id1(int);
/* cpdf_id2(pdfs) returns the second ID string of the PDF, if any, in
* hexadecimal string format. */
char *cpdf_id2(int);
/* cpdf_hasAcroForm returns true if the document has an AcroForm */
int cpdf_hasAcroForm(int);
/* To return the subformats of a PDF (if any), call
* cpdf_startGetSubformats(pdf) to return their number. Then pass the numbers
* 0..n - 1 to cpdf_getSubformat to return the strings. Call
* cpdf_endGetSubformats() to clean up. */
int cpdf_startGetSubformats(int);
char *cpdf_getSubformat(int);
void cpdf_endGetSubformats(void);
/* cpdf_getVersion(pdf) returns the minor version number of a document. */
@ -187,7 +196,7 @@ 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_pageInfoJSON(pdf, retlen) returns JSON data for the page
/* cpdf_pageInfoJSON(pdf, size) returns JSON data for the page
information, and fills in the return length. */
void *cpdf_pageInfoJSON(int, int *);
@ -269,7 +278,7 @@ void cpdf_displayDocTitle(int, int);
/* cpdf_getDisplayDocTitle(pdf) gets the display document title flag. */
int cpdf_getDisplayDocTitle(int);
/* cpdf_nonFullScreenPageMode(pdf, page mode) sets the non full screen page
/* cpdf_nonFullScreenPageMode(pdf, pagemode) sets the non full screen page
* mode. */
void cpdf_nonFullScreenPageMode(int, enum cpdf_pageMode);
@ -297,7 +306,7 @@ void cpdf_setMetadataFromFile(int, const char[]);
void cpdf_setMetadataFromByteArray(int, void *, int);
/*
* cpdf_getMetadata(pdf, &length) returns the XMP metadata and fills in
* cpdf_getMetadata(pdf, length) returns the XMP metadata and fills in
* length.
*/
void *cpdf_getMetadata(int, int *);
@ -373,7 +382,7 @@ int cpdf_getPageLabelOffset(int);
int cpdf_getPageLabelRange(int);
void cpdf_endGetPageLabels();
/* cpdf_compositionJSON(filesize, pdf, size returns the composition data in
* JSON format. */
/* cpdf_compositionJSON(filesize, pdf, size) returns the composition data in
* JSON format, filling in the return length. */
void *cpdf_compositionJSON(int, int, int *);

View File

@ -45,7 +45,7 @@ char *cpdf_getAttachmentName(int);
int cpdf_getAttachmentPage(int);
/*
* cpdf_getAttachmentData(serial number, &length) returns a pointer to the
* cpdf_getAttachmentData(serial number, length) returns a pointer to the
* data, and its length.
*/
void *cpdf_getAttachmentData(int, int *);

View File

@ -15,7 +15,7 @@ char *cpdf_getFontType(int);
char *cpdf_getFontEncoding(int);
void cpdf_endGetFontInfo(void);
/* cpdf_fontsJSON(pdf, retlen) returns JSON data for the font list, and fills
/* cpdf_fontsJSON(pdf, size) returns JSON data for the font list, and fills
* in the return length. */
void *cpdf_fontsJSON(int, int *);

View File

@ -1,5 +1,7 @@
/* CHAPTER 15. PDF and JSON */
/* Set the JSON output format. If true, the newer UTF8 format is used. Default:
* false. */
void cpdf_JSONUTF8(int);
/* cpdf_outputJSON(filename, parse_content, no_stream_data, pdf) outputs a PDF
@ -8,7 +10,7 @@ void cpdf_JSONUTF8(int);
* */
void cpdf_outputJSON(const char[], int, int, int, int);
/* cpdf_outputJSONMemory(parse_content, no_stream_data, pdf, &length) is like
/* cpdf_outputJSONMemory(parse_content, no_stream_data, pdf, size) is like
* outputJSON, but it writes to a buffer in memory. The length is filled in. */
void *cpdf_outputJSONMemory(int, int, int, int, int *);

View File

@ -15,16 +15,33 @@ int cpdf_blankDocumentPaper(enum cpdf_papersize, int);
/* cpdf_textToPDF(w, h, font, fontsize, filename) typesets a UTF8 text file
* ragged right on a page of size w * h in points in the given font and font
* size. */
int cpdf_textToPDF(double, double, int, double, const char[]);
int cpdf_textToPDF(double, double, const char[], double, const char[]);
/* cpdf_textToPDF(papersize font, fontsize, filename) typesets a UTF8 text file
/* cpdf_textToPDFMemory(w, h, font, fontsize, data, length) typesets a UTF8 text
* file ragged right on a page of size w * h in points in the given font and
* font size. */
int cpdf_textToPDFMemory(double, double, const char[], double, void *, int);
/* cpdf_textToPDF(papersize, font, fontsize, filename) typesets a UTF8 text file
* ragged right on a page of the given size in the given font and font size. */
int cpdf_textToPDFPaper(int, int, double, const char[]);
int cpdf_textToPDFPaper(int, const char[], double, const char[]);
/* cpdf_fromPNG(filename) builds a PDF from a 24-bit non-interlaced
* non-transparent PNG. */
/* cpdf_textToPDFMemory(papersize font, fontsize, data, length) typesets a UTF8
* text file ragged right on a page of the given size in the given font and
* font size. */
int cpdf_textToPDFPaperMemory(int, const char[], double, void *, int);
/* cpdf_fromPNG(filename) builds a PDF from a non-interlaced non-transparent
* PNG. */
int cpdf_fromPNG(const char[]);
/* cpdf_fromJPEG(filename) builds a PDF from a JPEG/ */
/* cpdf_fromPNGMemory(data, length) builds a PDF from a non-interlaced
* non-transparent PNG. */
int cpdf_fromPNGMemory(void *, int);
/* cpdf_fromJPEG(filename) builds a PDF from a JPEG. */
int cpdf_fromJPEG(const char[]);
/* cpdf_fromJPEGMemory(data, length) builds a PDF from a JPEG. */
int cpdf_fromJPEGMemory(void *, int);

View File

@ -160,10 +160,18 @@ void cpdf_drawUse(char *);
* under the given name. */
void cpdf_drawJPEG(char *, char *);
/* cpdf_drawPNG(name, filename) loads a 24 bit non-interlaced non-transparent
/* cpdf_drawJPEGMemory(name, data, length) loads a JPEG from the given file,
* storing it under the given name. */
void cpdf_drawJPEGMemory(char *, void *, int);
/* cpdf_drawPNG(name, filename) loads a non-interlaced non-transparent
* PNG from the given file, storing it under the given name. */
void cpdf_drawPNG(char *, char *);
/* cpdf_drawPNG(name, data, length) loads a non-interlaced non-transparent
* PNG from the given file, storing it under the given name. */
void cpdf_drawPNGMemory(char *, void *, int);
/* cpdf_drawImage(name) draws a stored image. To draw at the expected size, it
* is required to scale the Current Transformation Matrix by the width and
* height of the image. */