diff --git a/cpdfmanual.pdf b/cpdfmanual.pdf index 0635b93..0f96da5 100644 Binary files a/cpdfmanual.pdf and b/cpdfmanual.pdf differ diff --git a/cpdfmanual.tex b/cpdfmanual.tex index bca1609..b2e4a96 100644 --- a/cpdfmanual.tex +++ b/cpdfmanual.tex @@ -3375,7 +3375,7 @@ A basic text to PDF convertor is included in \texttt{cpdf}. It takes a UTF8 text \clearpage \section*{C Interface} \begin{small}\tt -\lstinputlisting{splits/c17} +\lstinputlisting{splits/c18} \end{small} \end{cpdflib} @@ -3636,7 +3636,7 @@ The \texttt{-remove-clipping} operation removes any clipping paths on given page \clearpage \section*{C Interface} \begin{small}\tt -\lstinputlisting{splits/c18} +\lstinputlisting{splits/c19} \end{small} \end{cpdflib} diff --git a/splits/c02.tex b/splits/c02.tex index 037859b..edf329c 100644 --- a/splits/c02.tex +++ b/splits/c02.tex @@ -29,13 +29,6 @@ int cpdf_fromMemory(void *, int, const char[]); */ int cpdf_fromMemoryLazy(void *, int, const char[]); -/* - * cpdf_blankDocument(width, height, num_pages) creates a blank document with - * pages of the given width (in points), height (in points), and number of - * pages. - */ -int cpdf_blankDocument(double, double, int); - /* Standard page sizes. */ enum cpdf_papersize { cpdf_a0portrait, /* A0 portrait */ @@ -56,12 +49,6 @@ enum cpdf_papersize { cpdf_uslegallandscape /* US Legal landscape */ }; -/* - * cpdf_blankDocumentPaper(papersize, num_pages) makes a blank document given - * a page size and number of pages. - */ -int cpdf_blankDocumentPaper(enum cpdf_papersize, int); - /* Remove a PDF from memory, given its number. */ void cpdf_deletePdf(int); @@ -233,7 +220,7 @@ int cpdf_pagesFast(const char[], const char[]); void cpdf_toFile(int, const char[], int, int); /* - * cpdf_toFile (pdf, filename, linearize, make_id, preserve_objstm, + * cpdf_toFileExt (pdf, filename, linearize, make_id, preserve_objstm, * generate_objstm, compress_objstm) writes the file to a given filename. If * make_id is true, it will be given a new ID. If preserve_objstm is true, * existing object streams will be preserved. If generate_objstm is true, @@ -245,9 +232,8 @@ void cpdf_toFile(int, const char[], int, int); void cpdf_toFileExt(int, const char[], int, int, int, int, int); /* - * Given a buffer of the correct size, cpdf_toFileMemory (pdf, linearize, - * make_id, &length) writes it and returns the buffer. The buffer length is - * filled in &length. + * cpdf_toFileMemory (pdf, linearize, make_id, &length) writes a PDF file it + * and returns the buffer. The buffer length is filled in &length. */ void *cpdf_toMemory(int, int, int, int *); diff --git a/splits/c04.tex b/splits/c04.tex index 407db9f..4e48d87 100644 --- a/splits/c04.tex +++ b/splits/c04.tex @@ -8,7 +8,7 @@ void cpdf_scalePages(int, int, double, double); /* - * cpdf_scaleToFit(pdf, range, width height, scale) scales the content to fit + * 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) */ diff --git a/splits/c06.tex b/splits/c06.tex index 8790911..e871de5 100644 --- a/splits/c06.tex +++ b/splits/c06.tex @@ -7,7 +7,7 @@ void cpdf_compress(int); /* - * cpdf_uncompress(pdf) uncompresses any streams in the given PDF, so long as + * cpdf_decompress(pdf) decompresses any streams in the given PDF, so long as * the compression method is supported. */ void cpdf_decompress(int); diff --git a/splits/c07.tex b/splits/c07.tex index a21159e..8ab01a7 100644 --- a/splits/c07.tex +++ b/splits/c07.tex @@ -68,3 +68,16 @@ void cpdf_setBookmarkText(int, const char[]); */ void cpdf_endSetBookmarkInfo(int); +/* cpdf_getBookmarksJSON(pdf, length) returns the bookmark data and sets the + * length. */ +void *cpdf_getBookmarksJSON(int, int *); + +/* cpdf_setBookmarksJSON(pdf, data, datalength) sets the bookmarks from JSON + * bookmark data. */ +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); + diff --git a/splits/c10.tex b/splits/c10.tex index 4daa0b9..1db9f30 100644 --- a/splits/c10.tex +++ b/splits/c10.tex @@ -1,5 +1,14 @@ /* CHAPTER 9. Multipage facilities */ +/* cpdf_impose(pdf, x, y, fit, columns, rtl, btt, center, margin, spacing, + * linewidth) imposes a PDF. There are two modes: imposing x * y, or imposing + * to fit a page of size x * y. This is controlled by fit. Columns imposes by + * columns rather than rows. rtl is right-to-left, btt bottom-to-top. Center is + * unused for now. Margin is the margin around the output, spacing the spacing + * between imposed inputs. */ +void cpdf_impose(int, double, double, int, int, int, int, int, double, double, + double); + /* * 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 diff --git a/splits/c11.tex b/splits/c11.tex index 831f9f8..365551b 100644 --- a/splits/c11.tex +++ b/splits/c11.tex @@ -1,4 +1,6 @@ /* CHAPTER 10. Annotations */ -/* Not in the library version */ +/* Return the annotations from a PDF in JSON format, returning also its length. + */ +void *cpdf_annotationsJSON(int, int *); diff --git a/splits/c12.tex b/splits/c12.tex index 8126a22..37013f8 100644 --- a/splits/c12.tex +++ b/splits/c12.tex @@ -147,7 +147,7 @@ int cpdf_getPageRotation(int, int); int cpdf_hasBox(int, int, const char[]); /* - * These functions get a box given the document, page range, min x, max x, + * These functions get a box given the document, page number, min x, max x, * min y, max y in points. Only succeeds if such a box exists, as checked by * cpdf_hasBox. */ @@ -292,7 +292,21 @@ 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. + * and start value (note not a range). Call cpdf_endGetPageLabels to clean up. + * + * 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 */ int cpdf_startGetPageLabels(int); enum cpdf_pageLabelStyle cpdf_getPageLabelStyle(int); diff --git a/splits/c15.tex b/splits/c15.tex index c54383d..eacffc4 100644 --- a/splits/c15.tex +++ b/splits/c15.tex @@ -21,7 +21,7 @@ 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. + * new font is stored under its font name. */ void cpdf_copyFont(int, int, int, int, const char[]); diff --git a/splits/c16.tex b/splits/c16.tex index 747ad8e..9fb3550 100644 --- a/splits/c16.tex +++ b/splits/c16.tex @@ -4,5 +4,15 @@ * 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); +void cpdf_outputJSON(const char[], int, int, int, int); + +/* cpdf_outputJSONMemory(parse_content, no_stream_data, pdf, &length) is like + * outputJSON, but it write to a buffer in memory. The length is filled in. */ +void *cpdf_outputJSONMemory(int, int, int, int, int *); + +/* Load a PDF from a JSON file given its filename */ +int cpdf_fromJSON(const char[]); + +/* Load a PDF from a JSON file in memory, given the buffer and its length */ +int cpdf_fromJSONMemory(void *, int); diff --git a/splits/c18.tex b/splits/c18.tex index e5e599d..12673af 100644 --- a/splits/c18.tex +++ b/splits/c18.tex @@ -1,54 +1,23 @@ -/* CHAPTER 17. Miscellaneous */ +/* CHAPTER 17. Creating New PDFs */ + +/* cpdf_blankDocument(width, height, num_pages) creates a blank document with + * pages of the given width (in points), height (in points), and number of + * pages. + */ +int cpdf_blankDocument(double, double, int); /* - * cpdf_draft(pdf, range, boxes) removes images on the given pages, replacing - * them with crossed boxes if 'boxes' is true + * cpdf_blankDocumentPaper(papersize, num_pages) makes a blank document given + * a page size and number of pages. */ -void cpdf_draft(int, int, int); +int cpdf_blankDocumentPaper(enum cpdf_papersize, int); -/* - * cpdf_removeAllText(pdf, range) removes all text from the given pages in a - * given document. - */ -void cpdf_removeAllText(int, 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[]); -/* cpdf_blackText(pdf, range) blackens all text on the given pages. */ -void cpdf_blackText(int, int); - -/* cpdf_blackLines(pdf, range) blackens all lines on the given pages. */ -void cpdf_blackLines(int, int); - -/* cpdf_blackFills(pdf, range) blackens all fills on the given pages. */ -void cpdf_blackFills(int, int); - -/* - * 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); - -/* cpdf_copyId(from, to) copies the /ID from one document to another. */ -void cpdf_copyId(int, int); - -/* cpdf_removeId(pdf) removes a document's /ID. */ -void cpdf_removeId(int); - -/* cpdf_setVersion(pdf, version) sets the minor version number of a document. */ -void cpdf_setVersion(int, int); - -/* cpdf_setFullVersion(pdf, major_version, minor_version) sets the full version - * number of a document. */ -void cpdf_setFullVersion(int, int, int); - -/* - * 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); +/* 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[]); diff --git a/splits/c19.tex b/splits/c19.tex index 41356ab..ac246d2 100644 --- a/splits/c19.tex +++ b/splits/c19.tex @@ -1,3 +1,74 @@ +/* CHAPTER 18. 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); + +/* + * cpdf_removeAllText(pdf, range) removes all text from the given pages in a + * given document. + */ +void cpdf_removeAllText(int, int); + +/* cpdf_blackText(pdf, range) blackens all text on the given pages. */ +void cpdf_blackText(int, int); + +/* cpdf_blackLines(pdf, range) blackens all lines on the given pages. */ +void cpdf_blackLines(int, int); + +/* cpdf_blackFills(pdf, range) blackens all fills on the given pages. */ +void cpdf_blackFills(int, int); + +/* + * 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); + +/* cpdf_copyId(from, to) copies the /ID from one document to another. */ +void cpdf_copyId(int, int); + +/* cpdf_removeId(pdf) removes a document's /ID. */ +void cpdf_removeId(int); + +/* cpdf_setVersion(pdf, version) sets the minor version number of a document. */ +void cpdf_setVersion(int, int); + +/* cpdf_setFullVersion(pdf, major_version, minor_version) sets the full version + * number of a document. */ +void cpdf_setFullVersion(int, int, int); + +/* + * cpdf_removeDictEntry(pdf, key) removes any dictionary entry with the given + * key anywhere in the document. + */ +void cpdf_removeDictEntry(int, const char[]); + +/* cpdf_removeDictEntrySearch(pdf, key, seachterm) removes any dictionary entry + * with the given key whose value matches the given search term. */ +void cpdf_removeDictEntrySearch(int, const char[], const char[]); + +/* cpdf_replaceDictEntry(pdf, key, newvalue) replaces the value associated with + * the given key */ +void cpdf_replaceDictEntry(int, const char[], const char[]); + +/* cpdf_replaceDictEntry(pdf, key, newvalue, searchterm) replaces the value + * associated with the given key if the existing value matches the search term. + */ +void cpdf_replaceDictEntrySearch(int, const char[], const char[], const char[]); + +/* cpdf_getDictEntries(pdf, key, length) returns a JSON array containing any + * and all values associated with the given key, and fills in its length. */ +void *cpdf_getDictEntries(int, const char[], int *retlen); + +/* + * cpdf_removeClipping(pdf, range) removes all clipping from pages in the + * given range. + */ +void cpdf_removeClipping(int, int); + /* CHAPTER X. Internal or undocumented. */ /* Internal. Used for demo versions of the commercial version of cpdflib. */ diff --git a/splitwrapper b/splitwrapper index d94a147..b1c921c 100755 --- a/splitwrapper +++ b/splitwrapper @@ -1,5 +1,5 @@ #!/bin/bash -csplit -k -f splits/c cpdflibwrapper.h '/CHAPTER/' {18} +csplit -k -f splits/c ../cpdflib-source/cpdflibwrapper.h '/CHAPTER/' {18} mv splits/c00 splits/c00.tex mv splits/c01 splits/c01.tex mv splits/c02 splits/c02.tex