├── cpdf.install ├── .gitignore ├── compressor ├── README.md ├── run ├── Makefile └── compressor.ml ├── docsplits ├── javascriptsplits │ ├── c05.tex │ ├── c08.tex │ ├── c19.tex │ ├── cm1.tex │ ├── c11.tex │ ├── c06.tex │ ├── c01.tex │ ├── c17.tex │ ├── c00.tex │ ├── c16.tex │ ├── c03.tex │ ├── c18.tex │ └── c10.tex ├── pysplits │ ├── c08.tex │ ├── c05.tex │ ├── c11.tex │ ├── c06.tex │ ├── c15.tex │ ├── c17.tex │ ├── c14.tex │ ├── c00.tex │ ├── c07.tex │ ├── c16.tex │ ├── c13.tex │ ├── c03.tex │ ├── c18.tex │ ├── c10.tex │ └── c20.tex ├── dotnetsplits │ ├── c05.tex │ ├── c08.tex │ ├── c11.tex │ ├── c06.tex │ ├── c00.tex │ ├── c16.tex │ ├── c18.tex │ ├── c17.tex │ ├── c14.tex │ ├── c15.tex │ ├── c03.tex │ ├── cm1.tex │ ├── c01.tex │ ├── c10.tex │ ├── c13.tex │ ├── c19.tex │ └── c07.tex ├── javasplits │ ├── c08.tex │ ├── c05.tex │ ├── c11.tex │ ├── c06.tex │ ├── c01.tex │ ├── c17.tex │ ├── cm1.tex │ ├── c16.tex │ ├── c14.tex │ ├── c18.tex │ ├── c15.tex │ ├── c03.tex │ └── c10.tex ├── splits │ ├── c08.tex │ ├── c05.tex │ ├── c00.tex │ ├── c06.tex │ ├── c11.tex │ ├── c16.tex │ ├── c17.tex │ ├── c03.tex │ ├── c15.tex │ ├── c14.tex │ ├── c13.tex │ ├── c01.tex │ ├── c18.tex │ └── c10.tex ├── splitwrapper └── splitjs ├── html_manual ├── javascriptsplits │ ├── c05.tex │ ├── c08.tex │ ├── cm1.tex │ ├── c11.tex │ ├── c06.tex │ ├── c01.tex │ ├── c17.tex │ ├── c00.tex │ ├── c16.tex │ ├── c03.tex │ ├── c18.tex │ └── c10.tex ├── dotnetsplits │ ├── c05.tex │ ├── c08.tex │ ├── c11.tex │ ├── c06.tex │ ├── c00.tex │ ├── c16.tex │ ├── c18.tex │ ├── c17.tex │ ├── c14.tex │ ├── c15.tex │ ├── c03.tex │ ├── cm1.tex │ ├── c01.tex │ ├── c10.tex │ ├── c13.tex │ ├── c19.tex │ └── c07.tex ├── pysplits │ ├── c08.tex │ ├── c05.tex │ ├── c11.tex │ ├── c14.tex │ ├── c15.tex │ ├── c06.tex │ ├── c17.tex │ ├── c00.tex │ ├── c16.tex │ ├── c18.tex │ ├── c07.tex │ ├── c13.tex │ ├── c03.tex │ ├── c10.tex │ └── c19.tex ├── javasplits │ ├── c08.tex │ ├── c05.tex │ ├── c11.tex │ ├── c06.tex │ ├── c01.tex │ ├── c17.tex │ ├── cm1.tex │ ├── c16.tex │ ├── c14.tex │ ├── c18.tex │ ├── c15.tex │ ├── c03.tex │ └── c10.tex ├── splits │ ├── c08.tex │ ├── c05.tex │ ├── c11.tex │ ├── c00.tex │ ├── c06.tex │ ├── c16.tex │ ├── c14.tex │ ├── c18.tex │ ├── c17.tex │ ├── c15.tex │ ├── c03.tex │ ├── c01.tex │ ├── c10.tex │ └── c13.tex ├── clean ├── README.txt └── go ├── logo.pdf ├── hello.pdf ├── mkinstall ├── cpdfmanual.pdf ├── cpdfform.ml ├── manualimages ├── bez.pdf ├── h1.pdf ├── png.pdf ├── pop.pdf ├── clip.pdf ├── dash.pdf ├── fill.pdf ├── fonts.pdf ├── line.pdf ├── lines.pdf ├── matrix.pdf ├── para.pdf ├── paras.pdf ├── sheet.png ├── stext.pdf ├── text.pdf ├── trans.pdf ├── xobj.pdf ├── capjoins.pdf ├── colfill.pdf ├── textclip.pdf └── fontparams.pdf ├── old └── README.md ├── cpdfform.mli ├── cpdfcommandrun.ml ├── cpdfspot.mli ├── cpdfcolours.mli ├── doublemkinstall ├── cpdfdebug.mli ├── cpdfxobject.mli ├── META ├── cpdfjpeg2000.mli ├── cpdfdraft.mli ├── cpdfportfolio.mli ├── mkman ├── cpdferror.ml ├── cpdfpagelabels.mli ├── cpdfjs.mli ├── fixcpdfmanual ├── cpdferror.mli ├── cpdftexttopdf.mli ├── cpdfremovetext.mli ├── cpdfextracttext.mli ├── cpdfcreate.mli ├── cpdfjpeg.mli ├── cpdftoc.mli ├── cpdfpresent.mli ├── cpdfchop.mli ├── cpdfprinttree.mli ├── cpdfcommand.mli ├── cpdfpad.mli ├── cpdfspot.ml ├── cpdfpng.mli ├── cpdfcomposition.mli ├── cpdfsqueeze.mli ├── cpdfocg.mli ├── cpdf.opam ├── cpdfutil.mli ├── cpdfstrftime.mli ├── cpdfcreate.ml ├── cpdfdebug.ml ├── cpdfcoord.mli ├── cpdfimpose.mli ├── cpdfannot.mli ├── cpdfunicodedata.mli ├── cpdfprinttree.ml ├── cpdfposition.mli ├── cpdftruetype.mli ├── cpdfattach.mli ├── cpdftype.mli ├── cpdfjson.mli ├── cpdffont.mli ├── cpdfembed.mli ├── cpdfua.mli ├── cpdfshape.mli ├── cpdfjpeg2000.ml ├── cpdftweak.mli ├── Makefile ├── cpdfbookmarks.mli ├── cpdfpagelabels.ml ├── cpdfimage.mli ├── cpdfutil.ml ├── cpdfportfolio.ml ├── cpdfpagespec.mli ├── cpdfpresent.ml ├── cpdfextracttext.ml ├── cpdfjs.ml └── cpdfaddtext.mli /cpdf.install: -------------------------------------------------------------------------------- 1 | bin: ["cpdf"] 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .texpadtmp 3 | -------------------------------------------------------------------------------- /compressor/README.md: -------------------------------------------------------------------------------- 1 | Compresses source files for unicode data. 2 | -------------------------------------------------------------------------------- /docsplits/javascriptsplits/c05.tex: -------------------------------------------------------------------------------- 1 | // CHAPTER 4. Encryption 2 | 3 | -------------------------------------------------------------------------------- /docsplits/pysplits/c08.tex: -------------------------------------------------------------------------------- 1 | # Not included in the library version 2 | -------------------------------------------------------------------------------- /docsplits/javascriptsplits/c08.tex: -------------------------------------------------------------------------------- 1 | // CHAPTER 7. Presentations 2 | 3 | -------------------------------------------------------------------------------- /docsplits/javascriptsplits/c19.tex: -------------------------------------------------------------------------------- 1 | //CHAPTER 18. Drawing on PDFs 2 | 3 | -------------------------------------------------------------------------------- /html_manual/javascriptsplits/c05.tex: -------------------------------------------------------------------------------- 1 | // CHAPTER 4. Encryption 2 | 3 | -------------------------------------------------------------------------------- /html_manual/javascriptsplits/c08.tex: -------------------------------------------------------------------------------- 1 | // CHAPTER 7. Presentations 2 | 3 | -------------------------------------------------------------------------------- /logo.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwhitington/cpdf-source/HEAD/logo.pdf -------------------------------------------------------------------------------- /compressor/run: -------------------------------------------------------------------------------- 1 | ./compressor ../cpdfunicodedata.source.ml ../cpdfunicodedata.ml 2 | -------------------------------------------------------------------------------- /docsplits/pysplits/c05.tex: -------------------------------------------------------------------------------- 1 | # Encryption covered under Chapter 1 in pycpdflib 2 | -------------------------------------------------------------------------------- /hello.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwhitington/cpdf-source/HEAD/hello.pdf -------------------------------------------------------------------------------- /mkinstall: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | make clean; make; ocamlfind remove cpdf; make install 3 | -------------------------------------------------------------------------------- /cpdfmanual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwhitington/cpdf-source/HEAD/cpdfmanual.pdf -------------------------------------------------------------------------------- /docsplits/dotnetsplits/c05.tex: -------------------------------------------------------------------------------- 1 | CHAPTER 4. Encryption 2 | 3 | Encryption covered in Chapter 1. 4 | -------------------------------------------------------------------------------- /cpdfform.ml: -------------------------------------------------------------------------------- 1 | (** Forms *) 2 | let extract_form pdf = () 3 | 4 | let replace_form filename pdf = () 5 | -------------------------------------------------------------------------------- /html_manual/dotnetsplits/c05.tex: -------------------------------------------------------------------------------- 1 | CHAPTER 4. Encryption 2 | 3 | Encryption covered in Chapter 1. 4 | -------------------------------------------------------------------------------- /manualimages/bez.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwhitington/cpdf-source/HEAD/manualimages/bez.pdf -------------------------------------------------------------------------------- /manualimages/h1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwhitington/cpdf-source/HEAD/manualimages/h1.pdf -------------------------------------------------------------------------------- /manualimages/png.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwhitington/cpdf-source/HEAD/manualimages/png.pdf -------------------------------------------------------------------------------- /manualimages/pop.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwhitington/cpdf-source/HEAD/manualimages/pop.pdf -------------------------------------------------------------------------------- /old/README.md: -------------------------------------------------------------------------------- 1 | An old, unfinished module from CPDF's very early life. To be resuscitated one day? 2 | -------------------------------------------------------------------------------- /html_manual/pysplits/c08.tex: -------------------------------------------------------------------------------- 1 | # CHAPTER 7. Presentations 2 | 3 | # Not included in the library version 4 | -------------------------------------------------------------------------------- /manualimages/clip.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwhitington/cpdf-source/HEAD/manualimages/clip.pdf -------------------------------------------------------------------------------- /manualimages/dash.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwhitington/cpdf-source/HEAD/manualimages/dash.pdf -------------------------------------------------------------------------------- /manualimages/fill.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwhitington/cpdf-source/HEAD/manualimages/fill.pdf -------------------------------------------------------------------------------- /manualimages/fonts.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwhitington/cpdf-source/HEAD/manualimages/fonts.pdf -------------------------------------------------------------------------------- /manualimages/line.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwhitington/cpdf-source/HEAD/manualimages/line.pdf -------------------------------------------------------------------------------- /manualimages/lines.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwhitington/cpdf-source/HEAD/manualimages/lines.pdf -------------------------------------------------------------------------------- /manualimages/matrix.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwhitington/cpdf-source/HEAD/manualimages/matrix.pdf -------------------------------------------------------------------------------- /manualimages/para.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwhitington/cpdf-source/HEAD/manualimages/para.pdf -------------------------------------------------------------------------------- /manualimages/paras.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwhitington/cpdf-source/HEAD/manualimages/paras.pdf -------------------------------------------------------------------------------- /manualimages/sheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwhitington/cpdf-source/HEAD/manualimages/sheet.png -------------------------------------------------------------------------------- /manualimages/stext.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwhitington/cpdf-source/HEAD/manualimages/stext.pdf -------------------------------------------------------------------------------- /manualimages/text.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwhitington/cpdf-source/HEAD/manualimages/text.pdf -------------------------------------------------------------------------------- /manualimages/trans.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwhitington/cpdf-source/HEAD/manualimages/trans.pdf -------------------------------------------------------------------------------- /manualimages/xobj.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwhitington/cpdf-source/HEAD/manualimages/xobj.pdf -------------------------------------------------------------------------------- /docsplits/dotnetsplits/c08.tex: -------------------------------------------------------------------------------- 1 | CHAPTER 7. Presentations 2 | 3 | Not included in the library version of cpdf. 4 | -------------------------------------------------------------------------------- /docsplits/javasplits/c08.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 7. Presentations */ 2 | /* Not included in the library version. */ 3 | -------------------------------------------------------------------------------- /html_manual/javasplits/c08.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 7. Presentations */ 2 | /* Not included in the library version. */ 3 | -------------------------------------------------------------------------------- /manualimages/capjoins.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwhitington/cpdf-source/HEAD/manualimages/capjoins.pdf -------------------------------------------------------------------------------- /manualimages/colfill.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwhitington/cpdf-source/HEAD/manualimages/colfill.pdf -------------------------------------------------------------------------------- /manualimages/textclip.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwhitington/cpdf-source/HEAD/manualimages/textclip.pdf -------------------------------------------------------------------------------- /cpdfform.mli: -------------------------------------------------------------------------------- 1 | (** Forms *) 2 | val extract_form : Pdf.t -> unit 3 | 4 | val replace_form : string -> Pdf.t -> unit 5 | -------------------------------------------------------------------------------- /docsplits/javasplits/c05.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 4. Encryption */ 2 | /* Encryption covered under Chapter 1 in cpdflib. */ 3 | -------------------------------------------------------------------------------- /docsplits/splits/c08.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 7. Presentations */ 2 | 3 | /* Not included in the library version. */ 4 | 5 | -------------------------------------------------------------------------------- /html_manual/dotnetsplits/c08.tex: -------------------------------------------------------------------------------- 1 | CHAPTER 7. Presentations 2 | 3 | Not included in the library version of cpdf. 4 | -------------------------------------------------------------------------------- /html_manual/pysplits/c05.tex: -------------------------------------------------------------------------------- 1 | # CHAPTER 4. Encryption 2 | 3 | # Encryption covered under Chapter 1 in pycpdflib 4 | -------------------------------------------------------------------------------- /html_manual/splits/c08.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 7. Presentations */ 2 | 3 | /* Not included in the library version. */ 4 | 5 | -------------------------------------------------------------------------------- /manualimages/fontparams.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/johnwhitington/cpdf-source/HEAD/manualimages/fontparams.pdf -------------------------------------------------------------------------------- /docsplits/splits/c05.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 4. Encryption */ 2 | 3 | /* Encryption covered under Chapter 1 in cpdflib. */ 4 | 5 | -------------------------------------------------------------------------------- /html_manual/javasplits/c05.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 4. Encryption */ 2 | /* Encryption covered under Chapter 1 in cpdflib. */ 3 | -------------------------------------------------------------------------------- /html_manual/splits/c05.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 4. Encryption */ 2 | 3 | /* Encryption covered under Chapter 1 in cpdflib. */ 4 | 5 | -------------------------------------------------------------------------------- /cpdfcommandrun.ml: -------------------------------------------------------------------------------- 1 | let _ = 2 | match Filename.basename Sys.argv.(0) with 3 | "cpdf.top" -> () 4 | | _ -> Cpdfcommand.go () 5 | -------------------------------------------------------------------------------- /cpdfspot.mli: -------------------------------------------------------------------------------- 1 | (** Spot colours *) 2 | 3 | (** List spot colours to Standard Output. *) 4 | val list_spot_colours : Pdf.t -> unit 5 | -------------------------------------------------------------------------------- /cpdfcolours.mli: -------------------------------------------------------------------------------- 1 | (** Standard CSS Colours *) 2 | 3 | (** Standard CSS Colours, names in lowercase. *) 4 | val colours : (string * int) list 5 | -------------------------------------------------------------------------------- /html_manual/pysplits/c11.tex: -------------------------------------------------------------------------------- 1 | # CHAPTER 10. Annotations 2 | 3 | def annotationsJSON(pdf): 4 | """Get the annotations in JSON format.""" 5 | -------------------------------------------------------------------------------- /docsplits/javascriptsplits/cm1.tex: -------------------------------------------------------------------------------- 1 | cpdf.js: JavaScript interface to the cpdf PDF tools 2 | =================================================== 3 | -------------------------------------------------------------------------------- /doublemkinstall: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd ../camlpdf 3 | ./mkinstall 4 | cd ../cpdf-source 5 | make clean; make; ocamlfind remove cpdf; make install 6 | -------------------------------------------------------------------------------- /html_manual/javascriptsplits/cm1.tex: -------------------------------------------------------------------------------- 1 | cpdf.js: JavaScript interface to the cpdf PDF tools 2 | =================================================== 3 | -------------------------------------------------------------------------------- /cpdfdebug.mli: -------------------------------------------------------------------------------- 1 | (** Debugging tools *) 2 | 3 | (** Print all the objects from a given PDF to Standard Output. *) 4 | val print_pdf_objs : Pdf.t -> unit 5 | -------------------------------------------------------------------------------- /docsplits/dotnetsplits/c11.tex: -------------------------------------------------------------------------------- 1 | CHAPTER 10. Annotations 2 | 3 | Cpdf.annotationsJSON(Cpdf.Pdf) 4 | 5 | Returns the annotations from a PDF in JSON format 6 | -------------------------------------------------------------------------------- /cpdfxobject.mli: -------------------------------------------------------------------------------- 1 | (** XObjects *) 2 | 3 | (** Stamp a PDF as an xobject in another. *) 4 | val stamp_as_xobject : Pdf.t -> int list -> Pdf.t -> Pdf.t * string 5 | -------------------------------------------------------------------------------- /html_manual/dotnetsplits/c11.tex: -------------------------------------------------------------------------------- 1 | CHAPTER 10. Annotations 2 | 3 | Cpdf.annotationsJSON(Cpdf.Pdf) 4 | 5 | Returns the annotations from a PDF in JSON format 6 | -------------------------------------------------------------------------------- /META: -------------------------------------------------------------------------------- 1 | name="cpdf" 2 | description="PDF commmand line tools" 3 | version="2.8.1" 4 | requires="camlpdf" 5 | archive(byte)="cpdf.cma" 6 | archive(native)="cpdf.cmxa" 7 | -------------------------------------------------------------------------------- /cpdfjpeg2000.mli: -------------------------------------------------------------------------------- 1 | (** JPEG2000 Utilities *) 2 | 3 | (** Return the width and height of a JPEG2000 stream *) 4 | val jpeg2000_dimensions : Pdfio.bytes -> int * int 5 | -------------------------------------------------------------------------------- /cpdfdraft.mli: -------------------------------------------------------------------------------- 1 | (** Remove images *) 2 | 3 | (** Remove images from a PDF, optionally adding crossed boxes. *) 4 | val draft : string option -> bool -> int list -> Pdf.t -> Pdf.t 5 | -------------------------------------------------------------------------------- /cpdfportfolio.mli: -------------------------------------------------------------------------------- 1 | type entry = 2 | {filename : string; 3 | relationship : string option; 4 | description : string option} 5 | 6 | val portfolio : Pdf.t -> entry list -> unit 7 | -------------------------------------------------------------------------------- /mkman: -------------------------------------------------------------------------------- 1 | #groff -m mandoc -Thtml ./cpdf.1 > ~/Desktop/cpdf.html 2 | #pandoc --standalone --to html cpdf.1.md -o ~/Desktop/cpdf.html 3 | pandoc --standalone --to man cpdf.1.md -o cpdf.1 4 | -------------------------------------------------------------------------------- /cpdferror.ml: -------------------------------------------------------------------------------- 1 | (** Two exceptions recommended for use with the library. *) 2 | exception SoftError of string 3 | 4 | exception HardError of string 5 | 6 | let error s = raise (SoftError s) 7 | -------------------------------------------------------------------------------- /cpdfpagelabels.mli: -------------------------------------------------------------------------------- 1 | (** Page labels *) 2 | 3 | (** Add page labels. *) 4 | val add_page_labels : 5 | Pdf.t -> bool -> Pdfpagelabels.labelstyle -> string option -> int -> int list -> unit 6 | -------------------------------------------------------------------------------- /docsplits/javasplits/c11.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 10. Annotations */ 2 | 3 | /** Returns the annotations from a PDF in JSON format. */ 4 | public native byte[] annotationsJSON(Pdf pdf) throws CpdfError; 5 | -------------------------------------------------------------------------------- /html_manual/javasplits/c11.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 10. Annotations */ 2 | 3 | /** Returns the annotations from a PDF in JSON format. */ 4 | public native byte[] annotationsJSON(Pdf pdf) throws CpdfError; 5 | -------------------------------------------------------------------------------- /html_manual/splits/c11.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 10. Annotations */ 2 | 3 | /* Return the annotations from a PDF in JSON format, returning also its length. 4 | */ 5 | void *cpdf_annotationsJSON(int, int *); 6 | 7 | -------------------------------------------------------------------------------- /cpdfjs.mli: -------------------------------------------------------------------------------- 1 | (** JavaScript *) 2 | 3 | (** True if a document contains JavaScript *) 4 | val contains_javascript : Pdf.t -> bool 5 | 6 | (** Remove JavaScript from a document *) 7 | val remove_javascript : Pdf.t -> unit 8 | -------------------------------------------------------------------------------- /fixcpdfmanual: -------------------------------------------------------------------------------- 1 | #Set the language and document title 2 | cpdf cpdfmanual.pdf -set-language "en-US" AND -set-title "Coherent PDF Command Line Tools Manual" -also-set-xmp -o out.pdf 3 | cp out.pdf cpdfmanual.pdf 4 | rm out.pdf 5 | -------------------------------------------------------------------------------- /html_manual/clean: -------------------------------------------------------------------------------- 1 | rm -f *.html *.4ct *.4tc *.aux *.css *.dvi *.idv *.idx *.lg *.log *.tmp *.xref *.png *.toc *.out *.cut 2 | rm -rf manualimages 3 | rm -f Changes 4 | rm -rf ../camlpdf 5 | rm -f logo.pdf 6 | rm -f cpdfmanual.tex 7 | -------------------------------------------------------------------------------- /html_manual/README.txt: -------------------------------------------------------------------------------- 1 | The splits and pysplits and dotnetsplits are just copied from the parent 2 | directory - remember to update them. 3 | 4 | When we make command line / C / Python / .NET we upload it in a named 5 | subdirectory. 6 | -------------------------------------------------------------------------------- /docsplits/javascriptsplits/c11.tex: -------------------------------------------------------------------------------- 1 | // CHAPTER 10. Annotations 2 | 3 | /** Returns the annotations from a PDF in JSON format. 4 | @arg {pdf} pdf PDF document 5 | @return {Uint8Array} results as an array of bytes */ 6 | function annotationsJSON(pdf) {} 7 | 8 | -------------------------------------------------------------------------------- /html_manual/javascriptsplits/c11.tex: -------------------------------------------------------------------------------- 1 | // CHAPTER 10. Annotations 2 | 3 | /** Returns the annotations from a PDF in JSON format. 4 | @arg {pdf} pdf PDF document 5 | @return {Uint8Array} results as an array of bytes */ 6 | function annotationsJSON(pdf) {} 7 | 8 | -------------------------------------------------------------------------------- /cpdferror.mli: -------------------------------------------------------------------------------- 1 | (** Error handling *) 2 | 3 | (** Soft error in CPDF. *) 4 | exception SoftError of string 5 | 6 | (** Hard error in CPDF *) 7 | exception HardError of string 8 | 9 | (** Raise SoftError with the given string. *) 10 | val error : string -> 'a 11 | -------------------------------------------------------------------------------- /cpdftexttopdf.mli: -------------------------------------------------------------------------------- 1 | (** Text to PDF *) 2 | 3 | (** Typeset a text file as a PDF. *) 4 | val typeset : process_struct_tree:bool -> ?subformat:Cpdfua.subformat -> ?title:string -> papersize:Pdfpaper.t -> font:Cpdfembed.cpdffont -> fontsize:float -> Pdfio.bytes -> Pdf.t 5 | -------------------------------------------------------------------------------- /docsplits/splits/c00.tex: -------------------------------------------------------------------------------- 1 | /* 2 | * A C wrapper to cpdf PDF tools library. Free for non-commercial use. See 3 | * LICENSE for details. To purchase a license, please visit 4 | * http://www.coherentpdf.com/ 5 | * 6 | * Text arguments and results are in UTF8. 7 | */ 8 | 9 | -------------------------------------------------------------------------------- /html_manual/splits/c00.tex: -------------------------------------------------------------------------------- 1 | /* 2 | * A C wrapper to cpdf PDF tools library. Free for non-commercial use. See 3 | * LICENSE for details. To purchase a license, please visit 4 | * http://www.coherentpdf.com/ 5 | * 6 | * Text arguments and results are in UTF8. 7 | */ 8 | 9 | -------------------------------------------------------------------------------- /cpdfremovetext.mli: -------------------------------------------------------------------------------- 1 | (** Remove text from documents *) 2 | 3 | (** Remove text added by [Cpdfaddtext] from the given pages. *) 4 | val removetext : int list -> Pdf.t -> Pdf.t 5 | 6 | (** Remove all text from the given pages *) 7 | val remove_all_text : int list -> Pdf.t -> Pdf.t 8 | -------------------------------------------------------------------------------- /cpdfextracttext.mli: -------------------------------------------------------------------------------- 1 | (** Experimental text extractor *) 2 | 3 | (** Extract page text for a given page. *) 4 | val extract_page_text : float option -> Pdf.t -> 'a -> Pdfpage.t -> string 5 | 6 | (** Extract page text for given page range. *) 7 | val extract_text : float option -> Pdf.t -> int list -> string 8 | -------------------------------------------------------------------------------- /cpdfcreate.mli: -------------------------------------------------------------------------------- 1 | (** Making new documents *) 2 | 3 | (** Make a blank document given x and y page dimensions in points and a number of pages *) 4 | val blank_document : float -> float -> int -> Pdf.t 5 | 6 | (** The same, but give a Pdfpaper.t paper size. *) 7 | val blank_document_paper : Pdfpaper.t -> int -> Pdf.t 8 | -------------------------------------------------------------------------------- /cpdfjpeg.mli: -------------------------------------------------------------------------------- 1 | (** JPEG Utilities *) 2 | 3 | (** Return the width and height of a JPEG *) 4 | val jpeg_dimensions : Pdfio.bytes -> int * int 5 | 6 | (** Backup version, calls out to magick. This is because ours can't do progressive JPEG yet. *) 7 | val backup_jpeg_dimensions : path_to_im:string -> string -> int * int 8 | -------------------------------------------------------------------------------- /cpdftoc.mli: -------------------------------------------------------------------------------- 1 | (** Table of contents *) 2 | 3 | (** Typeset a table of contents and prepend to the document. *) 4 | val typeset_table_of_contents : font:Cpdfembed.cpdffont -> fontsize:float -> title:string -> bookmark:bool -> dotleader:bool -> process_struct_tree:bool -> ?subformat:Cpdfua.subformat -> Pdf.t -> Pdf.t 5 | -------------------------------------------------------------------------------- /html_manual/pysplits/c14.tex: -------------------------------------------------------------------------------- 1 | # CHAPTER 13. Images 2 | 3 | def getImageResolution(pdf, min_required_resolution): 4 | """Return a list of all uses of images in the PDF which do not meet the 5 | minimum required resolution in dpi as tuples of: 6 | (pagenumber, name, x pixels, y pixels, x resolution, y resolution)""" 7 | -------------------------------------------------------------------------------- /cpdfpresent.mli: -------------------------------------------------------------------------------- 1 | (** Presentations *) 2 | 3 | (** [presentation range t d horizontal inward direction effect_duration pdf] 4 | adds a presentation on the pages in [range]. See cpdfmanual.pdf for details. 5 | *) 6 | val presentation : int list -> string option -> 7 | float option -> bool -> bool -> int -> float -> Pdf.t -> Pdf.t 8 | -------------------------------------------------------------------------------- /cpdfchop.mli: -------------------------------------------------------------------------------- 1 | (** Chop *) 2 | 3 | (** Chop pages in the given range into pieces. *) 4 | val chop : x:int -> y:int -> columns:bool -> btt:bool -> rtl:bool -> Pdf.t -> int list -> Pdf.t 5 | 6 | (** Chop a page in the given range horizontally or vertically. *) 7 | val chop_hv : is_h:bool -> line:float -> columns:bool -> Pdf.t -> int list -> Pdf.t 8 | -------------------------------------------------------------------------------- /cpdfprinttree.mli: -------------------------------------------------------------------------------- 1 | (** Print trees *) 2 | 3 | (** Print a tree to a buffer. *) 4 | val to_buffer : ?line_prefix: string -> get_name: ('a -> string) -> get_children: ('a -> 'a list) -> Buffer.t -> 'a -> unit 5 | 6 | (** Print a tree to a string. *) 7 | val to_string : ?line_prefix: string -> get_name: ('a -> string) -> get_children: ('a -> 'a list) -> 'a -> string 8 | -------------------------------------------------------------------------------- /cpdfcommand.mli: -------------------------------------------------------------------------------- 1 | (** PDF Command Line Tools in library form *) 2 | 3 | (** Call the command line tools with the contents of [Sys.argv] *) 4 | val go : unit -> unit 5 | 6 | (** Call the command line tools with a specialised [argv] of our own *) 7 | val go_withargv : string array -> unit 8 | 9 | (**/**) 10 | exception StayOnError 11 | 12 | val null : unit -> unit 13 | -------------------------------------------------------------------------------- /cpdfpad.mli: -------------------------------------------------------------------------------- 1 | (** Padding *) 2 | 3 | (** Put blank pages before the given page numbers *) 4 | val padbefore : ?padwith:Pdf.t -> int list -> Pdf.t -> Pdf.t 5 | 6 | (** Put blank pages after the given page numbers *) 7 | val padafter : ?padwith:Pdf.t -> int list -> Pdf.t -> Pdf.t 8 | 9 | (** Pad to a multiple of n pages *) 10 | val padmultiple : int -> Pdf.t -> Pdf.t 11 | -------------------------------------------------------------------------------- /docsplits/pysplits/c11.tex: -------------------------------------------------------------------------------- 1 | def annotationsJSON(pdf): 2 | """Gets the annotations in JSON format.""" 3 | 4 | def removeAnnotations(pdf, r): 5 | """Removes all annotations from pages in the given range.""" 6 | 7 | def setAnnotationsJSON(pdf, data): 8 | """Adds the annotations given in JSON format to the PDF, on top of any 9 | existing annotations.""" 10 | -------------------------------------------------------------------------------- /cpdfspot.ml: -------------------------------------------------------------------------------- 1 | open Pdfutil 2 | 3 | let list_spot_colours pdf = 4 | Pdf.objiter 5 | (fun _ obj -> 6 | match obj with 7 | Pdf.Array (Pdf.Name "/Separation"::x::_) -> 8 | begin match Pdf.direct pdf x with 9 | Pdf.Name col -> Printf.printf "%s\n" col 10 | | _ -> () 11 | end 12 | | _ -> ()) 13 | pdf 14 | -------------------------------------------------------------------------------- /cpdfpng.mli: -------------------------------------------------------------------------------- 1 | (** Read PNG files *) 2 | 3 | (** PNG files, represented only to the extent required to insert as PDF image objects *) 4 | type t = 5 | {width : int; 6 | height : int; 7 | bitdepth : int; 8 | colortype : int; 9 | idat : Pdfio.bytes} 10 | 11 | (** Read a non-interlaced, non-alpha, non-palette PNG for inclusion in a PDF file. *) 12 | val read_png : Pdfio.input -> t 13 | -------------------------------------------------------------------------------- /docsplits/dotnetsplits/c06.tex: -------------------------------------------------------------------------------- 1 | CHAPTER 5. Compression 2 | 3 | Cpdf.compress(Cpdf.Pdf) 4 | 5 | Compresses any uncompressed streams in the given PDF using the Flate algorithm. 6 | 7 | Cpdf.decompress(Cpdf.Pdf) 8 | 9 | Decompresses any streams in the given PDF, so long as the compression method is 10 | supported. 11 | 12 | Cpdf.squeezeInMemory(Cpdf.Pdf) 13 | 14 | Squeezes a pdf in memory. 15 | -------------------------------------------------------------------------------- /html_manual/dotnetsplits/c06.tex: -------------------------------------------------------------------------------- 1 | CHAPTER 5. Compression 2 | 3 | Cpdf.compress(Cpdf.Pdf) 4 | 5 | Compresses any uncompressed streams in the given PDF using the Flate algorithm. 6 | 7 | Cpdf.decompress(Cpdf.Pdf) 8 | 9 | Decompresses any streams in the given PDF, so long as the compression method is 10 | supported. 11 | 12 | Cpdf.squeezeInMemory(Cpdf.Pdf) 13 | 14 | Squeezes a pdf in memory. 15 | -------------------------------------------------------------------------------- /cpdfcomposition.mli: -------------------------------------------------------------------------------- 1 | (** Show composition of a PDF *) 2 | 3 | (** [show_composition filesize json pdf] prints the composition of a document to 4 | Standard Output. *) 5 | val show_composition : int -> bool -> Pdf.t -> unit 6 | 7 | (** [show_composition_json_blob filesize json pdf] returns the composition of a 8 | document in JSON format. *) 9 | val show_composition_json_blob : int -> Pdf.t -> Pdfio.bytes 10 | -------------------------------------------------------------------------------- /compressor/Makefile: -------------------------------------------------------------------------------- 1 | SOURCES = compressor.ml 2 | 3 | RESULT = compressor 4 | 5 | PACKS = camlpdf 6 | 7 | TARGETS := native-code 8 | 9 | OCAMLFLAGS = -bin-annot 10 | OCAMLNCFLAGS = -g -safe-string -w -3 11 | OCAMLBCFLAGS = -g -safe-string -w -3 12 | OCAMLLDFLAGS = -g 13 | 14 | all : $(TARGETS) 15 | 16 | clean :: 17 | rm -rf doc foo foo2 out.pdf out2.pdf *.cmt *.cmti *.zlib 18 | 19 | -include OCamlMakefile 20 | -------------------------------------------------------------------------------- /cpdfsqueeze.mli: -------------------------------------------------------------------------------- 1 | (** Lossless compression *) 2 | 3 | (** Compresses all streams in the PDF document which are uncompressed, using 4 | /FlateDecode, leaving out metadata. If the PDF is encrypted, does nothing. *) 5 | val recompress_pdf : Pdf.t -> Pdf.t 6 | 7 | (** Decompresses all streams in a PDF document, assuming it isn't encrypted. *) 8 | val decompress_pdf : Pdf.t -> Pdf.t 9 | 10 | (** Squeeze a PDF *) 11 | val squeeze : ?logto:string -> ?pagedata:bool -> Pdf.t -> unit 12 | -------------------------------------------------------------------------------- /cpdfocg.mli: -------------------------------------------------------------------------------- 1 | (** Optional content groups *) 2 | 3 | (** Return list of OCG names. *) 4 | val ocg_get_list : Pdf.t -> string list 5 | 6 | (** Print OCG list to Standard Output. *) 7 | val ocg_list : Pdf.t -> unit 8 | 9 | (** Coalesce same-named OCGs resulting from merge. *) 10 | val ocg_coalesce : Pdf.t -> unit 11 | 12 | (** Rename an OCG. *) 13 | val ocg_rename : string -> string -> Pdf.t -> unit 14 | 15 | (** Make sure every OCG is in the /Order. *) 16 | val ocg_order_all : Pdf.t -> unit 17 | -------------------------------------------------------------------------------- /docsplits/javasplits/c06.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 5. Compression */ 2 | 3 | /** Compresses any uncompressed streams in the given PDF using the Flate 4 | algorithm. */ 5 | public native void compress(Pdf pdf) throws CpdfError; 6 | 7 | /** Decompresses any streams in the given PDF, so long as the compression 8 | method is supported. */ 9 | public native void decompress(Pdf pdf) throws CpdfError; 10 | 11 | /** Squeezes a pdf in memory. */ 12 | public native void squeezeInMemory(Pdf pdf) throws CpdfError; 13 | -------------------------------------------------------------------------------- /docsplits/pysplits/c06.tex: -------------------------------------------------------------------------------- 1 | def compress(pdf): 2 | """Compress any uncompressed streams in the given PDF using the Flate 3 | algorithm.""" 4 | 5 | def decompress(pdf): 6 | """Decompress any streams in the given PDF, so long as the compression 7 | method is supported.""" 8 | 9 | def squeezeInMemory(pdf): 10 | """squeezeToMemory(pdf) squeezes a pdf in memory. Squeezing is a lossless 11 | compression method which works by rearrangement of a PDFs internal 12 | structure.""" 13 | -------------------------------------------------------------------------------- /html_manual/javasplits/c06.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 5. Compression */ 2 | 3 | /** Compresses any uncompressed streams in the given PDF using the Flate 4 | algorithm. */ 5 | public native void compress(Pdf pdf) throws CpdfError; 6 | 7 | /** Decompresses any streams in the given PDF, so long as the compression 8 | method is supported. */ 9 | public native void decompress(Pdf pdf) throws CpdfError; 10 | 11 | /** Squeezes a pdf in memory. */ 12 | public native void squeezeInMemory(Pdf pdf) throws CpdfError; 13 | -------------------------------------------------------------------------------- /html_manual/pysplits/c15.tex: -------------------------------------------------------------------------------- 1 | # CHAPTER 14. Fonts 2 | 3 | def getFontInfo(pdf): 4 | """Get a list of (pagenumber, fontname, fonttype, fontencoding) tuples, 5 | showing each font used on each page.""" 6 | 7 | def removeFonts(pdf): 8 | """Remove all font data from a file.""" 9 | 10 | def copyFont(pdf, pdf2, r, pagenumber, fontname): 11 | """Copy the given font from the given page in the pdf PDF to every page in 12 | the pdf2 PDF. The new font is stored under its font name.""" 13 | -------------------------------------------------------------------------------- /docsplits/splits/c06.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 5. Compression */ 2 | 3 | /* 4 | * cpdf_compress(pdf) compresses any uncompressed streams in the given PDF 5 | * using the Flate algorithm. 6 | */ 7 | void cpdf_compress(int); 8 | 9 | /* 10 | * cpdf_decompress(pdf) decompresses any streams in the given PDF, so long as 11 | * the compression method is supported. 12 | */ 13 | void cpdf_decompress(int); 14 | 15 | /* cpdf_squeezeToMemory(pdf) squeezes a pdf in memory. */ 16 | void cpdf_squeezeInMemory(int); 17 | 18 | -------------------------------------------------------------------------------- /html_manual/splits/c06.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 5. Compression */ 2 | 3 | /* 4 | * cpdf_compress(pdf) compresses any uncompressed streams in the given PDF 5 | * using the Flate algorithm. 6 | */ 7 | void cpdf_compress(int); 8 | 9 | /* 10 | * cpdf_decompress(pdf) decompresses any streams in the given PDF, so long as 11 | * the compression method is supported. 12 | */ 13 | void cpdf_decompress(int); 14 | 15 | /* cpdf_squeezeToMemory(pdf) squeezes a pdf in memory. */ 16 | void cpdf_squeezeInMemory(int); 17 | 18 | -------------------------------------------------------------------------------- /docsplits/dotnetsplits/c00.tex: -------------------------------------------------------------------------------- 1 | Cpdf 2 | 3 | The Coherent PDF Library for .NET 4 | 5 | Cpdf.Pdf 6 | 7 | PDF document. Use the 'using' keyword, or call Dispose to make sure PDFs are 8 | deallocated. 9 | 10 | Cpdf.Pdf.Dispose 11 | 12 | Force disposal of the PDF. 13 | 14 | Cpdf.Pdf.Finalize 15 | 16 | Class destructor 17 | 18 | Cpdf.CPDFError 19 | 20 | Any function in this library may raise the CPDFError exception. 21 | 22 | Cpdf.CPDFError.#ctor(String) 23 | 24 | Construct a CPDFError which carries a string. 25 | -------------------------------------------------------------------------------- /html_manual/pysplits/c06.tex: -------------------------------------------------------------------------------- 1 | # CHAPTER 5. Compression 2 | 3 | def compress(pdf): 4 | """Compress any uncompressed streams in the given PDF using the Flate 5 | algorithm.""" 6 | 7 | def decompress(pdf): 8 | """Decompress any streams in the given PDF, so long as the compression 9 | method is supported.""" 10 | 11 | def squeezeInMemory(pdf): 12 | """squeezeToMemory(pdf) squeezes a pdf in memory. Squeezing is a lossless 13 | compression method which works be rearrangement of a PDFs internal 14 | -------------------------------------------------------------------------------- /docsplits/javascriptsplits/c06.tex: -------------------------------------------------------------------------------- 1 | // CHAPTER 5. Compression 2 | 3 | /** Compresses any uncompressed streams in the given PDF using the Flate 4 | algorithm. 5 | @arg {pdf} pdf PDF document */ 6 | function compress(pdf) {} 7 | 8 | /** Decompresses any streams in the given PDF, so long as the compression 9 | method is supported. 10 | @arg {pdf} pdf PDF document */ 11 | function decompress(pdf) {} 12 | 13 | /** Squeezes a pdf in memory. 14 | @arg {pdf} pdf PDF document */ 15 | function squeezeInMemory(pdf) {} 16 | 17 | -------------------------------------------------------------------------------- /html_manual/dotnetsplits/c00.tex: -------------------------------------------------------------------------------- 1 | Cpdf 2 | 3 | The Coherent PDF Library for .NET 4 | 5 | Cpdf.Pdf 6 | 7 | PDF document. Use the 'using' keyword, or call Dispose to make sure PDFs are 8 | deallocated. 9 | 10 | Cpdf.Pdf.Dispose 11 | 12 | Force disposal of the PDF. 13 | 14 | Cpdf.Pdf.Finalize 15 | 16 | Class destructor 17 | 18 | Cpdf.CPDFError 19 | 20 | Any function in this library may raise the CPDFError exception. 21 | 22 | Cpdf.CPDFError.#ctor(String) 23 | 24 | Construct a CPDFError which carries a string. 25 | -------------------------------------------------------------------------------- /html_manual/javascriptsplits/c06.tex: -------------------------------------------------------------------------------- 1 | // CHAPTER 5. Compression 2 | 3 | /** Compresses any uncompressed streams in the given PDF using the Flate 4 | algorithm. 5 | @arg {pdf} pdf PDF document */ 6 | function compress(pdf) {} 7 | 8 | /** Decompresses any streams in the given PDF, so long as the compression 9 | method is supported. 10 | @arg {pdf} pdf PDF document */ 11 | function decompress(pdf) {} 12 | 13 | /** Squeezes a pdf in memory. 14 | @arg {pdf} pdf PDF document */ 15 | function squeezeInMemory(pdf) {} 16 | 17 | -------------------------------------------------------------------------------- /docsplits/pysplits/c15.tex: -------------------------------------------------------------------------------- 1 | def getFontInfo(pdf): 2 | """Get a list of (pagenumber, fontname, fonttype, fontencoding) tuples, 3 | showing each font used on each page.""" 4 | 5 | def fontsJSON(pdf): 6 | """Return font information in JSON format.""" 7 | 8 | def removeFonts(pdf): 9 | """Remove all font data from a file.""" 10 | 11 | def copyFont(pdf, pdf2, r, pagenumber, fontname): 12 | """Copy the given font from the given page in the pdf PDF to every page in 13 | the pdf2 PDF. The new font is stored under its font name.""" 14 | -------------------------------------------------------------------------------- /docsplits/splits/c11.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 10. Annotations */ 2 | 3 | /* Return the annotations from a PDF in JSON format, returning also its length. 4 | */ 5 | void *cpdf_annotationsJSON(int, int *); 6 | 7 | /* cpdf_removeAnnotations(pdf, range) removes all annotations from pages in the 8 | * given range. */ 9 | void cpdf_removeAnnotations(int, int); 10 | 11 | /* cpdf_setAnnotationsJSON(pdf, data, length) adds the annotations given in 12 | * JSON format to the PDF, on top of any existing annotations. */ 13 | void cpdf_setAnnotationsJSON(int, void *, int); 14 | 15 | -------------------------------------------------------------------------------- /cpdf.opam: -------------------------------------------------------------------------------- 1 | opam-version: "2.0" 2 | name: "cpdf" 3 | version: "2.8.1" 4 | maintainer: "contact@coherentgraphics.co.uk" 5 | license: "AGPL-3.0-or-later" 6 | build: [[make]] 7 | depends: [ 8 | "ocaml" {>= "4.10.0"} 9 | "ocamlfind" {build} 10 | "camlpdf" {= version} 11 | ] 12 | homepage: "http://github.com/johnwhitington/cpdf-source" 13 | authors: ["John Whitington"] 14 | bug-reports: "http://github.com/johnwhitington/cpdf-source/issues" 15 | dev-repo: "git+https://github.com/johnwhitington/cpdf-source" 16 | install: [[make "install"]] 17 | synopsis: "PDF command line tools" 18 | -------------------------------------------------------------------------------- /docsplits/dotnetsplits/c16.tex: -------------------------------------------------------------------------------- 1 | CHAPTER 15. PDF and JSON 2 | 3 | Cpdf.outputJSON(String, Boolean, Boolean, Boolean, Cpdf.Pdf) 4 | 5 | Outputs a PDF in JSON format to the given filename. If parse_content is true, 6 | page content is parsed. If no_stream_data is true, all stream data is 7 | suppressed entirely. 8 | 9 | Cpdf.outputJSONMemory(Cpdf.Pdf, Boolean, Boolean, Boolean) 10 | 11 | Like outputJSON, but it writes to a byte array in memory. 12 | 13 | Cpdf.fromJSON(String) 14 | 15 | Loads a PDF from a JSON file given its filename. 16 | 17 | Cpdf.fromJSONMemory(Byte[]) 18 | 19 | Loads a PDF from a JSON file in memory 20 | -------------------------------------------------------------------------------- /html_manual/dotnetsplits/c16.tex: -------------------------------------------------------------------------------- 1 | CHAPTER 15. PDF and JSON 2 | 3 | Cpdf.outputJSON(String, Boolean, Boolean, Boolean, Cpdf.Pdf) 4 | 5 | Outputs a PDF in JSON format to the given filename. If parse_content is true, 6 | page content is parsed. If no_stream_data is true, all stream data is 7 | suppressed entirely. 8 | 9 | Cpdf.outputJSONMemory(Cpdf.Pdf, Boolean, Boolean, Boolean) 10 | 11 | Like outputJSON, but it writes to a byte array in memory. 12 | 13 | Cpdf.fromJSON(String) 14 | 15 | Loads a PDF from a JSON file given its filename. 16 | 17 | Cpdf.fromJSONMemory(Byte[]) 18 | 19 | Loads a PDF from a JSON file in memory 20 | -------------------------------------------------------------------------------- /cpdfutil.mli: -------------------------------------------------------------------------------- 1 | (** Utilities *) 2 | 3 | val progress : bool ref 4 | val progress_line : string -> unit 5 | val progress_line_no_end : string -> unit 6 | val progress_page : int -> unit 7 | val progress_endpage : unit -> unit 8 | val progress_done : unit -> unit 9 | 10 | (** Remove a dictionary entry. *) 11 | val remove_dict_entry : Pdf.t -> string -> Pdf.pdfobject option -> unit 12 | 13 | (** Replace a dictionary entry. *) 14 | val replace_dict_entry : Pdf.t -> string -> Pdf.pdfobject -> Pdf.pdfobject option -> unit 15 | 16 | (** Check for injectible characters in a string, and error out if so. *) 17 | val check_injectible : string -> unit 18 | -------------------------------------------------------------------------------- /docsplits/pysplits/c17.tex: -------------------------------------------------------------------------------- 1 | def getOCGList(pdf): 2 | """Return a list of Optional Content Groups in the given pdf as strings.""" 3 | 4 | def OCGRename(pdf, n_from, n_to): 5 | """Rename an optional content group.""" 6 | 7 | def OCGOrderAll(pdf): 8 | """Ensure that every optional content group appears in the OCG order list. 9 | """ 10 | 11 | def OCGCoalesce(pdf): 12 | """Coalesce optional content groups. For example, if we merge or stamp two 13 | files both with an OCG called "Layer 1", we will have two different 14 | optional content groups. This function will merge the two into a single 15 | optional content group.""" 16 | -------------------------------------------------------------------------------- /cpdfstrftime.mli: -------------------------------------------------------------------------------- 1 | (** C-style strftime *) 2 | 3 | (** Supports the following format specifiers: 4 | %a %A %b %B %s %e %H %I %j %m %M %p %S %T %u %w %Y %% *) 5 | 6 | (** Our version of Unix's tm, so Unix not required *) 7 | type t = 8 | {_tm_sec : int; 9 | _tm_min : int; 10 | _tm_hour : int; 11 | _tm_mday : int; 12 | _tm_mon : int; 13 | _tm_year : int; 14 | _tm_wday : int; 15 | _tm_yday : int; 16 | _tm_isdst : bool} 17 | 18 | (** Get the time now *) 19 | val current_time : unit -> t 20 | 21 | (** A dummy time value *) 22 | val dummy : t 23 | 24 | (** Strftime. If time omitted, the current time is used. *) 25 | val strftime : ?time:t -> string -> string 26 | -------------------------------------------------------------------------------- /html_manual/pysplits/c17.tex: -------------------------------------------------------------------------------- 1 | # CHAPTER 16. Optional Content Groups 2 | 3 | def getOCGList(pdf): 4 | """Return a list of Optional Content Groups in the given pdf as strings.""" 5 | 6 | def OCGRename(pdf, n_from, n_to): 7 | """Rename an optional content group.""" 8 | 9 | def OCGOrderAll(pdf): 10 | """Ensure that every optional content group appears in the OCG order list.""" 11 | 12 | def OCGCoalesce(pdf): 13 | """Coalesce optional content groups. For example, if we merge or stamp two 14 | files both with an OCG called "Layer 1", we will have two different 15 | optional content groups. This function will merge the two into a single 16 | optional content group.""" 17 | -------------------------------------------------------------------------------- /docsplits/dotnetsplits/c18.tex: -------------------------------------------------------------------------------- 1 | CHAPTER 17. Creating New PDFs 2 | 3 | Cpdf.blankDocument(Double, Double, Int32) 4 | 5 | Creates a blank document with pages of the given width (in points), height (in 6 | points), and number of pages. 7 | 8 | Cpdf.blankDocumentPaper(Cpdf.Papersize, Int32) 9 | 10 | Makes a blank document given a page size and number of pages. 11 | 12 | Cpdf.textToPDF(Double, Double, Cpdf.Font, Double, String) 13 | 14 | Typesets a UTF8 text file ragged right on a page of size w * h in points in the 15 | given font and font size. 16 | 17 | Cpdf.textToPDFPaper(Cpdf.Papersize, Cpdf.Font, Double, String) 18 | 19 | Typesets a UTF8 text file ragged right on a page of the given size in the given 20 | font and font size. 21 | -------------------------------------------------------------------------------- /docsplits/pysplits/c14.tex: -------------------------------------------------------------------------------- 1 | def getImageResolution(pdf, resolution): 2 | """Return a list of all uses of images in the PDF which do not meet the 3 | minimum required resolution in dpi as tuples of: 4 | (pagenumber, name, x pixels, y pixels, x resolution, y resolution, objnum). 5 | """ 6 | 7 | def imageResolutionJSON(pdf, resolution): 8 | """Return the image resolution data in JSON format.""" 9 | 10 | def getImages(pdf): 11 | """Return a list of images in the PDF as tuples of: 12 | (object number, pages occurring, image name, width, height, size, 13 | bitspercomponent, color space, filter) 14 | """ 15 | 16 | def imagesJSON(pdf): 17 | """Return the list of images in the PDF in JSON format.""" 18 | -------------------------------------------------------------------------------- /html_manual/dotnetsplits/c18.tex: -------------------------------------------------------------------------------- 1 | CHAPTER 17. Creating New PDFs 2 | 3 | Cpdf.blankDocument(Double, Double, Int32) 4 | 5 | Creates a blank document with pages of the given width (in points), height (in 6 | points), and number of pages. 7 | 8 | Cpdf.blankDocumentPaper(Cpdf.Papersize, Int32) 9 | 10 | Makes a blank document given a page size and number of pages. 11 | 12 | Cpdf.textToPDF(Double, Double, Cpdf.Font, Double, String) 13 | 14 | Typesets a UTF8 text file ragged right on a page of size w * h in points in the 15 | given font and font size. 16 | 17 | Cpdf.textToPDFPaper(Cpdf.Papersize, Cpdf.Font, Double, String) 18 | 19 | Typesets a UTF8 text file ragged right on a page of the given size in the given 20 | font and font size. 21 | -------------------------------------------------------------------------------- /cpdfcreate.ml: -------------------------------------------------------------------------------- 1 | open Pdfutil 2 | 3 | let blank_document width height pages = 4 | let pdf_pages = 5 | map (fun () -> Pdfpage.blankpage (Pdfpaper.make Pdfunits.PdfPoint width height)) (many () pages) 6 | in 7 | let pdf, pageroot = Pdfpage.add_pagetree pdf_pages (Pdf.empty ()) in 8 | let pdf = Pdfpage.add_root pageroot [] pdf in 9 | Pdf.change_id pdf (string_of_float (Random.float 1.)); 10 | pdf 11 | 12 | let blank_document_paper papersize pages = 13 | let pdf_pages = 14 | map (fun () -> Pdfpage.blankpage papersize) (many () pages) 15 | in 16 | let pdf, pageroot = Pdfpage.add_pagetree pdf_pages (Pdf.empty ()) in 17 | let pdf = Pdfpage.add_root pageroot [] pdf in 18 | Pdf.change_id pdf (string_of_float (Random.float 1.)); 19 | pdf 20 | -------------------------------------------------------------------------------- /docsplits/pysplits/c00.tex: -------------------------------------------------------------------------------- 1 | """Pycpdflib: a python interface to cpdf. 2 | 3 | Before using the library, you must load the libpycpdf and libcpdf DLLs. This is 4 | achieved with the pycpdflib.loadDLL function, given the filename or full path 5 | of the libpycpdf DLL. On Windows, you may have to call os.add_dll_directory 6 | first. On MacOS, you may need to give the full path, and you may need to 7 | install libcpdf.so in a standard location /usr/local/lib/, or use the 8 | install_name_tool command to tell libpycpdf.so where to find libcpdf.so. 9 | 10 | A 'range' is a list of integers specifying page numbers. 11 | 12 | Text arguments and results are in UTF8. Data is of type bytes. 13 | 14 | Any function may raise the exception CPDFError, carrying a string describing 15 | the error. """ 16 | -------------------------------------------------------------------------------- /html_manual/pysplits/c00.tex: -------------------------------------------------------------------------------- 1 | """Pycpdflib: a python interface to cpdf. 2 | 3 | Before using the library, you must load the libpycpdf and libcpdf DLLs. This is 4 | achieved with the pycpdflib.loadDLL function, given the filename or full path 5 | of the libpycpdf DLL. On Windows, you may have to call os.add_dll_directory 6 | first. On MacOS, you may need to give the full path, and you may need to 7 | install libcpdf.so in a standard location /usr/local/lib/, or use the 8 | install_name_tool command to tell libpycpdf.so where to find libcpdf.so. 9 | 10 | A 'range' is a list of integers specifying page numbers. 11 | 12 | Text arguments and results are in UTF8. Data is of type bytes. 13 | 14 | Any function may raise the exception CPDFError, carrying a string describing 15 | the error. """ 16 | -------------------------------------------------------------------------------- /docsplits/pysplits/c07.tex: -------------------------------------------------------------------------------- 1 | def getBookmarks(pdf): 2 | """Get the bookmarks for a PDF as a list of tuples of the form: 3 | (level : int, page : int, text : string, openstatus : bool)""" 4 | 5 | def setBookmarks(pdf, marks): 6 | """Set the bookmarks for a PDF as a list of tuples of the form: 7 | (level : int, page : int, text : string, openstatus : bool)""" 8 | 9 | def getBookmarksJSON(pdf): 10 | """Get the bookmarks in JSON format.""" 11 | 12 | def setBookmarksJSON(pdf, data): 13 | """Sets the bookmarks from JSON bookmark data.""" 14 | 15 | def tableOfContents(pdf, font, fontsize, title, bookmark): 16 | """Typesets a table of contents from existing bookmarks and prepends it to 17 | the document. If bookmark is set, the table of contents gets its own 18 | bookmark.""" 19 | -------------------------------------------------------------------------------- /docsplits/splitwrapper: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | csplit -k -f splits/c ../../cpdflib-source/cpdflibwrapper.h '/CHAPTER/' {19} 3 | mv splits/c00 splits/c00.tex 4 | mv splits/c01 splits/c01.tex 5 | mv splits/c02 splits/c02.tex 6 | mv splits/c03 splits/c03.tex 7 | mv splits/c04 splits/c04.tex 8 | mv splits/c05 splits/c05.tex 9 | mv splits/c06 splits/c06.tex 10 | mv splits/c07 splits/c07.tex 11 | mv splits/c08 splits/c08.tex 12 | mv splits/c09 splits/c09.tex 13 | mv splits/c10 splits/c10.tex 14 | mv splits/c11 splits/c11.tex 15 | mv splits/c12 splits/c12.tex 16 | mv splits/c13 splits/c13.tex 17 | mv splits/c14 splits/c14.tex 18 | mv splits/c15 splits/c15.tex 19 | mv splits/c16 splits/c16.tex 20 | mv splits/c17 splits/c17.tex 21 | mv splits/c18 splits/c18.tex 22 | mv splits/c19 splits/c19.tex 23 | mv splits/c20 splits/c20.tex 24 | -------------------------------------------------------------------------------- /cpdfdebug.ml: -------------------------------------------------------------------------------- 1 | open Pdfutil 2 | 3 | let print_pdf_objs pdf = 4 | Printf.printf "Trailerdict: %s\n" (Pdfwrite.string_of_pdf pdf.Pdf.trailerdict); 5 | Printf.printf "Root: %i\n" pdf.Pdf.root; 6 | begin match Pdf.lookup_direct pdf "/Root" pdf.Pdf.trailerdict with 7 | | Some catalog -> 8 | Printf.printf "Catalog: %s\n" (Pdfwrite.string_of_pdf catalog); 9 | begin match Pdf.lookup_direct pdf "/Pages" catalog with 10 | | Some pages -> 11 | Printf.printf "Pages: %s\n" (Pdfwrite.string_of_pdf pages) 12 | | None -> 13 | flprint "no catalog\n" 14 | end 15 | | None -> 16 | flprint "No catalog!\n" 17 | end; 18 | Pdf.objiter 19 | (fun n obj -> 20 | Printf.printf "%i 0 obj:\n\n" n; 21 | Printf.printf "%s\n" (Pdfwrite.string_of_pdf obj)) 22 | pdf 23 | -------------------------------------------------------------------------------- /html_manual/pysplits/c16.tex: -------------------------------------------------------------------------------- 1 | # CHAPTER 15. PDF and JSON 2 | 3 | def outputJSON(filename, parse_content, no_stream_data, decompress_streams, pdf): 4 | """Output a PDF in JSON format to the given filename. If parse_content is 5 | True, page content is parsed. If decompress_streams is True, streams are 6 | decompressed. If no_stream_data is True, all stream data is suppressed 7 | entirely.""" 8 | 9 | def outputJSONMemory(pdf, parse_content, no_stream_data, decompress_streams): 10 | """outputJSONMemory(pdf, parse_content, no_stream_data, decompress_stream) 11 | is like outputJSON, but it write to a buffer in memory).""" 12 | 13 | def fromJSON(filename): 14 | """Load a PDF from a JSON file given its filename.""" 15 | 16 | def fromJSONMemory(data): 17 | """ Load a PDF from JSON data in memory.""" 18 | -------------------------------------------------------------------------------- /html_manual/splits/c16.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 15. PDF and JSON */ 2 | 3 | /* cpdf_outputJSON(filename, parse_content, no_stream_data, pdf) outputs a PDF 4 | * in JSON format to the given filename. If parse_content is true, page content 5 | * is parsed. If no_stream_data is true, all stream data is suppressed entirely. 6 | * */ 7 | void cpdf_outputJSON(const char[], int, int, int, int); 8 | 9 | /* cpdf_outputJSONMemory(parse_content, no_stream_data, pdf, &length) is like 10 | * outputJSON, but it write to a buffer in memory. The length is filled in. */ 11 | void *cpdf_outputJSONMemory(int, int, int, int, int *); 12 | 13 | /* Load a PDF from a JSON file given its filename */ 14 | int cpdf_fromJSON(const char[]); 15 | 16 | /* Load a PDF from a JSON file in memory, given the buffer and its length */ 17 | int cpdf_fromJSONMemory(void *, int); 18 | 19 | -------------------------------------------------------------------------------- /cpdfcoord.mli: -------------------------------------------------------------------------------- 1 | (** Parsing coordinates, numbers, positions etc.*) 2 | 3 | (** See cpdfmanual.pdf for examples of things these functions can parse, such as page sizes. *) 4 | 5 | (** Read a single rectangles from a string. *) 6 | val parse_rectangle : Pdf.t -> string -> (float * float * float * float) 7 | 8 | (** Read a list of rectangles from a string. *) 9 | val parse_rectangles : Pdf.t -> string -> (float * float * float * float) list 10 | 11 | (** Read a coordinate from a string *) 12 | val parse_coordinate : Pdf.t -> string -> float * float 13 | 14 | (** Read a list of coordinates from a string *) 15 | val parse_coordinates : Pdf.t -> string -> (float * float) list 16 | 17 | val parse_units_string : Pdf.t -> Pdfpage.t -> string -> float list 18 | 19 | (** Read a single number from a string *) 20 | val parse_single_number : Pdf.t -> string -> float 21 | -------------------------------------------------------------------------------- /cpdfimpose.mli: -------------------------------------------------------------------------------- 1 | (** Imposition *) 2 | 3 | (** Imposition. See cpdfmanual.pdf for details. *) 4 | val impose : process_struct_tree:bool -> x:float -> y:float -> fit:bool -> columns:bool -> rtl:bool -> btt:bool -> center:bool -> margin:float -> spacing:float -> linewidth:float -> fast:bool -> Pdf.t -> Pdf.t 5 | 6 | (** The legacy twoup_stack operation puts two logical pages on each physical page, 7 | rotating them 90 degrees to do so. The new mediabox is thus larger. Bool true 8 | (fast) if assume well-formed ISO content streams. *) 9 | val twoup_stack : process_struct_tree:bool -> bool -> Pdf.t -> Pdf.t 10 | 11 | (** The legacy twoup operation does the same, but scales the new sides down so that 12 | the media box is unchanged. Bool true (fast) if assume well-formed ISO content streams. *) 13 | val twoup : process_struct_tree:bool -> bool -> Pdf.t -> Pdf.t 14 | -------------------------------------------------------------------------------- /html_manual/pysplits/c18.tex: -------------------------------------------------------------------------------- 1 | # CHAPTER 17. Creating New PDFs 2 | 3 | def blankDocument(w, h, pages): 4 | """ Create a blank document 5 | with pages of the given width (in points), height (in points), and number 6 | of pages.""" 7 | 8 | def blankDocumentPaper(papersize, pages): 9 | """Create a blank document with pages of the given paper size, and number 10 | of pages. """ 11 | 12 | def textToPDF(w, h, font, fontsize, filename): 13 | """textToPDF(w, h, font, fontsize, filename) typesets a UTF8 text file 14 | ragged right on a page of size w * h in points in the given font and font 15 | size.""" 16 | 17 | def textToPDFPaper(papersize, font, fontsize, filename): 18 | """textToPDF(papersize font, fontsize, filename) typesets a UTF8 text file 19 | ragged right on a page of the given size in the given font and font 20 | size.""" 21 | -------------------------------------------------------------------------------- /cpdfannot.mli: -------------------------------------------------------------------------------- 1 | (** Annotations *) 2 | 3 | (* {2 Modern functions} *) 4 | 5 | (** Get annotations as JSON *) 6 | val get_annotations_json : Pdf.t -> int list -> Pdfio.bytes 7 | 8 | (** Set annotations from JSON. *) 9 | val set_annotations_json : Pdf.t -> Pdfio.input -> unit 10 | 11 | (** Remove the annotations on given pages. *) 12 | val remove_annotations : int list -> Pdf.t -> Pdf.t 13 | 14 | (** Copy the annotations on a given set of pages *) 15 | val copy_annotations : int list -> Pdf.t -> Pdf.t -> unit 16 | 17 | (* {2 Old-style functions *) 18 | 19 | (** Return the annotations as a simple old-style (pagenumber, content) list. *) 20 | val get_annotations : Cpdfmetadata.encoding -> Pdf.t -> (int * string) list 21 | 22 | (** List the annotations to standard output in a given encoding. *) 23 | val list_annotations : int list -> Cpdfmetadata.encoding -> Pdf.t -> unit 24 | -------------------------------------------------------------------------------- /cpdfunicodedata.mli: -------------------------------------------------------------------------------- 1 | (** UnicodeData.txt in parsed form *) 2 | 3 | (** The source, compressed. *) 4 | val unicodedata_source : string 5 | 6 | (** The type of a single entry from UnicodeData.txt *) 7 | type t = 8 | {code_value : string; 9 | character_name : string; 10 | general_category : string; 11 | canonical_combining_classes : string; 12 | bidirectional_category : string; 13 | character_decomposition_mapping : string; 14 | decimal_digit_value : string; 15 | digit_value : string; 16 | numeric_value : string; 17 | mirrored : string; 18 | unicode_10_name : string; 19 | iso_10646_comment_field : string; 20 | uppercase_mapping : string; 21 | lowercase_mapping : string; 22 | titlecase_mapping : string} 23 | 24 | (** The unicode data. We pass a unit because it is parsed upon demand and 25 | memoised. *) 26 | val unicodedata : unit -> t list 27 | -------------------------------------------------------------------------------- /docsplits/dotnetsplits/c17.tex: -------------------------------------------------------------------------------- 1 | CHAPTER 16. Optional Content Groups 2 | 3 | Cpdf.startGetOCGList(Cpdf.Pdf) 4 | 5 | Begins retrieving optional content group names. The serial number 0..n - 1 is 6 | returned. 7 | 8 | Cpdf.OCGListEntry(Int32) 9 | 10 | Retrieves an OCG name, given its serial number 0..n - 1. 11 | 12 | Cpdf.endGetOCGList 13 | 14 | Ends retrieval of optional content group names. 15 | 16 | Cpdf.OCGRename(Cpdf.Pdf, String, String) 17 | 18 | Renames an optional content group. 19 | 20 | Cpdf.OCGOrderAll(Cpdf.Pdf) 21 | 22 | Ensures that every optional content group appears in the OCG order list. 23 | 24 | Cpdf.OCGCoalesce(Cpdf.Pdf) 25 | 26 | Coalesces optional content groups. For example, if we merge or stamp two files 27 | both with an OCG called "Layer 1", we will have two different optional content 28 | groups. This function will merge the two into a single optional content group. 29 | -------------------------------------------------------------------------------- /html_manual/go: -------------------------------------------------------------------------------- 1 | #Move files around 2 | cp -r ../manualimages . 3 | cp ../logo.pdf . 4 | cp ../Changes . 5 | mkdir ../camlpdf 6 | cp ../../camlpdf/Changes ../camlpdf/Changes 7 | cp ../cpdfmanual.tex . 8 | 9 | #Remove tagging 10 | sed -i '' 's/\\DocumentMetadata/\%\\DocumentMetadata/' cpdfmanual.tex 11 | 12 | #Typeset to HTML 13 | htlatex cpdfmanual "html,2" 14 | 15 | #Pad frames 16 | sed -i '' 's/.framedenv{border: 1px solid black;}/.framedenv{border: 1px solid black; padding: 8px}/g' cpdfmanual.css 17 | 18 | #Remove tex4ht's attempt at box-drawing characters for struct trees 19 | LCTYPE=C LANG=C sed -i '' 's/__/\ \ /g' *.html 20 | 21 | #Make sure HTML files have a lang set 22 | LCTYPE=C LANG=C sed -i '' 's///g' *.html 23 | 24 | #Give the main page a title 25 | LCTYPE=C LANG=C sed -i '' 's//<title>Coherent PDF Command Line Tools Manual/' cpdfmanual.html 26 | -------------------------------------------------------------------------------- /html_manual/dotnetsplits/c17.tex: -------------------------------------------------------------------------------- 1 | CHAPTER 16. Optional Content Groups 2 | 3 | Cpdf.startGetOCGList(Cpdf.Pdf) 4 | 5 | Begins retrieving optional content group names. The serial number 0..n - 1 is 6 | returned. 7 | 8 | Cpdf.OCGListEntry(Int32) 9 | 10 | Retrieves an OCG name, given its serial number 0..n - 1. 11 | 12 | Cpdf.endGetOCGList 13 | 14 | Ends retrieval of optional content group names. 15 | 16 | Cpdf.OCGRename(Cpdf.Pdf, String, String) 17 | 18 | Renames an optional content group. 19 | 20 | Cpdf.OCGOrderAll(Cpdf.Pdf) 21 | 22 | Ensures that every optional content group appears in the OCG order list. 23 | 24 | Cpdf.OCGCoalesce(Cpdf.Pdf) 25 | 26 | Coalesces optional content groups. For example, if we merge or stamp two files 27 | both with an OCG called "Layer 1", we will have two different optional content 28 | groups. This function will merge the two into a single optional content group. 29 | -------------------------------------------------------------------------------- /docsplits/dotnetsplits/c14.tex: -------------------------------------------------------------------------------- 1 | CHAPTER 13. Images. 2 | 3 | Cpdf.startGetImageResolution(Cpdf.Pdf, Double) 4 | 5 | Cpdf.getImageResolutionPageNumber(Int32) 6 | 7 | Cpdf.getImageResolutionImageName(Int32) 8 | 9 | Cpdf.getImageResolutionXPixels(Int32) 10 | 11 | Cpdf.getImageResolutionYPixels(Int32) 12 | 13 | Cpdf.getImageResolutionXRes(Int32) 14 | 15 | Cpdf.getImageResolutionYRes(Int32) 16 | 17 | Cpdf.endGetImageResolution 18 | 19 | Gets image data, including resolution at all points of use. Call 20 | startGetImageResolution(pdf, min_required_resolution) will begin the 21 | process of obtaining data on all image uses below min_required_resolution, 22 | returning the total number. So, to return all image uses, specify a very 23 | high min_required_resolution. Then, call the other functions giving a 24 | serial number 0..n - 1, to retrieve the data. Finally, call 25 | endGetImageResolution to clean up. 26 | -------------------------------------------------------------------------------- /html_manual/dotnetsplits/c14.tex: -------------------------------------------------------------------------------- 1 | CHAPTER 13. Images. 2 | 3 | Cpdf.startGetImageResolution(Cpdf.Pdf, Double) 4 | 5 | Cpdf.getImageResolutionPageNumber(Int32) 6 | 7 | Cpdf.getImageResolutionImageName(Int32) 8 | 9 | Cpdf.getImageResolutionXPixels(Int32) 10 | 11 | Cpdf.getImageResolutionYPixels(Int32) 12 | 13 | Cpdf.getImageResolutionXRes(Int32) 14 | 15 | Cpdf.getImageResolutionYRes(Int32) 16 | 17 | Cpdf.endGetImageResolution 18 | 19 | Gets image data, including resolution at all points of use. Call 20 | startGetImageResolution(pdf, min_required_resolution) will begin the 21 | process of obtaining data on all image uses below min_required_resolution, 22 | returning the total number. So, to return all image uses, specify a very 23 | high min_required_resolution. Then, call the other functions giving a 24 | serial number 0..n - 1, to retrieve the data. Finally, call 25 | endGetImageResolution to clean up. 26 | -------------------------------------------------------------------------------- /docsplits/dotnetsplits/c15.tex: -------------------------------------------------------------------------------- 1 | CHAPTER 14. Fonts. 2 | 3 | Cpdf.startGetFontInfo(Cpdf.Pdf) 4 | 5 | Cpdf.numberFonts 6 | 7 | Cpdf.getFontPage(Int32) 8 | 9 | Cpdf.getFontName(Int32) 10 | 11 | Cpdf.getFontType(Int32) 12 | 13 | Cpdf.getFontEncoding(Int32) 14 | 15 | Cpdf.endGetFontInfo 16 | 17 | Retrieves font information. First, call startGetFontInfo(pdf). Now call 18 | numberFonts to return the number of fonts. For each font, call one or more of 19 | getFontPage, getFontName, getFontType, and getFontEncoding giving a serial 20 | number 0..n - 1 to return information. Finally, call endGetFontInfo to clean 21 | up. 22 | 23 | Cpdf.removeFonts(Cpdf.Pdf) 24 | 25 | Removes all font data from a file. 26 | 27 | Cpdf.copyFont(Cpdf.Pdf, Cpdf.Pdf, List{Int32}, Int32, String) 28 | 29 | Copies the given font from the given page in the 'from' PDF to every page in 30 | the 'to' PDF. The new font is stored under its font name. 31 | -------------------------------------------------------------------------------- /html_manual/dotnetsplits/c15.tex: -------------------------------------------------------------------------------- 1 | CHAPTER 14. Fonts. 2 | 3 | Cpdf.startGetFontInfo(Cpdf.Pdf) 4 | 5 | Cpdf.numberFonts 6 | 7 | Cpdf.getFontPage(Int32) 8 | 9 | Cpdf.getFontName(Int32) 10 | 11 | Cpdf.getFontType(Int32) 12 | 13 | Cpdf.getFontEncoding(Int32) 14 | 15 | Cpdf.endGetFontInfo 16 | 17 | Retrieves font information. First, call startGetFontInfo(pdf). Now call 18 | numberFonts to return the number of fonts. For each font, call one or more of 19 | getFontPage, getFontName, getFontType, and getFontEncoding giving a serial 20 | number 0..n - 1 to return information. Finally, call endGetFontInfo to clean 21 | up. 22 | 23 | Cpdf.removeFonts(Cpdf.Pdf) 24 | 25 | Removes all font data from a file. 26 | 27 | Cpdf.copyFont(Cpdf.Pdf, Cpdf.Pdf, List{Int32}, Int32, String) 28 | 29 | Copies the given font from the given page in the 'from' PDF to every page in 30 | the 'to' PDF. The new font is stored under its font name. 31 | -------------------------------------------------------------------------------- /html_manual/pysplits/c07.tex: -------------------------------------------------------------------------------- 1 | # CHAPTER 6. Bookmarks 2 | 3 | def getBookmarks(pdf): 4 | """Get the bookmarks for a PDF as a list of tuples of the form: 5 | (level : int, page : int, text : string, openstatus : bool)""" 6 | 7 | def setBookmarks(pdf, marks): 8 | """Set the bookmarks for a PDF as a list of tuples of the form: 9 | (level : int, page : int, text : string, openstatus : bool)""" 10 | 11 | def getBookmarksJSON(pdf): 12 | """Get the bookmarks in JSON format.""" 13 | 14 | def setBookmarksJSON(pdf, data): 15 | """setBookmarksJSON(pdf, data) sets the bookmarks from JSON bookmark data.""" 16 | 17 | def tableOfContents(pdf, font, fontsize, title, bookmark): 18 | """tableOfContents(pdf, font, fontsize, title, bookmark) typesets a table 19 | of contents from existing bookmarks and prepends it to the document. If 20 | bookmark is set, the table of contents gets its own bookmark.""" 21 | -------------------------------------------------------------------------------- /docsplits/pysplits/c16.tex: -------------------------------------------------------------------------------- 1 | def JSONUTF8(utf8): 2 | """Set the JSON output format. If true, the newer UTF8 format is used. 3 | Default: False.""" 4 | 5 | def outputJSON(filename, parse_content, no_stream_data, decompress_streams, pdf): 6 | """Output a PDF in JSON format to the given filename. If parse_content is 7 | True, page content is parsed. If decompress_streams is True, streams are 8 | decompressed. If no_stream_data is True, all stream data is suppressed 9 | entirely.""" 10 | 11 | def outputJSONMemory(pdf, parse_content, no_stream_data, decompress_streams): 12 | """outputJSONMemory(pdf, parse_content, no_stream_data, decompress_stream) 13 | is like outputJSON, but it write to a buffer in memory).""" 14 | 15 | def fromJSON(filename): 16 | """Load a PDF from a JSON file given its filename.""" 17 | 18 | def fromJSONMemory(data): 19 | """ Load a PDF from JSON data in memory.""" 20 | -------------------------------------------------------------------------------- /docsplits/pysplits/c13.tex: -------------------------------------------------------------------------------- 1 | def attachFile(filename, pdf): 2 | """Attach a file to the pdf. It is attached at document level.""" 3 | 4 | def attachFileToPage(filename, pdf, pagenumber): 5 | """Attach a file, given its file name, pdf, and the page number to which 6 | it should be attached.""" 7 | 8 | def attachFileFromMemory(data, filename, pdf): 9 | """Attach a file from a byte array. It is attached at document level.""" 10 | 11 | def attachFileToPageFromMemory(data, filename, pdf, pagenumber): 12 | """Attach a file to a given pag from a byte array. It is attached at 13 | document level.""" 14 | 15 | def removeAttachedFiles(pdf): 16 | """Remove all page- and document-level attachments from a document.""" 17 | 18 | def getAttachments(pdf): 19 | """List information about attachements. Returns a list of tuples (name, 20 | page number, byte array of data). Page 0 = document-level attachment.""" 21 | -------------------------------------------------------------------------------- /docsplits/dotnetsplits/c03.tex: -------------------------------------------------------------------------------- 1 | CHAPTER 2. Merging and Splitting 2 | 3 | Cpdf.mergeSimple(List{Cpdf.Pdf}) 4 | 5 | Given a list of PDFs, merges the files into a new one, which is returned. 6 | 7 | Cpdf.merge(List{Cpdf.Pdf}, Boolean, Boolean) 8 | 9 | Merges the PDFs. If retain_numbering is true page labels are not rewritten. If 10 | remove_duplicate_fonts is true, duplicate fonts are merged. This is useful when 11 | the source documents for merging originate from the same source. 12 | 13 | Cpdf.mergeSame(List{Cpdf.Pdf}, Boolean, Boolean, List{List{Int32}}) 14 | 15 | The same as merge, except that it has an additional argument - a list of page 16 | ranges. This is used to select the pages to pick from each PDF. This avoids 17 | duplication of information when multiple discrete parts of a source PDF are 18 | included. 19 | 20 | Cpdf.selectPages(Cpdf.Pdf, List{Int32}) 21 | 22 | Returns a new document which just those pages in the page range. 23 | -------------------------------------------------------------------------------- /html_manual/dotnetsplits/c03.tex: -------------------------------------------------------------------------------- 1 | CHAPTER 2. Merging and Splitting 2 | 3 | Cpdf.mergeSimple(List{Cpdf.Pdf}) 4 | 5 | Given a list of PDFs, merges the files into a new one, which is returned. 6 | 7 | Cpdf.merge(List{Cpdf.Pdf}, Boolean, Boolean) 8 | 9 | Merges the PDFs. If retain_numbering is true page labels are not rewritten. If 10 | remove_duplicate_fonts is true, duplicate fonts are merged. This is useful when 11 | the source documents for merging originate from the same source. 12 | 13 | Cpdf.mergeSame(List{Cpdf.Pdf}, Boolean, Boolean, List{List{Int32}}) 14 | 15 | The same as merge, except that it has an additional argument - a list of page 16 | ranges. This is used to select the pages to pick from each PDF. This avoids 17 | duplication of information when multiple discrete parts of a source PDF are 18 | included. 19 | 20 | Cpdf.selectPages(Cpdf.Pdf, List{Int32}) 21 | 22 | Returns a new document which just those pages in the page range. 23 | -------------------------------------------------------------------------------- /docsplits/pysplits/c03.tex: -------------------------------------------------------------------------------- 1 | def mergeSimple(pdfs): 2 | """Given a list of PDFs, merges the documents into a new PDF, which is 3 | returned.""" 4 | 5 | def merge(pdfs, retain_numbering, remove_duplicate_fonts): 6 | """Merges the list of PDFs. If retain_numbering is True page labels are not 7 | rewritten. If remove_duplicate_fonts is True, duplicate fonts are merged. 8 | This is useful when the source documents for merging originate from the 9 | same source.""" 10 | 11 | def mergeSame(pdfs, retain_numbering, remove_duplicate_fonts, ranges): 12 | """The same as merge, except that it has an additional argument (a list of 13 | page ranges). This is used to select the pages to pick from each PDF. This 14 | avoids duplication of information when multiple discrete parts of a single 15 | source PDF are included.""" 16 | 17 | def selectPages(pdf, r): 18 | """Returns a new document which just those pages in the page range.""" 19 | -------------------------------------------------------------------------------- /html_manual/splits/c14.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 13. Images. */ 2 | 3 | /* 4 | * Get image data, including resolution at all points of use. Call 5 | * cpdf_startGetImageResolution(pdf, min_required_resolution) will begin the 6 | * process of obtaining data on all image uses below min_required_resolution, 7 | * returning the total number. So, to return all image uses, specify a very 8 | * high min_required_resolution. Then, call the other functions giving a 9 | * serial number 0..<total number> - 1, to retrieve the data. Finally, call 10 | * cpdf_endGetImageResolution to clean up. 11 | */ 12 | int cpdf_startGetImageResolution(int, float); 13 | int cpdf_getImageResolutionPageNumber(int); 14 | char *cpdf_getImageResolutionImageName(int); 15 | int cpdf_getImageResolutionXPixels(int); 16 | int cpdf_getImageResolutionYPixels(int); 17 | double cpdf_getImageResolutionXRes(int); 18 | double cpdf_getImageResolutionYRes(int); 19 | void cpdf_endGetImageResolution(void); 20 | 21 | -------------------------------------------------------------------------------- /cpdfprinttree.ml: -------------------------------------------------------------------------------- 1 | (* Courtesy Martin Jambon, in the public domain. *) 2 | let rec titer f = function 3 | | [] -> () 4 | | [x] -> f true x 5 | | x :: tl -> f false x; titer f tl 6 | 7 | let to_buffer ?(line_prefix = "") ~get_name ~get_children buf x = 8 | let rec print_root indent x = 9 | Printf.bprintf buf "%s\n" (get_name x); 10 | let children = get_children x in 11 | titer (print_child indent) children 12 | and print_child indent is_last x = 13 | let line = if is_last then "└── " else "├── " in 14 | Printf.bprintf buf "%s%s" indent line; 15 | let extra_indent = if is_last then " " else "│ " in 16 | print_root (indent ^ extra_indent) x 17 | in 18 | Buffer.add_string buf line_prefix; 19 | print_root line_prefix x 20 | 21 | let to_string ?line_prefix ~get_name ~get_children x = 22 | let buf = Buffer.create 1000 in 23 | to_buffer ?line_prefix ~get_name ~get_children buf x; 24 | Buffer.contents buf 25 | -------------------------------------------------------------------------------- /docsplits/splits/c16.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 15. PDF and JSON */ 2 | 3 | /* Set the JSON output format. If true, the newer UTF8 format is used. Default: 4 | * false. */ 5 | void cpdf_JSONUTF8(int); 6 | 7 | /* cpdf_outputJSON(filename, parse_content, no_stream_data, pdf) outputs a PDF 8 | * in JSON format to the given filename. If parse_content is true, page content 9 | * is parsed. If no_stream_data is true, all stream data is suppressed entirely. 10 | * */ 11 | void cpdf_outputJSON(const char[], int, int, int, int); 12 | 13 | /* cpdf_outputJSONMemory(parse_content, no_stream_data, pdf, size) is like 14 | * outputJSON, but it writes to a buffer in memory. The length is filled in. */ 15 | void *cpdf_outputJSONMemory(int, int, int, int, int *); 16 | 17 | /* Load a PDF from a JSON file given its filename. */ 18 | int cpdf_fromJSON(const char[]); 19 | 20 | /* Load a PDF from a JSON file in memory, given the buffer and its length. */ 21 | int cpdf_fromJSONMemory(void *, int); 22 | 23 | -------------------------------------------------------------------------------- /html_manual/pysplits/c13.tex: -------------------------------------------------------------------------------- 1 | # CHAPTER 12. File Attachments 2 | 3 | def attachFile(filename, pdf): 4 | """Attach a file to the pdf. It is attached at document level.""" 5 | 6 | def attachFileToPage(filename, pdf, pagenumber): 7 | """Attach a file, given its file name, pdf, and the page number to which 8 | it should be attached.""" 9 | 10 | def attachFileFromMemory(data, filename, pdf): 11 | """Attach a file from a byte array. It is attached at document level.""" 12 | 13 | def attachFileToPageFromMemory(data, filename, pdf, pagenumber): 14 | """Attach a file to a given pag from a byte array. It is attached at 15 | document level.""" 16 | 17 | def removeAttachedFiles(pdf): 18 | """Remove all page- and document-level attachments from a document.""" 19 | 20 | def getAttachments(pdf): 21 | """List information about attachements. Returns a list of tuples 22 | (name, page number, byte array of data). Page 0 = document-level 23 | attachment.""" 24 | -------------------------------------------------------------------------------- /html_manual/splits/c18.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 17. Creating New PDFs */ 2 | 3 | /* cpdf_blankDocument(width, height, num_pages) creates a blank document with 4 | * pages of the given width (in points), height (in points), and number of 5 | * pages. 6 | */ 7 | int cpdf_blankDocument(double, double, int); 8 | 9 | /* 10 | * cpdf_blankDocumentPaper(papersize, num_pages) makes a blank document given 11 | * a page size and number of pages. 12 | */ 13 | int cpdf_blankDocumentPaper(enum cpdf_papersize, int); 14 | 15 | /* cpdf_textToPDF(w, h, font, fontsize, filename) typesets a UTF8 text file 16 | * ragged right on a page of size w * h in points in the given font and font 17 | * size. */ 18 | int cpdf_textToPDF(double, double, int, double, const char[]); 19 | 20 | /* cpdf_textToPDF(papersize font, fontsize, filename) typesets a UTF8 text file 21 | * ragged right on a page of the given size in the given font and font size. */ 22 | int cpdf_textToPDFPaper(int, int, double, const char[]); 23 | 24 | -------------------------------------------------------------------------------- /docsplits/splits/c17.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 16. Optional Content Groups */ 2 | 3 | /* Begin retrieving optional content group names. The serial number 0..<n - 1> 4 | * is returned. */ 5 | int cpdf_startGetOCGList(int pdf); 6 | 7 | /* Retrieve an OCG name, given its serial number 0..<n - 1>. */ 8 | char *cpdf_OCGListEntry(int i); 9 | 10 | /* End retrieval of optional content group names. */ 11 | void cpdf_endGetOCGList(void); 12 | 13 | /* cpdf_OCGRename(pdf, from, to) will rename an optional content group. */ 14 | void cpdf_OCGRename(int, const char[], const char[]); 15 | 16 | /* Ensure that every optional content group appears in the OCG order list. */ 17 | void cpdf_OCGOrderAll(int); 18 | 19 | /* Coalesce optional content groups. For example, if we merge or stamp two 20 | * files both with an OCG called "Layer 1", we will have two different optional 21 | * content groups. This function will merge the two into a single optional 22 | * content group. */ 23 | void cpdf_OCGCoalesce(int); 24 | 25 | -------------------------------------------------------------------------------- /html_manual/splits/c17.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 16. Optional Content Groups */ 2 | 3 | /* Begin retrieving optional content group names. The serial number 0..<n - 1> 4 | * is returned. */ 5 | int cpdf_startGetOCGList(int pdf); 6 | 7 | /* Retrieve an OCG name, given its serial number 0..<n - 1>. */ 8 | char *cpdf_OCGListEntry(int i); 9 | 10 | /* End retrieval of optional content group names. */ 11 | void cpdf_endGetOCGList(void); 12 | 13 | /* cpdf_OCGRename(pdf, from, to) will rename an optional content group. */ 14 | void cpdf_OCGRename(int, const char[], const char[]); 15 | 16 | /* Ensure that every optional content group appears in the OCG order list. */ 17 | void cpdf_OCGOrderAll(int); 18 | 19 | /* Coalesce optional content groups. For example, if we merge or stamp two 20 | * files both with an OCG called "Layer 1", we will have two different optional 21 | * content groups. This function will merge the two into a single optional 22 | * content group. */ 23 | void cpdf_OCGCoalesce(int); 24 | 25 | -------------------------------------------------------------------------------- /html_manual/pysplits/c03.tex: -------------------------------------------------------------------------------- 1 | # CHAPTER 2. Merging and Splitting 2 | 3 | def mergeSimple(pdfs): 4 | """Given a list of PDFs, merges the documents into a new PDF, which is 5 | returned.""" 6 | 7 | def merge(pdfs, retain_numbering, remove_duplicate_fonts): 8 | """Merges the list of PDFs. If retain_numbering is True page labels are not 9 | rewritten. If remove_duplicate_fonts is True, duplicate fonts are merged. 10 | This is useful when the source documents for merging originate from the 11 | same source.""" 12 | 13 | def mergeSame(pdfs, retain_numbering, remove_duplicate_fonts, ranges): 14 | """The same as merge, except that it has an additional argument 15 | - a list of page ranges. This is used to select the pages to pick from 16 | each PDF. This avoids duplication of information when multiple discrete 17 | parts of a single source PDF are included.""" 18 | 19 | def selectPages(pdf, r): 20 | """ Returns a new document which just those pages in the page range.""" 21 | -------------------------------------------------------------------------------- /cpdfposition.mli: -------------------------------------------------------------------------------- 1 | (** Positions *) 2 | 3 | (** Possible positions for adding text and other uses. See cpdfmanual.pdf *) 4 | type position = 5 | PosCentre of float * float 6 | | PosLeft of float * float 7 | | PosRight of float * float 8 | | Top of float 9 | | TopLeft of float * float 10 | | TopRight of float * float 11 | | Left of float 12 | | BottomLeft of float * float 13 | | Bottom of float 14 | | BottomRight of float * float 15 | | Right of float 16 | | Diagonal 17 | | ReverseDiagonal 18 | | Centre 19 | 20 | (** Produce a debug string of a [position] *) 21 | val string_of_position : position -> string 22 | 23 | (** [calculate_position ignore_d w (xmin, ymin, xmax, ymax) orientation pos] calculates 24 | the absolute position of text given its width, bounding box, orientation and 25 | position. If [ignore_d] is true, the distance from the position (e.g 10 in 26 | TopLeft 10) is ignored (considered zero). *) 27 | val calculate_position : 28 | bool -> 29 | float -> 30 | float * float * float * float -> 31 | position -> float * float * float 32 | -------------------------------------------------------------------------------- /html_manual/splits/c15.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 14. Fonts. */ 2 | 3 | /* 4 | * Retrieving font information. First, call cpdf_startGetFontInfo(pdf). Now 5 | * call cpdf_numberFonts to return the number of fonts. For each font, call 6 | * one or more of cpdf_getFontPage, cpdf_getFontName, cpdf_getFontType, and 7 | * cpdf_getFontEncoding giving a serial number 0..<number of fonts> - 1 to 8 | * return information. Finally, call cpdf_endGetFontInfo to clean up. 9 | */ 10 | void cpdf_startGetFontInfo(int); 11 | int cpdf_numberFonts(void); 12 | int cpdf_getFontPage(int); 13 | char *cpdf_getFontName(int); 14 | char *cpdf_getFontType(int); 15 | char *cpdf_getFontEncoding(int); 16 | void cpdf_endGetFontInfo(void); 17 | 18 | /* cpdf_removeFonts(pdf) removes all font data from a file. */ 19 | void cpdf_removeFonts(int); 20 | 21 | /* 22 | * cpdf_copyFont(from, to, range, pagenumber, fontname) copies the given font 23 | * from the given page in the 'from' PDF to every page in the 'to' PDF. The 24 | * new font is stored under its font name. 25 | */ 26 | void cpdf_copyFont(int, int, int, int, const char[]); 27 | 28 | -------------------------------------------------------------------------------- /docsplits/javascriptsplits/c01.tex: -------------------------------------------------------------------------------- 1 | // CHAPTER 0. Preliminaries 2 | 3 | /** Returns a string giving the version number of the CPDF library. 4 | @returns {string} version */ 5 | function version() {} 6 | 7 | /** Some operations have a fast mode. The default is 'slow' mode, which works 8 | even on old-fashioned files. For more details, see section 1.13 of the CPDF 9 | manual. This function sets the mode to fast globally. */ 10 | function setFast() {} 11 | 12 | /** Some operations have a fast mode. The default is 'slow' mode, which works 13 | even on old-fashioned files. For more details, see section 1.13 of the CPDF 14 | manual. This function sets the mode to slow globally. */ 15 | function setSlow() {} 16 | 17 | /** Delete a PDF so the memory representing it may be recovered. 18 | @arg {pdf} pdf PDF document to delete */ 19 | function deletePdf(pdf) {} 20 | 21 | /* A debug function which prints some information about resource usage. This 22 | can be used to detect if PDFs or ranges are being deallocated properly. 23 | Contrary to its name, it may be run at any time. */ 24 | function onexit() {} 25 | 26 | -------------------------------------------------------------------------------- /html_manual/javascriptsplits/c01.tex: -------------------------------------------------------------------------------- 1 | // CHAPTER 0. Preliminaries 2 | 3 | /** Returns a string giving the version number of the CPDF library. 4 | @returns {string} version */ 5 | function version() {} 6 | 7 | /** Some operations have a fast mode. The default is 'slow' mode, which works 8 | even on old-fashioned files. For more details, see section 1.13 of the CPDF 9 | manual. This function sets the mode to fast globally. */ 10 | function setFast() {} 11 | 12 | /** Some operations have a fast mode. The default is 'slow' mode, which works 13 | even on old-fashioned files. For more details, see section 1.13 of the CPDF 14 | manual. This function sets the mode to slow globally. */ 15 | function setSlow() {} 16 | 17 | /** Delete a PDF so the memory representing it may be recovered. 18 | @arg {pdf} pdf PDF document to delete */ 19 | function deletePdf(pdf) {} 20 | 21 | /* A debug function which prints some information about resource usage. This 22 | can be used to detect if PDFs or ranges are being deallocated properly. 23 | Contrary to its name, it may be run at any time. */ 24 | function onexit() {} 25 | 26 | -------------------------------------------------------------------------------- /docsplits/javasplits/c01.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 0. Preliminaries */ 2 | 3 | /** Initialises the library. Must be called before any other function. */ 4 | public native void startup() throws CpdfError; 5 | 6 | /** Returns a string giving the version number of the Jcpdf library. */ 7 | public native String version() throws CpdfError; 8 | 9 | /** Sets fast mode. Some operations have a fast mode. The default is 'slow' 10 | mode, which works even on old-fashioned files. For more details, see 11 | section 1.13 of the CPDF manual. This functions sets the mode to fast 12 | globally. */ 13 | public native void setFast() throws CpdfError; 14 | 15 | /** Sets slow mode. Some operations have a fast mode. The default is 'slow' 16 | mode, which works even on old-fashioned files. For more details, see 17 | section 1.13 of the CPDF manual. This functions sets the mode to slow 18 | globally. */ 19 | public native void setSlow() throws CpdfError; 20 | 21 | /** Prints some information about 22 | resource usage. This can be used to detect if PDFs or ranges are being 23 | deallocated properly. Contrary to its name, it may be run at any time. */ 24 | public native void onExit(); 25 | -------------------------------------------------------------------------------- /html_manual/javasplits/c01.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 0. Preliminaries */ 2 | 3 | /** Initialises the library. Must be called before any other function. */ 4 | public native void startup() throws CpdfError; 5 | 6 | /** Returns a string giving the version number of the Jcpdf library. */ 7 | public native String version() throws CpdfError; 8 | 9 | /** Sets fast mode. Some operations have a fast mode. The default is 'slow' 10 | mode, which works even on old-fashioned files. For more details, see 11 | section 1.13 of the CPDF manual. This functions sets the mode to fast 12 | globally. */ 13 | public native void setFast() throws CpdfError; 14 | 15 | /** Sets slow mode. Some operations have a fast mode. The default is 'slow' 16 | mode, which works even on old-fashioned files. For more details, see 17 | section 1.13 of the CPDF manual. This functions sets the mode to slow 18 | globally. */ 19 | public native void setSlow() throws CpdfError; 20 | 21 | /** Prints some information about 22 | resource usage. This can be used to detect if PDFs or ranges are being 23 | deallocated properly. Contrary to its name, it may be run at any time. */ 24 | public native void onExit(); 25 | -------------------------------------------------------------------------------- /docsplits/dotnetsplits/cm1.tex: -------------------------------------------------------------------------------- 1 | CPDF .NET Library 2 | ================= 3 | 4 | Before using the library, you must make sure your project or build environment 5 | has access to the cpdf DLL, which is not part of the .NET assembly. You can add 6 | it to a Visual Studio project as a file, set to copy-to-output-folder. Or, you 7 | can install it in a standard location. The DLL must be named as follows, for 8 | .NET to be able to find it: 9 | 10 | Windows: cpdf.dll 11 | MacOS: libcpdf.dylib 12 | Linux: libcpdf.so 13 | 14 | The following documentation is automatically extracted from the XML comments 15 | present in the assembly. You can use Intellisense to view them within Visual 16 | Studio - the documentation here is for completeness. 17 | 18 | A 'range' is a list of integers specifying page numbers. 19 | 20 | Text arguments and results are in UTF8. Data is of type bytes[]. 21 | 22 | Any function may raise the exception CPDFError, carrying a string describing 23 | the error. 24 | 25 | There is no automatic garbage collection of PDFs. Use the Using keyword and/or 26 | the Dispose method on objects of type Cpdf.Pdf to explicitly deallocate PDFs. 27 | 28 | 29 | -------------------------------------------------------------------------------- /html_manual/dotnetsplits/cm1.tex: -------------------------------------------------------------------------------- 1 | CPDF .NET Library 2 | ================= 3 | 4 | Before using the library, you must make sure your project or build environment 5 | has access to the cpdf DLL, which is not part of the .NET assembly. You can add 6 | it to a Visual Studio project as a file, set to copy-to-output-folder. Or, you 7 | can install it in a standard location. The DLL must be named as follows, for 8 | .NET to be able to find it: 9 | 10 | Windows: cpdf.dll 11 | MacOS: libcpdf.dylib 12 | Linux: libcpdf.so 13 | 14 | The following documentation is automatically extracted from the XML comments 15 | present in the assembly. You can use Intellisense to view them within Visual 16 | Studio - the documentation here is for completeness. 17 | 18 | A 'range' is a list of integers specifying page numbers. 19 | 20 | Text arguments and results are in UTF8. Data is of type bytes[]. 21 | 22 | Any function may raise the exception CPDFError, carrying a string describing 23 | the error. 24 | 25 | There is no automatic garbage collection of PDFs. Use the Using keyword and/or 26 | the Dispose method on objects of type Cpdf.Pdf to explicitly deallocate PDFs. 27 | 28 | 29 | -------------------------------------------------------------------------------- /cpdftruetype.mli: -------------------------------------------------------------------------------- 1 | (** Parse and subset TrueType fonts *) 2 | 3 | (** The type of a single parsed font, including everything needed to build a PDF font. *) 4 | type t = 5 | {flags : int; 6 | minx : int; 7 | miny : int; 8 | maxx : int; 9 | maxy : int; 10 | italicangle : int; 11 | ascent : int; 12 | descent : int; 13 | capheight : int; 14 | stemv : int; 15 | xheight : int; 16 | avgwidth : int; 17 | maxwidth : int; 18 | firstchar : int; 19 | lastchar : int; 20 | widths : int array; 21 | subset_fontfile : Pdfio.bytes; 22 | subset : int list; 23 | tounicode : (int, string) Hashtbl.t option} 24 | 25 | (** Parse the given TrueType font file. It will return one or more fonts. The 26 | first, a plain Latin font in the given encoding. Others are for the 27 | additional characters in the font. You should supply a subset (a list of 28 | unicode codepoints whose corresponding glyphs are required). *) 29 | val parse : subset:int list -> Pdfio.bytes -> Pdftext.encoding -> t list 30 | 31 | (** Return the list of cmaps from a font file (used for PDF/UA verification). *) 32 | val cmaps : Pdfio.bytes -> (int * int) list 33 | -------------------------------------------------------------------------------- /cpdfattach.mli: -------------------------------------------------------------------------------- 1 | (** File Attachments *) 2 | type t = 3 | {name : string; 4 | pagenumber : int; 5 | data : unit -> Pdfio.bytes; 6 | description : string option; 7 | relationship : string option} 8 | 9 | (** Remove characters which might not make good filenames from a UTF8 string. *) 10 | val remove_unsafe_characters : string -> string 11 | 12 | (** [attach_file keepversion topage pdf relationship description filename] attaches the file in 13 | [filename] to the pdf, optionally to a page (rather than document-level). 14 | If keepversion is true, the PDF version number won't be altered. *) 15 | val attach_file : ?memory:Pdfio.bytes -> bool -> int option -> Pdf.t -> string option -> string option -> string -> Pdf.t 16 | 17 | (** Remove attached files. *) 18 | val remove_attached_files : Pdf.t -> Pdf.t 19 | 20 | (** List attached files. Attachment name and page number. Page 0 is document level. *) 21 | val list_attached_files : Pdf.t -> t list 22 | 23 | (** Dump attached files to a given directory. *) 24 | val dump_attached_files : Pdf.t -> string -> unit 25 | 26 | (** Total size in bytes of all attached files. *) 27 | val size_attached_files : Pdf.t -> int 28 | -------------------------------------------------------------------------------- /cpdftype.mli: -------------------------------------------------------------------------------- 1 | (** Experimental typesetter for cpdf *) 2 | type element = 3 | Text of char list 4 | | HGlue of float 5 | | VGlue of float 6 | | NewLine 7 | | NewPage 8 | | Font of string * Pdftext.font * float 9 | | BeginDest of Pdfdest.t * string option 10 | | EndDest 11 | | BeginDocument 12 | | Tag of string * int 13 | | EndTag 14 | 15 | type t = element list 16 | 17 | (** Debug printing *) 18 | val to_string : t -> string 19 | 20 | (** Return the font width table for a given (id, font, fontsize) combination. *) 21 | val font_widths : string -> Pdftext.font -> float -> float array 22 | 23 | (** Calculate the widths of a string given a font width table, and list of char codes *) 24 | val width_of_string : float array -> char list -> float 25 | 26 | (** [typeset process_struct_tree lmargin rmargin tmargin bmargin papersize pdf contents] builds a 27 | list of pages of typset content. *) 28 | val typeset : process_struct_tree:bool -> float -> float -> float -> float -> Pdfpaper.t -> Pdf.t -> t -> Pdfpage.t list * (string * int) list list 29 | 30 | (** Add artifact markers to any un-marked part of the content stream. *) 31 | val add_artifacts : Pdfops.t list -> Pdfops.t list 32 | -------------------------------------------------------------------------------- /docsplits/splitjs: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | csplit -k -f javascriptsplits/c ../../coherentpdf.js/cpdfdocs.js '/CHAPTER/' {19} 3 | mv javascriptsplits/c00 javascriptsplits/c00.tex 4 | mv javascriptsplits/c01 javascriptsplits/c01.tex 5 | mv javascriptsplits/c02 javascriptsplits/c02.tex 6 | mv javascriptsplits/c03 javascriptsplits/c03.tex 7 | mv javascriptsplits/c04 javascriptsplits/c04.tex 8 | mv javascriptsplits/c05 javascriptsplits/c05.tex 9 | mv javascriptsplits/c06 javascriptsplits/c06.tex 10 | mv javascriptsplits/c07 javascriptsplits/c07.tex 11 | mv javascriptsplits/c08 javascriptsplits/c08.tex 12 | mv javascriptsplits/c09 javascriptsplits/c09.tex 13 | mv javascriptsplits/c10 javascriptsplits/c10.tex 14 | mv javascriptsplits/c11 javascriptsplits/c11.tex 15 | mv javascriptsplits/c12 javascriptsplits/c12.tex 16 | mv javascriptsplits/c13 javascriptsplits/c13.tex 17 | mv javascriptsplits/c14 javascriptsplits/c14.tex 18 | mv javascriptsplits/c15 javascriptsplits/c15.tex 19 | mv javascriptsplits/c16 javascriptsplits/c16.tex 20 | mv javascriptsplits/c17 javascriptsplits/c17.tex 21 | mv javascriptsplits/c18 javascriptsplits/c18.tex 22 | mv javascriptsplits/c19 javascriptsplits/c19.tex 23 | mv javascriptsplits/c20 javascriptsplits/c20.tex 24 | -------------------------------------------------------------------------------- /docsplits/splits/c03.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 2. Merging and Splitting */ 2 | 3 | /* 4 | * cpdf_mergeSimple(pdfs, length) given an array of PDFs, and its length, 5 | * merges the files into a new one, which is returned. 6 | */ 7 | int cpdf_mergeSimple(int *, int); 8 | 9 | /* 10 | * cpdf_merge(pdfs, len, retain_numbering, remove_duplicate_fonts) merges the 11 | * PDFs. If retain_numbering is true page labels are not rewritten. If 12 | * remove_duplicate_fonts is true, duplicate fonts are merged. This is useful 13 | * when the source documents for merging originate from the same source. 14 | */ 15 | int cpdf_merge(int *, int, int, int); 16 | 17 | /* 18 | * cpdf_mergeSame(pdfs, len, retain_numbering, remove_duplicate_fonts, 19 | * ranges) is the same as cpdf_merge, except that it has an additional 20 | * argument - an array of page ranges. This is used to select the pages to 21 | * pick from each PDF. This avoids duplication of information when multiple 22 | * discrete parts of a source PDF are included. 23 | */ 24 | int cpdf_mergeSame(int *, int, int, int, int *); 25 | 26 | /* 27 | * cpdf_selectPages(pdf, range) returns a new document which just those pages 28 | * in the page range. 29 | */ 30 | int cpdf_selectPages(int, int); 31 | 32 | -------------------------------------------------------------------------------- /html_manual/splits/c03.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 2. Merging and Splitting */ 2 | 3 | /* 4 | * cpdf_mergeSimple(pdfs, length) given an array of PDFs, and its length, 5 | * merges the files into a new one, which is returned. 6 | */ 7 | int cpdf_mergeSimple(int *, int); 8 | 9 | /* 10 | * cpdf_merge(pdfs, len, retain_numbering, remove_duplicate_fonts) merges the 11 | * PDFs. If retain_numbering is true page labels are not rewritten. If 12 | * remove_duplicate_fonts is true, duplicate fonts are merged. This is useful 13 | * when the source documents for merging originate from the same source. 14 | */ 15 | int cpdf_merge(int *, int, int, int); 16 | 17 | /* 18 | * cpdf_mergeSame(pdfs, len, retain_numbering, remove_duplicate_fonts, 19 | * ranges) is the same as cpdf_merge, except that it has an additional 20 | * argument - an array of page ranges. This is used to select the pages to 21 | * pick from each PDF. This avoids duplication of information when multiple 22 | * discrete parts of a source PDF are included. 23 | */ 24 | int cpdf_mergeSame(int *, int, int, int, int *); 25 | 26 | /* 27 | * cpdf_selectPages(pdf, range) returns a new document which just those pages 28 | * in the page range. 29 | */ 30 | int cpdf_selectPages(int, int); 31 | 32 | -------------------------------------------------------------------------------- /docsplits/javascriptsplits/c17.tex: -------------------------------------------------------------------------------- 1 | // CHAPTER 16. Optional Content Groups 2 | 3 | /** Begins retrieving optional content group names. The number of entries is returned. 4 | @arg {pdf} pdf PDF document 5 | @return {number} number of entries */ 6 | function startGetOCGList(pdf) {} 7 | 8 | /** Retrieves an OCG name, given its serial number 0..n - 1. 9 | @arg {number} n serial number 10 | @return {string} OCG name */ 11 | function ocgListEntry(n) {} 12 | 13 | /** Ends retrieval of optional content group names. */ 14 | function endGetOCGList() {} 15 | 16 | /** Renames an optional content group. 17 | @arg {pdf} pdf PDF document 18 | @arg {string} name_from source name 19 | @arg {string} name_to destination name */ 20 | function ocgRename(pdf, name_from, name_to) {} 21 | 22 | /** Ensures that every optional content group appears in the OCG order list. 23 | @arg {pdf} pdf PDF document */ 24 | function ocgOrderAll(pdf) {} 25 | 26 | /** Coalesces optional content groups. For example, if we merge or stamp two 27 | files both with an OCG called "Layer 1", we will have two different optional 28 | content groups. This function will merge the two into a single optional 29 | content group. 30 | @arg {pdf} pdf PDF document */ 31 | function ocgCoalesce(pdf) {} 32 | 33 | -------------------------------------------------------------------------------- /docsplits/splits/c15.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 14. Fonts. */ 2 | 3 | /* 4 | * Retrieving font information. First, call cpdf_startGetFontInfo(pdf). Now 5 | * call cpdf_numberFonts to return the number of fonts. For each font, call 6 | * one or more of cpdf_getFontPage, cpdf_getFontName, cpdf_getFontType, and 7 | * cpdf_getFontEncoding giving a serial number 0..<number of fonts> - 1 to 8 | * return information. Finally, call cpdf_endGetFontInfo to clean up. 9 | */ 10 | void cpdf_startGetFontInfo(int); 11 | int cpdf_numberFonts(void); 12 | int cpdf_getFontPage(int); 13 | char *cpdf_getFontName(int); 14 | char *cpdf_getFontType(int); 15 | char *cpdf_getFontEncoding(int); 16 | void cpdf_endGetFontInfo(void); 17 | 18 | /* cpdf_fontsJSON(pdf, size) returns JSON data for the font list, and fills 19 | * in the return length. */ 20 | void *cpdf_fontsJSON(int, int *); 21 | 22 | /* cpdf_removeFonts(pdf) removes all font data from a file. */ 23 | void cpdf_removeFonts(int); 24 | 25 | /* 26 | * cpdf_copyFont(from, to, range, pagenumber, fontname) copies the given font 27 | * from the given page in the 'from' PDF to every page in the 'to' PDF. The 28 | * new font is stored under its font name. 29 | */ 30 | void cpdf_copyFont(int, int, int, int, const char[]); 31 | 32 | -------------------------------------------------------------------------------- /html_manual/javascriptsplits/c17.tex: -------------------------------------------------------------------------------- 1 | // CHAPTER 16. Optional Content Groups 2 | 3 | /** Begins retrieving optional content group names. The number of entries is returned. 4 | @arg {pdf} pdf PDF document 5 | @return {number} number of entries */ 6 | function startGetOCGList(pdf) {} 7 | 8 | /** Retrieves an OCG name, given its serial number 0..n - 1. 9 | @arg {number} n serial number 10 | @return {string} OCG name */ 11 | function ocgListEntry(n) {} 12 | 13 | /** Ends retrieval of optional content group names. */ 14 | function endGetOCGList() {} 15 | 16 | /** Renames an optional content group. 17 | @arg {pdf} pdf PDF document 18 | @arg {string} name_from source name 19 | @arg {string} name_to destination name */ 20 | function ocgRename(pdf, name_from, name_to) {} 21 | 22 | /** Ensures that every optional content group appears in the OCG order list. 23 | @arg {pdf} pdf PDF document */ 24 | function ocgOrderAll(pdf) {} 25 | 26 | /** Coalesces optional content groups. For example, if we merge or stamp two 27 | files both with an OCG called "Layer 1", we will have two different optional 28 | content groups. This function will merge the two into a single optional 29 | content group. 30 | @arg {pdf} pdf PDF document */ 31 | function ocgCoalesce(pdf) {} 32 | 33 | -------------------------------------------------------------------------------- /docsplits/javasplits/c17.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 16. Optional Content Groups */ 2 | 3 | /** Begins retrieving optional content group names. The serial number 4 | <code>0..n - 1</code> is returned. */ 5 | public native int startGetOCGList(Pdf pdf) throws CpdfError; 6 | 7 | /** Retrieves an entry in the optional content group list, given the serial 8 | number <code>0..n - 1</code>. */ 9 | public native String OCGListEntry(int serial) throws CpdfError; 10 | 11 | /** Ends retrieval of optional content group names. */ 12 | public native void endGetOCGList() throws CpdfError; 13 | 14 | /** Renames an optional content group. 15 | @param pdf PDF document 16 | @param f name to rename from 17 | @param t name to rename to */ 18 | public native void OCGRename(Pdf pdf, String f, String t) throws CpdfError; 19 | 20 | /** Ensures that every optional content group appears in the OCG order 21 | list. */ 22 | public native void OCGOrderAll(Pdf pdf) throws CpdfError; 23 | 24 | /** Coalesces optional content groups. For example, if we merge or stamp 25 | two files both with an OCG called "Layer 1", we will have two different 26 | optional content groups. This function will merge the two into a single 27 | optional content group. */ 28 | public native void OCGCoalesce(Pdf pdf) throws CpdfError; 29 | -------------------------------------------------------------------------------- /html_manual/javasplits/c17.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 16. Optional Content Groups */ 2 | 3 | /** Begins retrieving optional content group names. The serial number 4 | <code>0..n - 1</code> is returned. */ 5 | public native int startGetOCGList(Pdf pdf) throws CpdfError; 6 | 7 | /** Retrieves an entry in the optional content group list, given the serial 8 | number <code>0..n - 1</code>. */ 9 | public native String OCGListEntry(int serial) throws CpdfError; 10 | 11 | /** Ends retrieval of optional content group names. */ 12 | public native void endGetOCGList() throws CpdfError; 13 | 14 | /** Renames an optional content group. 15 | @param pdf PDF document 16 | @param f name to rename from 17 | @param t name to rename to */ 18 | public native void OCGRename(Pdf pdf, String f, String t) throws CpdfError; 19 | 20 | /** Ensures that every optional content group appears in the OCG order 21 | list. */ 22 | public native void OCGOrderAll(Pdf pdf) throws CpdfError; 23 | 24 | /** Coalesces optional content groups. For example, if we merge or stamp 25 | two files both with an OCG called "Layer 1", we will have two different 26 | optional content groups. This function will merge the two into a single 27 | optional content group. */ 28 | public native void OCGCoalesce(Pdf pdf) throws CpdfError; 29 | -------------------------------------------------------------------------------- /cpdfjson.mli: -------------------------------------------------------------------------------- 1 | (** Read and write PDFs in CPDFJSON format *) 2 | 3 | (** Write a PDF in CPDFJSON format. [parse_content] parses page content 4 | streams, [no_stream_data] will omit stream data, [decompress_streams] 5 | decompresses all streams, [clean_strings] will convert any UTF16BE strings 6 | to PDFDocEncoding if it can. If [utf8] is set, CPDFJSON UTF8 format is used 7 | instead. *) 8 | val to_output : Pdfio.output -> utf8:bool -> parse_content:bool -> no_stream_data:bool -> decompress_streams:bool -> ?clean_strings:bool -> Pdf.t -> unit 9 | 10 | (** Read a CPDFJSON PDF from an input. /Length entries will be corrected automatically. *) 11 | val of_input : Pdfio.input -> Pdf.t 12 | 13 | (** Convert a single PDF object to CPDFJSON format. [clean_strings] and [utf8] are as above. 14 | Then the PDF file, then a function which is usually [function _ -> ()], then 15 | [no_stream_data] as above, then [parse_content_streams] as above, and 16 | finally the object itself. *) 17 | val json_of_object : utf8:bool -> ?clean_strings:bool -> Pdf.t -> (int -> unit) -> no_stream_data:bool -> parse_content:bool -> Pdf.pdfobject -> Cpdfyojson.Safe.t 18 | 19 | (** Convert a single CPDFJSON object to a PDF object *) 20 | val object_of_json : Cpdfyojson.Safe.t -> Pdf.pdfobject 21 | -------------------------------------------------------------------------------- /docsplits/javasplits/cm1.tex: -------------------------------------------------------------------------------- 1 | Jcpdf: Java interface to the cpdf PDF tools 2 | =========================================== 3 | 4 | The DLLs "libcpdf" and "libjcpdf" are required. 5 | 6 | Before using the library, you must make sure your project or build environment 7 | has access to the cpdf DLL, which is not part of the Java .jar. You can add as 8 | am external requirement in your Java IDE. Or, you can install it in a standard 9 | location, such as the Windows system folder. 10 | 11 | On Windows, The DLL libcpdf.dll must be renamed to cpdf.dll, for Jcpdf to be 12 | able to find it. 13 | 14 | Follow the instructions at the end of Chapter 1 to write your first program. In 15 | addition, the Jcpdf package provides documentation with each function, which 16 | you can view in your IDE. 17 | 18 | Usage 19 | ----- 20 | 21 | Create an instance of the library with, for example: 22 | 23 | Jcpdf.jcpdf = new Jcpdf() 24 | 25 | You must call startup() to initialise the library prior to calling any other 26 | function. 27 | 28 | PDFs are of type Jcpdf.Pdf. Page ranges are of type Jcpdf.Range. Both PDFs and 29 | ranges are not automatically garbage-collected. Use try or the close() method 30 | to dispose of them. 31 | 32 | Exceptions are of type Jcpdf.CpdfError and may be raised by any function. 33 | -------------------------------------------------------------------------------- /html_manual/javasplits/cm1.tex: -------------------------------------------------------------------------------- 1 | Jcpdf: Java interface to the cpdf PDF tools 2 | =========================================== 3 | 4 | The DLLs "libcpdf" and "libjcpdf" are required. 5 | 6 | Before using the library, you must make sure your project or build environment 7 | has access to the cpdf DLL, which is not part of the Java .jar. You can add as 8 | am external requirement in your Java IDE. Or, you can install it in a standard 9 | location, such as the Windows system folder. 10 | 11 | On Windows, The DLL libcpdf.dll must be renamed to cpdf.dll, for Jcpdf to be 12 | able to find it. 13 | 14 | Follow the instructions at the end of Chapter 1 to write your first program. In 15 | addition, the Jcpdf package provides documentation with each function, which 16 | you can view in your IDE. 17 | 18 | Usage 19 | ----- 20 | 21 | Create an instance of the library with, for example: 22 | 23 | Jcpdf.jcpdf = new Jcpdf() 24 | 25 | You must call startup() to initialise the library prior to calling any other 26 | function. 27 | 28 | PDFs are of type Jcpdf.Pdf. Page ranges are of type Jcpdf.Range. Both PDFs and 29 | ranges are not automatically garbage-collected. Use try or the close() method 30 | to dispose of them. 31 | 32 | Exceptions are of type Jcpdf.CpdfError and may be raised by any function. 33 | -------------------------------------------------------------------------------- /docsplits/dotnetsplits/c01.tex: -------------------------------------------------------------------------------- 1 | CHAPTER 0. Preliminaries 2 | 3 | Cpdf.startup 4 | 5 | Initialises the library. Must be called before any other function. 6 | 7 | Cpdf.version 8 | 9 | Returns a string giving the version number of the CPDF library. 10 | 11 | Cpdf.setFast 12 | 13 | Some operations have a fast mode. The default is 'slow' mode, which works even 14 | on old-fashioned files. For more details, see section 1.13 of the CPDF manual. 15 | This function sets the mode to fast globally. 16 | 17 | Cpdf.setSlow 18 | 19 | Some operations have a fast mode. The default is 'slow' mode, which works even 20 | on old-fashioned files. For more details, see section 1.13 of the CPDF manual. 21 | This functions sets the mode to slow globally. 22 | 23 | Cpdf.lastError 24 | 25 | Not to be called directly. Errors in .NET cpdf are raised by exceptions. 26 | 27 | Cpdf.lastErrorString 28 | 29 | Not to be called directly. Errors in .NET cpdf are raised by exceptions. 30 | 31 | Cpdf.clearError 32 | 33 | Not to be called directly. Errors in .NET cpdf are raised by exceptions. 34 | 35 | Cpdf.onExit 36 | 37 | A debug function which prints some information about resource usage. This can 38 | be used to detect if PDFs or ranges are being deallocated properly. Contrary to 39 | its name, it may be run at any time. 40 | -------------------------------------------------------------------------------- /docsplits/javasplits/c16.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 15. PDF and JSON */ 2 | 3 | /** Outputs a PDF in JSON format to the given filename. 4 | @param filename file name 5 | @param parse_content parse page content 6 | @param no_stream_data all stream data is suppressed entirely 7 | @param decompress_streams streams are decompressed 8 | @param pdf PDF document */ 9 | public void outputJSON(String filename, boolean parse_content, 10 | boolean no_stream_data, boolean decompress_streams, 11 | Pdf pdf) 12 | throws CpdfError; 13 | 14 | /** Like outputJSON, but it writes to a byte array in memory. 15 | @param pdf PDF document 16 | @param parse_content parse page content 17 | @param no_stream_data all stream data is suppressed entirely 18 | @param decompress_streams streams are decompressed */ 19 | public native byte[] outputJSONMemory(Pdf pdf, boolean parse_content, 20 | boolean no_stream_data, 21 | boolean decompress_streams) 22 | throws CpdfError; 23 | 24 | /** Loads a PDF from a JSON file given its filename. */ 25 | public Pdf fromJSON(String filename) throws CpdfError; 26 | 27 | /** Loads a PDF from a JSON file in memory. */ 28 | public native Pdf fromJSONMemory(byte[] data) throws CpdfError; 29 | -------------------------------------------------------------------------------- /html_manual/dotnetsplits/c01.tex: -------------------------------------------------------------------------------- 1 | CHAPTER 0. Preliminaries 2 | 3 | Cpdf.startup 4 | 5 | Initialises the library. Must be called before any other function. 6 | 7 | Cpdf.version 8 | 9 | Returns a string giving the version number of the CPDF library. 10 | 11 | Cpdf.setFast 12 | 13 | Some operations have a fast mode. The default is 'slow' mode, which works even 14 | on old-fashioned files. For more details, see section 1.13 of the CPDF manual. 15 | This function sets the mode to fast globally. 16 | 17 | Cpdf.setSlow 18 | 19 | Some operations have a fast mode. The default is 'slow' mode, which works even 20 | on old-fashioned files. For more details, see section 1.13 of the CPDF manual. 21 | This functions sets the mode to slow globally. 22 | 23 | Cpdf.lastError 24 | 25 | Not to be called directly. Errors in .NET cpdf are raised by exceptions. 26 | 27 | Cpdf.lastErrorString 28 | 29 | Not to be called directly. Errors in .NET cpdf are raised by exceptions. 30 | 31 | Cpdf.clearError 32 | 33 | Not to be called directly. Errors in .NET cpdf are raised by exceptions. 34 | 35 | Cpdf.onExit 36 | 37 | A debug function which prints some information about resource usage. This can 38 | be used to detect if PDFs or ranges are being deallocated properly. Contrary to 39 | its name, it may be run at any time. 40 | -------------------------------------------------------------------------------- /html_manual/javasplits/c16.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 15. PDF and JSON */ 2 | 3 | /** Outputs a PDF in JSON format to the given filename. 4 | @param filename file name 5 | @param parse_content parse page content 6 | @param no_stream_data all stream data is suppressed entirely 7 | @param decompress_streams streams are decompressed 8 | @param pdf PDF document */ 9 | public void outputJSON(String filename, boolean parse_content, 10 | boolean no_stream_data, boolean decompress_streams, 11 | Pdf pdf) 12 | throws CpdfError; 13 | 14 | /** Like outputJSON, but it writes to a byte array in memory. 15 | @param pdf PDF document 16 | @param parse_content parse page content 17 | @param no_stream_data all stream data is suppressed entirely 18 | @param decompress_streams streams are decompressed */ 19 | public native byte[] outputJSONMemory(Pdf pdf, boolean parse_content, 20 | boolean no_stream_data, 21 | boolean decompress_streams) 22 | throws CpdfError; 23 | 24 | /** Loads a PDF from a JSON file given its filename. */ 25 | public Pdf fromJSON(String filename) throws CpdfError; 26 | 27 | /** Loads a PDF from a JSON file in memory. */ 28 | public native Pdf fromJSONMemory(byte[] data) throws CpdfError; 29 | -------------------------------------------------------------------------------- /cpdffont.mli: -------------------------------------------------------------------------------- 1 | (** Fonts *) 2 | 3 | (** {2 Listing fonts} *) 4 | 5 | (** Print font list to stdout *) 6 | val print_fonts : ?json:bool -> Pdf.t -> int list -> unit 7 | 8 | (** Return font list. Page number, name, subtype, basefont, encoding, font (direct). *) 9 | val list_fonts : Pdf.t -> int list -> (int * string * string * string * string * Pdf.pdfobject) list 10 | 11 | (** Return font list in JSON format *) 12 | val json_fonts : Pdf.t -> int list -> Cpdfyojson.Safe.t 13 | 14 | (** {2 Miscellany} *) 15 | 16 | (** Embed missing fonts *) 17 | val embed_missing_fonts : string -> bool -> string -> string -> unit 18 | 19 | (** Copy a font *) 20 | val copy_font : Pdf.t -> string -> int -> int list -> Pdf.t -> Pdf.t 21 | 22 | (** Report missing fonts *) 23 | val missing_fonts : ?l:(int * string * string * string * string) list ref -> Pdf.t -> int list -> unit 24 | 25 | (** Return missing fonts *) 26 | val missing_fonts_return : Pdf.t -> int list -> (int * string * string * string * string) list 27 | 28 | (** Print a font table to Standard Output. *) 29 | val print_font_table : Pdf.t -> string -> int -> unit 30 | 31 | (** Extract a font file to disk. *) 32 | val extract_fontfile : int -> string -> string -> Pdf.t -> unit 33 | 34 | (** Remove fonts from a document. *) 35 | val remove_fonts : Pdf.t -> Pdf.t 36 | -------------------------------------------------------------------------------- /cpdfembed.mli: -------------------------------------------------------------------------------- 1 | (** Embed a TrueType font in a PDF *) 2 | 3 | (* Embed a TrueType font for the given set of unicode codepoints in the given 4 | encoding, adding the fontfiles to the PDF and returning a list of font objects, 5 | together with a unicode codepoint --> (font number in list, charcode) table *) 6 | 7 | type t = Pdftext.font list * (int, int * int) Hashtbl.t 8 | 9 | type cpdffont = 10 | PreMadeFontPack of t 11 | | EmbedInfo of {fontfile : Pdfio.bytes; fontname : string; encoding : Pdftext.encoding} 12 | | ExistingNamedFont 13 | 14 | (** Build a fontpack for a Standard 14 font *) 15 | val fontpack_of_standardfont : Pdftext.font -> t 16 | 17 | (** Look up a unicode codepoint in a font page. Returns (charcode, fontnumber, font) *) 18 | val get_char : t -> int -> (int * int * Pdftext.font) option 19 | 20 | (** Build a fontpack from a TrueType font and list of codepoints, embedding its fonts in the document *) 21 | val embed_truetype : 22 | Pdf.t -> fontfile:Pdfio.bytes -> fontname:string -> codepoints:int list -> 23 | encoding:Pdftext.encoding -> t 24 | 25 | (** Collate outputs of [get_char] with like font *) 26 | val collate_runs : ('a * 'b * 'c) list -> ('a * 'b * 'c) list list 27 | 28 | (** Load substitute Standard 14 font *) 29 | val load_substitute : string -> Pdftext.standard_font -> Pdfio.bytes * string 30 | -------------------------------------------------------------------------------- /docsplits/javasplits/c14.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 13. Images. */ 2 | 3 | /** Gets image data, including resolution at all points of use. Call 4 | {@link #startGetImageResolution(pdf, double) startGetImageResolution(pdf, 5 | min_required_resolution)} to begin the process of obtaining data on all 6 | image uses below <code>min_required_resolution</code>, returning the total 7 | number. So, to return all image uses, specify a very high 8 | <code>min_required_resolution</code>. Then, call the other functions giving 9 | a serial number <code>0...n - 1</code>, to retrieve the data. Finally, call 10 | {@link #endGetImageResolution() endGetImageResolution} to clean up. */ 11 | public native int startGetImageResolution(Pdf pdf, double res) 12 | throws CpdfError; 13 | 14 | public native int getImageResolutionPageNumber(int serial) 15 | throws CpdfError; 16 | 17 | public native String getImageResolutionImageName(int serial) 18 | throws CpdfError; 19 | 20 | public native int getImageResolutionXPixels(int serial) throws CpdfError; 21 | 22 | public native int getImageResolutionYPixels(int serial) throws CpdfError; 23 | 24 | public native double getImageResolutionXRes(int serial) throws CpdfError; 25 | 26 | public native double getImageResolutionYRes(int serial) throws CpdfError; 27 | 28 | public native void endGetImageResolution() throws CpdfError; 29 | -------------------------------------------------------------------------------- /html_manual/javasplits/c14.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 13. Images. */ 2 | 3 | /** Gets image data, including resolution at all points of use. Call 4 | {@link #startGetImageResolution(pdf, double) startGetImageResolution(pdf, 5 | min_required_resolution)} to begin the process of obtaining data on all 6 | image uses below <code>min_required_resolution</code>, returning the total 7 | number. So, to return all image uses, specify a very high 8 | <code>min_required_resolution</code>. Then, call the other functions giving 9 | a serial number <code>0...n - 1</code>, to retrieve the data. Finally, call 10 | {@link #endGetImageResolution() endGetImageResolution} to clean up. */ 11 | public native int startGetImageResolution(Pdf pdf, double res) 12 | throws CpdfError; 13 | 14 | public native int getImageResolutionPageNumber(int serial) 15 | throws CpdfError; 16 | 17 | public native String getImageResolutionImageName(int serial) 18 | throws CpdfError; 19 | 20 | public native int getImageResolutionXPixels(int serial) throws CpdfError; 21 | 22 | public native int getImageResolutionYPixels(int serial) throws CpdfError; 23 | 24 | public native double getImageResolutionXRes(int serial) throws CpdfError; 25 | 26 | public native double getImageResolutionYRes(int serial) throws CpdfError; 27 | 28 | public native void endGetImageResolution() throws CpdfError; 29 | -------------------------------------------------------------------------------- /cpdfua.mli: -------------------------------------------------------------------------------- 1 | (** PDF/UA *) 2 | 3 | type subformat = 4 | | PDFUA1 5 | | PDFUA2 6 | 7 | (** Parse PDF/UA-1 and PDF/UA-2 to the subformat type. *) 8 | val subformat_of_string : string -> subformat 9 | 10 | (** Print matterhorn test results ("" = all tests) *) 11 | val test_matterhorn_print : Pdf.t -> string -> unit 12 | 13 | (** Return JSON results of a matterhorn test ("" = all tests *) 14 | val test_matterhorn_json : Pdf.t -> string -> Cpdfyojson.Safe.t 15 | 16 | (** Mark PDF as PDF/UA-1 compliant. *) 17 | val mark : Pdf.t -> unit 18 | 19 | (** Mark PDF as PDF/UA-2 compliant. *) 20 | val mark2 : int -> Pdf.t -> unit 21 | 22 | (** Remove any PDF/UA-* marker *) 23 | val remove_mark : Pdf.t -> unit 24 | 25 | (** Print the structure tree to standard output, graphically. *) 26 | val print_struct_tree : Pdf.t -> unit 27 | 28 | (** Extract structure tree to JSON *) 29 | val extract_struct_tree : Pdf.t -> Cpdfyojson.Safe.t 30 | 31 | (** Reapply an edited JSON structure tree to its PDF. *) 32 | val replace_struct_tree : Pdf.t -> Cpdfyojson.Safe.t -> unit 33 | 34 | (** Make a blank PDF/UA-1 PDF given a title, paper size, and number of pages. *) 35 | val create_pdfua1 : string -> Pdfpaper.t -> int -> Pdf.t 36 | 37 | (** Make a blank PDF/UA-2 PDF given a title, paper size, and number of pages. *) 38 | val create_pdfua2 : string -> Pdfpaper.t -> int -> Pdf.t 39 | -------------------------------------------------------------------------------- /docsplits/javascriptsplits/c00.tex: -------------------------------------------------------------------------------- 1 | // CHAPTER -1: Introduction 2 | 3 | /** 4 | Use 5 | --- 6 | 7 | coherentpdf.js can be used from both node and the browser. 8 | 9 | The file `cpdflibtest.js` uses every function in coherentpdf.js. Call `./run` 10 | to run it in node. 11 | 12 | For development server-side with node: `coherentpdf.js` (minified version 13 | `coherentpdf.min.js`). Load with `const coherentpdf = require('coherentpdf')` 14 | if installed in npm, or `const coherentpdf = require('./coherentpdf.js')` to 15 | load from current directory. 16 | 17 | For development client-side with the browser : `coherentpdf.browser.js` 18 | (minified version for deployment : `coherentpdf.browser.min.js`). Load with 19 | `<script src="coherentpdf.browser.js"></script>` or similar. 20 | 21 | 22 | Data types 23 | ---------- 24 | 25 | Arguments are numbers, strings, or arrays (of type UInt8Array for data). Page 26 | ranges are represented by arrays of numbers. 27 | 28 | 29 | Memory Management 30 | ----------------- 31 | 32 | A PDF p must be explicitly deallocated with deletePdf(p). 33 | 34 | 35 | Errors 36 | ------ 37 | 38 | Any function may raise an exception, containing a string describing the problem. 39 | 40 | 41 | Concurrency 42 | ----------- 43 | 44 | coherentpdf.js is synchronous and non-re-entrant. In the browser, best used in a worker. 45 | **/ 46 | 47 | -------------------------------------------------------------------------------- /html_manual/javascriptsplits/c00.tex: -------------------------------------------------------------------------------- 1 | // CHAPTER -1: Introduction 2 | 3 | /** 4 | Use 5 | --- 6 | 7 | coherentpdf.js can be used from both node and the browser. 8 | 9 | The file `cpdflibtest.js` uses every function in coherentpdf.js. Call `./run` 10 | to run it in node. 11 | 12 | For development server-side with node: `coherentpdf.js` (minified version 13 | `coherentpdf.min.js`). Load with `const coherentpdf = require('coherentpdf')` 14 | if installed in npm, or `const coherentpdf = require('./coherentpdf.js')` to 15 | load from current directory. 16 | 17 | For development client-side with the browser : `coherentpdf.browser.js` 18 | (minified version for deployment : `coherentpdf.browser.min.js`). Load with 19 | `<script src="coherentpdf.browser.js"></script>` or similar. 20 | 21 | 22 | Data types 23 | ---------- 24 | 25 | Arguments are numbers, strings, or arrays (of type UInt8Array for data). Page 26 | ranges are represented by arrays of numbers. 27 | 28 | 29 | Memory Management 30 | ----------------- 31 | 32 | A PDF p must be explicitly deallocated with deletePdf(p). 33 | 34 | 35 | Errors 36 | ------ 37 | 38 | Any function may raise an exception, containing a string describing the problem. 39 | 40 | 41 | Concurrency 42 | ----------- 43 | 44 | coherentpdf.js is synchronous and non-re-entrant. In the browser, best used in a worker. 45 | **/ 46 | 47 | -------------------------------------------------------------------------------- /cpdfshape.mli: -------------------------------------------------------------------------------- 1 | (** Basic Shapes *) 2 | 3 | type fpoint = float * float 4 | 5 | type winding_rule = EvenOdd | NonZero 6 | 7 | type segment = 8 | | Straight of fpoint * fpoint 9 | | Bezier of fpoint * fpoint * fpoint * fpoint 10 | 11 | (* Each segment list may be marked as a hole or not. *) 12 | type hole = Hole | Not_hole 13 | 14 | (* A [subpath] is either closed or open. *) 15 | type closure = Closed | Open 16 | 17 | (* A [subpath] is the pair of a hole and a list of segments. *) 18 | type subpath = hole * closure * segment list 19 | 20 | (* A path is made from a number of subpaths. *) 21 | type path = winding_rule * subpath list 22 | 23 | (** The factor by which the radius of a circle is multiplied to find the length 24 | of the bezier control lines when approximating quarter arcs to make circles. *) 25 | val kappa : float 26 | 27 | (** Calling [restrict_angle s a] restricts an angle [a] to one of those at [s, 28 | 2s, 3s...] returning the chosen one. *) 29 | val restrict_angle : float -> float -> float 30 | 31 | (** Calling [circle x y r] builds a path representing a circle at [(x, y)] with 32 | radius [r]. *) 33 | val circle : float -> float -> float -> path 34 | 35 | (** Calling [rectangle x y w h] builds a path representing a rectangle with top 36 | left [(x, y)], width [w] and height [h]. *) 37 | val rectangle : float -> float -> float -> float -> path 38 | -------------------------------------------------------------------------------- /html_manual/splits/c01.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 0. Preliminaries */ 2 | 3 | /* The function cpdf_startup(argv) must be called before using the library. */ 4 | void cpdf_startup(char **); 5 | 6 | /* Return the version of the cpdflib library as a string */ 7 | char *cpdf_version(); 8 | 9 | /* 10 | * Some operations have a fast mode. The default is 'slow' mode, which works 11 | * even on old-fashioned files. For more details, see section 1.13 of the 12 | * CPDF manual. These functions set the mode globally. 13 | */ 14 | void cpdf_setFast(); 15 | void cpdf_setSlow(); 16 | 17 | /* 18 | * Errors. cpdf_lastError and cpdf_lastErrorString hold information about the 19 | * last error to have occurred. They should be consulted after each call. If 20 | * cpdf_lastError is non-zero, there was an error, and cpdf_lastErrorString 21 | * gives details. If cpdf_lastError is zero, there was no error on the most 22 | * recent cpdf call. 23 | */ 24 | extern int cpdf_lastError; 25 | extern char *cpdf_lastErrorString; 26 | 27 | /* cpdf_clearError clears the current error state. */ 28 | void cpdf_clearError(void); 29 | 30 | /* 31 | * cpdf_onExit is a debug function which prints some information about 32 | * resource usage. This can be used to detect if PDFs or ranges are being 33 | * deallocated properly. Contrary to its name, it may be run at any time. 34 | */ 35 | void cpdf_onExit(void); 36 | 37 | -------------------------------------------------------------------------------- /cpdfjpeg2000.ml: -------------------------------------------------------------------------------- 1 | open Pdfutil 2 | open Pdfio 3 | open Cpdferror 4 | 5 | let read_word i = 6 | let a = i32ofi (i.input_byte ()) in 7 | let b = i32ofi (i.input_byte ()) in 8 | let c = i32ofi (i.input_byte ()) in 9 | let d = i32ofi (i.input_byte ()) in 10 | lor32 (lor32 (lor32 (lsl32 a 24) (lsl32 b 16)) (lsl32 c 8)) d 11 | 12 | exception Answer of int * int 13 | 14 | let id_IMAGE_HEADER_BOX = 0x69686472l (* ihdr *) 15 | 16 | (* Return the width and height of a JPEG2000 (.jp2 or .jpx) image. *) 17 | let jpeg2000_dimensions_inner bs = 18 | let i = Pdfio.input_of_bytes bs in 19 | let a = read_word i in 20 | let b = read_word i in 21 | let c = read_word i in 22 | if a <> 0x0000000cl || b <> 0x6a502020l || c <> 0x0d0a870al then 23 | Cpdferror.error "bad JPEG2000 header" 24 | else 25 | while true do 26 | let box = read_word i in 27 | if box = id_IMAGE_HEADER_BOX then 28 | begin 29 | let h = read_word i in 30 | let w = read_word i in 31 | raise (Answer (i32toi w, i32toi h)) 32 | end; 33 | (* Read words starting at each byte until we find ihdr. *) 34 | i.seek_in (i.pos_in () - 3) 35 | done 36 | 37 | let jpeg2000_dimensions bs = 38 | try ignore (jpeg2000_dimensions_inner bs); (0, 0) with 39 | | Answer (w, h) -> (w, h) 40 | | Exit -> error "could not determine JPEG2000 dimensions" 41 | -------------------------------------------------------------------------------- /docsplits/dotnetsplits/c10.tex: -------------------------------------------------------------------------------- 1 | CHAPTER 9. Multipage facilities 2 | 3 | Cpdf.impose(Cpdf.Pdf, Double, Double, Boolean, Boolean, Boolean, Boolean, 4 | Boolean, Double, Double, Double) 5 | 6 | Imposes a PDF. There are two modes: imposing x * y, or imposing to fit a page 7 | of size x * y. This is controlled by fit. Columns imposes by columns rather 8 | than rows. rtl is right-to-left, btt bottom-to-top. Center is unused for now. 9 | Margin is the margin around the output, spacing the spacing between imposed 10 | inputs. 11 | 12 | Cpdf.twoUp(Cpdf.Pdf) 13 | 14 | Imposes a document two up. twoUpStack does so by doubling the page size, to fit 15 | two pages on one. 16 | 17 | Cpdf.twoUpStack(Cpdf.Pdf) 18 | 19 | Impose a document two up. twoUpStack does so by doubling the page size, to fit 20 | two pages on one. 21 | 22 | Cpdf.padBefore(Cpdf.Pdf, List{Int32}) 23 | 24 | Adds a blank page before each page in the given range. 25 | 26 | Cpdf.padAfter(Cpdf.Pdf, List{Int32}) 27 | 28 | Adds a blank page after each page in the given range. 29 | 30 | Cpdf.padEvery(Cpdf.Pdf, Int32) 31 | 32 | Adds a blank page after every n pages. 33 | 34 | Cpdf.padMultiple(Cpdf.Pdf, Int32) 35 | 36 | Adds pages at the end to pad the file to a multiple of n pages in length. 37 | 38 | Cpdf.padMultipleBefore(Cpdf.Pdf, Int32) 39 | 40 | Adds pages at the beginning to pad the file to a multiple of n pages in length. 41 | -------------------------------------------------------------------------------- /html_manual/dotnetsplits/c10.tex: -------------------------------------------------------------------------------- 1 | CHAPTER 9. Multipage facilities 2 | 3 | Cpdf.impose(Cpdf.Pdf, Double, Double, Boolean, Boolean, Boolean, Boolean, 4 | Boolean, Double, Double, Double) 5 | 6 | Imposes a PDF. There are two modes: imposing x * y, or imposing to fit a page 7 | of size x * y. This is controlled by fit. Columns imposes by columns rather 8 | than rows. rtl is right-to-left, btt bottom-to-top. Center is unused for now. 9 | Margin is the margin around the output, spacing the spacing between imposed 10 | inputs. 11 | 12 | Cpdf.twoUp(Cpdf.Pdf) 13 | 14 | Imposes a document two up. twoUpStack does so by doubling the page size, to fit 15 | two pages on one. 16 | 17 | Cpdf.twoUpStack(Cpdf.Pdf) 18 | 19 | Impose a document two up. twoUpStack does so by doubling the page size, to fit 20 | two pages on one. 21 | 22 | Cpdf.padBefore(Cpdf.Pdf, List{Int32}) 23 | 24 | Adds a blank page before each page in the given range. 25 | 26 | Cpdf.padAfter(Cpdf.Pdf, List{Int32}) 27 | 28 | Adds a blank page after each page in the given range. 29 | 30 | Cpdf.padEvery(Cpdf.Pdf, Int32) 31 | 32 | Adds a blank page after every n pages. 33 | 34 | Cpdf.padMultiple(Cpdf.Pdf, Int32) 35 | 36 | Adds pages at the end to pad the file to a multiple of n pages in length. 37 | 38 | Cpdf.padMultipleBefore(Cpdf.Pdf, Int32) 39 | 40 | Adds pages at the beginning to pad the file to a multiple of n pages in length. 41 | -------------------------------------------------------------------------------- /docsplits/dotnetsplits/c13.tex: -------------------------------------------------------------------------------- 1 | CHAPTER 12. File Attachments 2 | 3 | Cpdf.attachFile(String, Cpdf.Pdf) 4 | 5 | Attaches a file to the pdf. It is attached at document level. 6 | 7 | Cpdf.attachFileToPage(String, Cpdf.Pdf, Int32) 8 | 9 | Attaches a file, given its file name, pdf, and the page number to which it 10 | should be attached. 11 | 12 | Cpdf.attachFileFromMemory(Byte[], String, Cpdf.Pdf) 13 | 14 | Attaches data from memory, just like attachFile. 15 | 16 | Cpdf.attachFileToPageFromMemory(Byte[], String, Cpdf.Pdf, Int32) 17 | 18 | Attaches to a page from memory, just like attachFileToPage. 19 | 20 | Cpdf.removeAttachedFiles(Cpdf.Pdf) 21 | 22 | Removes all page- and document-level attachments from a document. 23 | 24 | Cpdf.startGetAttachments(Cpdf.Pdf) 25 | 26 | Cpdf.numberGetAttachments 27 | 28 | Lists information about attachments. Call startGetAttachments(pdf) first, then 29 | numberGetAttachments to find out how many there are. Then getAttachmentName 30 | etc. to return each one 0...(n - 1). Finally, call endGetAttachments to clean 31 | up. 32 | 33 | Cpdf.getAttachmentName(Int32) 34 | 35 | Gets the name of an attachment. 36 | 37 | Cpdf.getAttachmentPage(Int32) 38 | 39 | Gets the page number. 0 = document level. 40 | 41 | Cpdf.getAttachmentData(Int32) 42 | 43 | Gets the attachment data itself. 44 | 45 | Cpdf.endGetAttachments 46 | 47 | Cleans up after getting attachments. 48 | -------------------------------------------------------------------------------- /docsplits/javascriptsplits/c16.tex: -------------------------------------------------------------------------------- 1 | // CHAPTER 15. PDF and JSON 2 | 3 | /** Outputs a PDF in JSON format to the given filename. If parse_content is 4 | true, page content is parsed. If no_stream_data is true, all stream data is 5 | suppressed entirely. If decompress_streams is true, streams are decompressed. 6 | @arg {string} filename file name 7 | @arg {boolean} parse_content parse page content 8 | @arg {boolean} no_stream_data suppress stream data 9 | @arg {boolean} decompress_streams decompress streams 10 | @arg {pdf} pdf PDF document */ 11 | function outputJSON(filename, parse_content, no_stream_data, decompress_streams, pdf) {} 12 | 13 | /** Like outputJSON, but it writes to a byte array in memory. 14 | @arg {boolean} parse_content parse page content 15 | @arg {boolean} no_stream_data suppress stream data 16 | @arg {boolean} decompress_streams decompress streams 17 | @arg {pdf} pdf PDF document 18 | @return {Uint8Array} JSON data as a byte array */ 19 | function outputJSONMemory(parse_content, no_stream_data, decompress_streams, pdf) {} 20 | 21 | /** Loads a PDF from a JSON file given its filename. 22 | @arg {string} filename file name 23 | @return {pdf} PDF document */ 24 | function fromJSON(filename) {} 25 | 26 | /** Loads a PDF from a JSON file in memory. 27 | @arg {Uint8Array} data JSON data as a byte array 28 | @return {pdf} PDF document */ 29 | function fromJSONMemory(data) {} 30 | 31 | -------------------------------------------------------------------------------- /html_manual/dotnetsplits/c13.tex: -------------------------------------------------------------------------------- 1 | CHAPTER 12. File Attachments 2 | 3 | Cpdf.attachFile(String, Cpdf.Pdf) 4 | 5 | Attaches a file to the pdf. It is attached at document level. 6 | 7 | Cpdf.attachFileToPage(String, Cpdf.Pdf, Int32) 8 | 9 | Attaches a file, given its file name, pdf, and the page number to which it 10 | should be attached. 11 | 12 | Cpdf.attachFileFromMemory(Byte[], String, Cpdf.Pdf) 13 | 14 | Attaches data from memory, just like attachFile. 15 | 16 | Cpdf.attachFileToPageFromMemory(Byte[], String, Cpdf.Pdf, Int32) 17 | 18 | Attaches to a page from memory, just like attachFileToPage. 19 | 20 | Cpdf.removeAttachedFiles(Cpdf.Pdf) 21 | 22 | Removes all page- and document-level attachments from a document. 23 | 24 | Cpdf.startGetAttachments(Cpdf.Pdf) 25 | 26 | Cpdf.numberGetAttachments 27 | 28 | Lists information about attachments. Call startGetAttachments(pdf) first, then 29 | numberGetAttachments to find out how many there are. Then getAttachmentName 30 | etc. to return each one 0...(n - 1). Finally, call endGetAttachments to clean 31 | up. 32 | 33 | Cpdf.getAttachmentName(Int32) 34 | 35 | Gets the name of an attachment. 36 | 37 | Cpdf.getAttachmentPage(Int32) 38 | 39 | Gets the page number. 0 = document level. 40 | 41 | Cpdf.getAttachmentData(Int32) 42 | 43 | Gets the attachment data itself. 44 | 45 | Cpdf.endGetAttachments 46 | 47 | Cleans up after getting attachments. 48 | -------------------------------------------------------------------------------- /html_manual/javascriptsplits/c16.tex: -------------------------------------------------------------------------------- 1 | // CHAPTER 15. PDF and JSON 2 | 3 | /** Outputs a PDF in JSON format to the given filename. If parse_content is 4 | true, page content is parsed. If no_stream_data is true, all stream data is 5 | suppressed entirely. If decompress_streams is true, streams are decompressed. 6 | @arg {string} filename file name 7 | @arg {boolean} parse_content parse page content 8 | @arg {boolean} no_stream_data suppress stream data 9 | @arg {boolean} decompress_streams decompress streams 10 | @arg {pdf} pdf PDF document */ 11 | function outputJSON(filename, parse_content, no_stream_data, decompress_streams, pdf) {} 12 | 13 | /** Like outputJSON, but it writes to a byte array in memory. 14 | @arg {boolean} parse_content parse page content 15 | @arg {boolean} no_stream_data suppress stream data 16 | @arg {boolean} decompress_streams decompress streams 17 | @arg {pdf} pdf PDF document 18 | @return {Uint8Array} JSON data as a byte array */ 19 | function outputJSONMemory(parse_content, no_stream_data, decompress_streams, pdf) {} 20 | 21 | /** Loads a PDF from a JSON file given its filename. 22 | @arg {string} filename file name 23 | @return {pdf} PDF document */ 24 | function fromJSON(filename) {} 25 | 26 | /** Loads a PDF from a JSON file in memory. 27 | @arg {Uint8Array} data JSON data as a byte array 28 | @return {pdf} PDF document */ 29 | function fromJSONMemory(data) {} 30 | 31 | -------------------------------------------------------------------------------- /html_manual/pysplits/c10.tex: -------------------------------------------------------------------------------- 1 | # CHAPTER 9. Multipage facilities 2 | 3 | def twoUp(pdf): 4 | """Impose a document two up by retaining the existing page 5 | size, scaling pages down.""" 6 | 7 | def twoUpStack(pdf): 8 | """Impose a document two up by doubling the page size, 9 | to fit two pages on one.""" 10 | 11 | def impose(pdf, x, y, fit, columns, rtl, btt, center, margin, spacing, linewidth): 12 | """impose(pdf, x, y, fit, columns, rtl, btt, center, margin, spacing, 13 | linewidth) imposes a PDF. There are two modes: imposing x * y, or imposing 14 | to fit a page of size x * y. This is controlled by fit. Columns imposes by 15 | columns rather than rows. rtl is right-to-left, btt bottom-to-top. Center 16 | is unused for now. Margin is the margin around the output, spacing the 17 | spacing between imposed inputs.""" 18 | 19 | def padBefore(pdf, r): 20 | """Adds a blank page before each page in the given range.""" 21 | 22 | def padAfter(pdf, r): 23 | """Adds a blank page after each page in the given range.""" 24 | 25 | def padEvery(pdf, n): 26 | """Adds a blank page after every n pages.""" 27 | 28 | def padMultiple(pdf, n): 29 | """Adds pages at the end to pad the file to a multiple of n pages in 30 | length.""" 31 | 32 | def padMultipleBefore(pdf, n): 33 | """Adds pages at the beginning to pad the file to a 34 | multiple of n pages in length.""" 35 | -------------------------------------------------------------------------------- /docsplits/pysplits/c18.tex: -------------------------------------------------------------------------------- 1 | def blankDocument(w, h, pages): 2 | """Create a blank document with pages of the given width (in points), 3 | height (in points), and number of pages.""" 4 | 5 | def blankDocumentPaper(papersize, pages): 6 | """Create a blank document with pages of the given paper size, and number 7 | of pages.""" 8 | 9 | def textToPDF(w, h, font, fontsize, filename): 10 | """Typesets a UTF8 text file ragged right on a page of size w * h in points 11 | in the given font and font size.""" 12 | 13 | def textToPDFMemory(w, h, font, fontsize, data): 14 | """Typesets a UTF8 text file ragged right on a page of size w * h in points 15 | in the given font and font size.""" 16 | 17 | def textToPDFPaper(papersize, font, fontsize, filename): 18 | """Typesets a UTF8 text file ragged right on a page of the given size in 19 | the given font and font size.""" 20 | 21 | def textToPDFPaperMemory(papersize, font, fontsize, data): 22 | """Typesets a UTF8 text file ragged right on a page of the given size in 23 | the given font and font size.""" 24 | 25 | def fromPNG(filename): 26 | """Builds a PDF from a non-interlaced non-transparent PNG file.""" 27 | 28 | def fromPNGMemory(data): 29 | """Builds a PDF from a non-interlaced non-transparent PNG file bytearray.""" 30 | 31 | def fromJPEG(filename): 32 | """Builds a PDF from a JPEG file.""" 33 | 34 | def fromJPEGMemory(data): 35 | """Builds a PDF from a JPEG file bytearray.""" 36 | -------------------------------------------------------------------------------- /docsplits/javasplits/c18.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 17. Creating New PDFs */ 2 | 3 | /** Creates a blank document with pages of the given width (in points), 4 | height (in points), and number of pages. 5 | @param w width of page 6 | @param h height of page 7 | @param pages number of pages */ 8 | public native Pdf blankDocument(double w, double h, int pages) 9 | throws CpdfError; 10 | 11 | /** Makes a blank document given a page size and number of pages. 12 | @param papersize paper size, such as {@link #a0portrait a0portrait} 13 | @param pages number of pages */ 14 | public native Pdf blankDocumentPaper(int papersize, int pages) 15 | throws CpdfError; 16 | 17 | /** Typesets a UTF8 text file ragged right on a page of size w * h in 18 | points in the given font and font size. 19 | @param w width of page 20 | @param h height of page 21 | @param font font, such as {@link #timesRoman timesRoman} 22 | @param fontsize font size 23 | @param filename file name */ 24 | public Pdf textToPDF(double w, double h, int font, double fontsize, 25 | String filename) 26 | throws CpdfError; 27 | 28 | /** Typesets a UTF8 text file ragged right on a page of the given size in 29 | the given font and font size. 30 | @param papersize paper size, such as {@link #a0portrait a0portrait} 31 | @param font font, such as {@link #timesRoman timesRoman} 32 | @param fontsize font size 33 | @param filename file name */ 34 | public Pdf textToPDFPaper(int papersize, int font, double fontsize, 35 | String filename) 36 | throws CpdfError; 37 | -------------------------------------------------------------------------------- /html_manual/javasplits/c18.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 17. Creating New PDFs */ 2 | 3 | /** Creates a blank document with pages of the given width (in points), 4 | height (in points), and number of pages. 5 | @param w width of page 6 | @param h height of page 7 | @param pages number of pages */ 8 | public native Pdf blankDocument(double w, double h, int pages) 9 | throws CpdfError; 10 | 11 | /** Makes a blank document given a page size and number of pages. 12 | @param papersize paper size, such as {@link #a0portrait a0portrait} 13 | @param pages number of pages */ 14 | public native Pdf blankDocumentPaper(int papersize, int pages) 15 | throws CpdfError; 16 | 17 | /** Typesets a UTF8 text file ragged right on a page of size w * h in 18 | points in the given font and font size. 19 | @param w width of page 20 | @param h height of page 21 | @param font font, such as {@link #timesRoman timesRoman} 22 | @param fontsize font size 23 | @param filename file name */ 24 | public Pdf textToPDF(double w, double h, int font, double fontsize, 25 | String filename) 26 | throws CpdfError; 27 | 28 | /** Typesets a UTF8 text file ragged right on a page of the given size in 29 | the given font and font size. 30 | @param papersize paper size, such as {@link #a0portrait a0portrait} 31 | @param font font, such as {@link #timesRoman timesRoman} 32 | @param fontsize font size 33 | @param filename file name */ 34 | public Pdf textToPDFPaper(int papersize, int font, double fontsize, 35 | String filename) 36 | throws CpdfError; 37 | -------------------------------------------------------------------------------- /compressor/compressor.ml: -------------------------------------------------------------------------------- 1 | (* compressor <infile> <outfile> [<compress>] substitutes data files specified 2 | by __DATA:<filename>\n into the <infile> template, writing to <outfile>. The 3 | data is printed in way which meets OCaml's syntax. It is compressed by zlib. 4 | *) 5 | open Pdfutil 6 | 7 | let contents_of_file filename = 8 | let ch = open_in_bin filename in 9 | let s = really_input_string ch (in_channel_length ch) in 10 | close_in ch; 11 | s 12 | 13 | let contents_to_file filename contents = 14 | let ch = open_out_bin filename in 15 | output_string ch contents; 16 | close_out ch 17 | 18 | let rec process a = function 19 | | '_'::'_'::'D'::'A'::'T'::'A'::':'::more -> 20 | let filename, rest = cleavewhile (neq '\n') more in 21 | let data = all_but_last (explode (contents_of_file (implode filename))) in 22 | let compressed = Pdfio.string_of_bytes (Pdfcodec.encode_flate (Pdfio.bytes_of_string (implode data))) in 23 | let ocaml = explode (Printf.sprintf "%S" compressed) in 24 | process (rev ocaml @ a) rest 25 | | h::t -> process (h::a) t 26 | | [] -> rev a 27 | 28 | let go infile outfile compress = 29 | let indata = explode (contents_of_file infile) in 30 | let processed = process [] indata in 31 | contents_to_file outfile (implode processed) 32 | 33 | let () = 34 | match Sys.argv with 35 | | [|_; infile; outfile|] -> go infile outfile false 36 | | [|_; infile; outfile; "compress"|] -> go infile outfile true 37 | | _ -> Printf.eprintf "compressor: unknown command line\n" 38 | -------------------------------------------------------------------------------- /docsplits/javascriptsplits/c03.tex: -------------------------------------------------------------------------------- 1 | // CHAPTER 2. Merging and Splitting 2 | 3 | /** Given a list of PDFs, merges the files into a new one, which is returned. 4 | @arg {"array of pdfs"} pdfs array of PDF documents to merge 5 | @return {pdf} merged PDF document */ 6 | function mergeSimple(pdfs) {} 7 | 8 | /** Merges the PDFs. If retain_numbering is true page labels are not 9 | rewritten. If remove_duplicate_fonts is true, duplicate fonts are merged. 10 | This is useful when the source documents for merging originate from the same 11 | source. 12 | @arg {"array of pdfs"} pdfs array of PDF documents to merge 13 | @arg {boolean} retain_numbering keep page numbering 14 | @arg {boolean} remove_duplicate_fonts remove duplicate font data */ 15 | function merge(pdfs, retain_numbering, remove_duplicate_fonts) {} 16 | 17 | /** The same as merge, except that it has an additional argument - a list of 18 | page ranges. This is used to select the pages to pick from each PDF. This 19 | avoids duplication of information when multiple discrete parts of a source PDF 20 | are included. 21 | @arg {"array of pdfs"} pdfs array of PDF documents to merge 22 | @arg {boolean} retain_numbering keep page numbering 23 | @arg {boolean} remove_duplicate_fonts remove duplicate font data 24 | @arg {"array of arrays of numbers"} ranges page ranges, one for each input PDF */ 25 | function mergeSame(pdfs, retain_numbering, remove_duplicate_fonts, ranges) {} 26 | 27 | /** Returns a new document with just those pages in the page range. 28 | @arg {pdf} pdf PDF document 29 | @arg {range} page range */ 30 | function selectPages(pdf, r) {} 31 | 32 | -------------------------------------------------------------------------------- /cpdftweak.mli: -------------------------------------------------------------------------------- 1 | (** Miscellany *) 2 | 3 | (** Make all lines in the PDF at least a certain thickness. *) 4 | val thinlines : int list -> float -> Pdf.t -> Pdf.t 5 | 6 | (** Make all text on certain pages black. *) 7 | val blacktext : Cpdfaddtext.colour -> int list -> Pdf.t -> Pdf.t 8 | 9 | (** Make all lines on certain pages black. *) 10 | val blacklines : Cpdfaddtext.colour -> int list -> Pdf.t -> Pdf.t 11 | 12 | (** Make all fills on certain pages black. *) 13 | val blackfills : Cpdfaddtext.colour -> int list -> Pdf.t -> Pdf.t 14 | 15 | (** Append page content. *) 16 | val append_page_content : string -> bool -> bool -> int list -> Pdf.t -> Pdf.t 17 | 18 | (** Print a dictionary entry. *) 19 | val print_dict_entry : utf8:bool -> Pdf.t -> string -> unit 20 | 21 | (** Get dictionary entries in JSON format *) 22 | val get_dict_entries : utf8:bool -> Pdf.t -> string -> Pdfio.bytes 23 | 24 | (** Remove clipping. *) 25 | val remove_clipping : Pdf.t -> int list -> Pdf.t 26 | 27 | (** Find an object from an objspec. Raises and error if the chain is not found. *) 28 | val find_obj : Pdf.t -> string -> Pdf.pdfobject 29 | 30 | (** [remove_stream pdf objspec filename] replaces the stream at [objspec] with the contents of [filename]. *) 31 | val replace_stream : Pdf.t -> string -> string -> unit 32 | 33 | (** [replace_obj pdf objspec obj] replace the object at [objspec] (which must exist) with [obj]. *) 34 | val replace_obj : Pdf.t -> string -> Pdf.pdfobject -> unit 35 | 36 | (** [remove_obj pdf objspec] removes the object described by the object specification. *) 37 | val remove_obj : Pdf.t -> string -> unit 38 | -------------------------------------------------------------------------------- /html_manual/javascriptsplits/c03.tex: -------------------------------------------------------------------------------- 1 | // CHAPTER 2. Merging and Splitting 2 | 3 | /** Given a list of PDFs, merges the files into a new one, which is returned. 4 | @arg {"array of pdfs"} pdfs array of PDF documents to merge 5 | @return {pdf} merged PDF document */ 6 | function mergeSimple(pdfs) {} 7 | 8 | /** Merges the PDFs. If retain_numbering is true page labels are not 9 | rewritten. If remove_duplicate_fonts is true, duplicate fonts are merged. 10 | This is useful when the source documents for merging originate from the same 11 | source. 12 | @arg {"array of pdfs"} pdfs array of PDF documents to merge 13 | @arg {boolean} retain_numbering keep page numbering 14 | @arg {boolean} remove_duplicate_fonts remove duplicate font data */ 15 | function merge(pdfs, retain_numbering, remove_duplicate_fonts) {} 16 | 17 | /** The same as merge, except that it has an additional argument - a list of 18 | page ranges. This is used to select the pages to pick from each PDF. This 19 | avoids duplication of information when multiple discrete parts of a source PDF 20 | are included. 21 | @arg {"array of pdfs"} pdfs array of PDF documents to merge 22 | @arg {boolean} retain_numbering keep page numbering 23 | @arg {boolean} remove_duplicate_fonts remove duplicate font data 24 | @arg {"array of arrays of numbers"} ranges page ranges, one for each input PDF */ 25 | function mergeSame(pdfs, retain_numbering, remove_duplicate_fonts, ranges) {} 26 | 27 | /** Returns a new document with just those pages in the page range. 28 | @arg {pdf} pdf PDF document 29 | @arg {range} page range */ 30 | function selectPages(pdf, r) {} 31 | 32 | -------------------------------------------------------------------------------- /html_manual/splits/c10.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 9. Multipage facilities */ 2 | 3 | /* cpdf_impose(pdf, x, y, fit, columns, rtl, btt, center, margin, spacing, 4 | * linewidth) imposes a PDF. There are two modes: imposing x * y, or imposing 5 | * to fit a page of size x * y. This is controlled by fit. Columns imposes by 6 | * columns rather than rows. rtl is right-to-left, btt bottom-to-top. Center is 7 | * unused for now. Margin is the margin around the output, spacing the spacing 8 | * between imposed inputs. */ 9 | void cpdf_impose(int, double, double, int, int, int, int, int, double, double, 10 | double); 11 | 12 | /* 13 | * Impose a document two up. cpdf_twoUp does so by retaining the existing 14 | * page size, scaling pages down. cpdf_twoUpStack does so by doubling the 15 | * page size, to fit two pages on one. 16 | */ 17 | void cpdf_twoUp(int); 18 | void cpdf_twoUpStack(int); 19 | 20 | /* 21 | * cpdf_padBefore(pdf, range) adds a blank page before each page in the given 22 | * range. 23 | */ 24 | void cpdf_padBefore(int, int); 25 | 26 | /* 27 | * cpdf_padAfter(pdf, range) adds a blank page after each page in the given 28 | * range. 29 | */ 30 | void cpdf_padAfter(int, int); 31 | 32 | /* cpdf_pageEvery(pdf, n) adds a blank page after every n pages. */ 33 | void cpdf_padEvery(int, int); 34 | 35 | /* 36 | * cpdf_padMultiple(pdf, n) adds pages at the end to pad the file to a 37 | * multiple of n pages in length. 38 | */ 39 | void cpdf_padMultiple(int, int); 40 | 41 | /* 42 | * cpdf_padMultiple(pdf, n) adds pages at the beginning to pad the file to a 43 | * multiple of n pages in length. 44 | */ 45 | void cpdf_padMultipleBefore(int, int); 46 | 47 | -------------------------------------------------------------------------------- /docsplits/javasplits/c15.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 14. Fonts. */ 2 | 3 | /** Retrieves font information. First, call {@link #startGetFontInfo(Pdf) 4 | startGetFontInfo}. Now call {@link #numberFonts() numberFonts} to return 5 | the number of fonts. For each font, call one or more of 6 | {@link #getFontPage(int) getFontPage}, {@link #getFontName(int) 7 | getFontName}, {@link #getFontType(int) getFontType}, and 8 | {@link #getFontEncoding(int) getFontEncoding} giving a serial number 9 | <code>0...n - 1</code> to return information. Finally, call 10 | {@link #endGetFontInfo() endGetFontInfo} to clean up. */ 11 | public native void startGetFontInfo(Pdf pdf) throws CpdfError; 12 | 13 | public native int numberFonts() throws CpdfError; 14 | 15 | public native String getFontName(int serial) throws CpdfError; 16 | 17 | public native int getFontPage(int serial) throws CpdfError; 18 | 19 | public native String getFontType(int setial) throws CpdfError; 20 | 21 | public native String getFontEncoding(int serial) throws CpdfError; 22 | 23 | public native void endGetFontInfo() throws CpdfError; 24 | 25 | /** Removes all font data from a file. */ 26 | public native void removeFonts(Pdf pdf) throws CpdfError; 27 | 28 | /** Copies the given font 29 | from the given page in the 'from' PDF to every page in the 'to' PDF. The 30 | new font is stored under its font name. 31 | @param from_pdf PDF document to copy from 32 | @param to_pdf PDF document to copy to 33 | @param range page range 34 | @param pagenumber page number of the page to copy from 35 | @param fontname font name */ 36 | public native void copyFont(Pdf from_pdf, Pdf to_pdf, Range range, 37 | int pagenumber, String fontname) 38 | throws CpdfError; 39 | -------------------------------------------------------------------------------- /html_manual/javasplits/c15.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 14. Fonts. */ 2 | 3 | /** Retrieves font information. First, call {@link #startGetFontInfo(Pdf) 4 | startGetFontInfo}. Now call {@link #numberFonts() numberFonts} to return 5 | the number of fonts. For each font, call one or more of 6 | {@link #getFontPage(int) getFontPage}, {@link #getFontName(int) 7 | getFontName}, {@link #getFontType(int) getFontType}, and 8 | {@link #getFontEncoding(int) getFontEncoding} giving a serial number 9 | <code>0...n - 1</code> to return information. Finally, call 10 | {@link #endGetFontInfo() endGetFontInfo} to clean up. */ 11 | public native void startGetFontInfo(Pdf pdf) throws CpdfError; 12 | 13 | public native int numberFonts() throws CpdfError; 14 | 15 | public native String getFontName(int serial) throws CpdfError; 16 | 17 | public native int getFontPage(int serial) throws CpdfError; 18 | 19 | public native String getFontType(int setial) throws CpdfError; 20 | 21 | public native String getFontEncoding(int serial) throws CpdfError; 22 | 23 | public native void endGetFontInfo() throws CpdfError; 24 | 25 | /** Removes all font data from a file. */ 26 | public native void removeFonts(Pdf pdf) throws CpdfError; 27 | 28 | /** Copies the given font 29 | from the given page in the 'from' PDF to every page in the 'to' PDF. The 30 | new font is stored under its font name. 31 | @param from_pdf PDF document to copy from 32 | @param to_pdf PDF document to copy to 33 | @param range page range 34 | @param pagenumber page number of the page to copy from 35 | @param fontname font name */ 36 | public native void copyFont(Pdf from_pdf, Pdf to_pdf, Range range, 37 | int pagenumber, String fontname) 38 | throws CpdfError; 39 | -------------------------------------------------------------------------------- /docsplits/javasplits/c03.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 2. Merging and Splitting */ 2 | 3 | /** Given an array of PDFs, merges the documents into a new one, which is 4 | returned. */ 5 | public native Pdf mergeSimple(Pdf[] pdfs) throws CpdfError; 6 | 7 | /** Merges the PDFs. If <code>retain_numbering</code> is true page labels 8 | are not rewritten. If <code>remove_duplicate_fonts</code> is true, 9 | duplicate fonts are merged. This is useful when the source documents for 10 | merging originate from the same source. 11 | @param pdfs array of PDF documents 12 | @param retain_numbering retain page numbering in output 13 | @param remove_duplicate_fonts remove duplicate font data by merging */ 14 | public native Pdf merge(Pdf[] pdfs, boolean retain_numbering, 15 | boolean remove_duplicate_fonts) 16 | throws CpdfError; 17 | 18 | /** Merges PDFs when one or more are drawn from the same document. It has 19 | an additional argument - a list of page ranges. This is used to select the 20 | pages to pick from each PDF. This avoids duplication of information when 21 | multiple discrete parts of a source PDF are included. 22 | @param pdfs array of PDF documents 23 | @param retain_numbering retain page numbering in output 24 | @param remove_duplicate_fonts remove duplicate font data by merging 25 | @param ranges array of ranges, one for each PDF*/ 26 | public native Pdf mergeSame(Pdf[] pdfs, boolean retain_numbering, 27 | boolean remove_duplicate_fonts, Range[] ranges) 28 | throws CpdfError; 29 | 30 | /** Returns a new document with just those pages in the page range. 31 | * @param pdf PDF document 32 | * @param range range*/ 33 | public native Pdf selectPages(Pdf pdf, Range range) throws CpdfError; 34 | -------------------------------------------------------------------------------- /html_manual/javasplits/c03.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 2. Merging and Splitting */ 2 | 3 | /** Given an array of PDFs, merges the documents into a new one, which is 4 | returned. */ 5 | public native Pdf mergeSimple(Pdf[] pdfs) throws CpdfError; 6 | 7 | /** Merges the PDFs. If <code>retain_numbering</code> is true page labels 8 | are not rewritten. If <code>remove_duplicate_fonts</code> is true, 9 | duplicate fonts are merged. This is useful when the source documents for 10 | merging originate from the same source. 11 | @param pdfs array of PDF documents 12 | @param retain_numbering retain page numbering in output 13 | @param remove_duplicate_fonts remove duplicate font data by merging */ 14 | public native Pdf merge(Pdf[] pdfs, boolean retain_numbering, 15 | boolean remove_duplicate_fonts) 16 | throws CpdfError; 17 | 18 | /** Merges PDFs when one or more are drawn from the same document. It has 19 | an additional argument - a list of page ranges. This is used to select the 20 | pages to pick from each PDF. This avoids duplication of information when 21 | multiple discrete parts of a source PDF are included. 22 | @param pdfs array of PDF documents 23 | @param retain_numbering retain page numbering in output 24 | @param remove_duplicate_fonts remove duplicate font data by merging 25 | @param ranges array of ranges, one for each PDF*/ 26 | public native Pdf mergeSame(Pdf[] pdfs, boolean retain_numbering, 27 | boolean remove_duplicate_fonts, Range[] ranges) 28 | throws CpdfError; 29 | 30 | /** Returns a new document with just those pages in the page range. 31 | * @param pdf PDF document 32 | * @param range range*/ 33 | public native Pdf selectPages(Pdf pdf, Range range) throws CpdfError; 34 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Build the cpdf command line tools 2 | NONDOC = cpdfyojson cpdfxmlm 3 | 4 | DOC = cpdfutil cpdfunicodedata cpdferror cpdfdebug cpdfjson cpdfstrftime \ 5 | cpdfcoord cpdfattach cpdfpagespec cpdfposition cpdfpresent cpdfmetadata \ 6 | cpdfbookmarks cpdfpage cpdftruetype cpdfremovetext cpdfextracttext \ 7 | cpdfembed cpdffont cpdftype cpdfaddtext cpdfpad cpdfocg cpdfsqueeze \ 8 | cpdfdraft cpdfspot cpdfpagelabels cpdfcreate cpdfannot cpdfxobject \ 9 | cpdfimpose cpdfchop cpdftweak cpdfprinttree cpdfua cpdftexttopdf \ 10 | cpdftoc cpdfjpeg cpdfjpeg2000 cpdfpng cpdfimage cpdfdraw \ 11 | cpdfcomposition cpdfshape cpdfcolours cpdfdrawcontrol cpdfform cpdfjs \ 12 | cpdfportfolio cpdfcommand 13 | 14 | MODS = $(NONDOC) $(DOC) 15 | 16 | SOURCES = $(foreach x,$(MODS),$(x).ml $(x).mli) cpdfcommandrun.ml 17 | 18 | RESULT = cpdf 19 | ANNOTATE = true 20 | PACKS = unix camlpdf 21 | 22 | CFLAGS = -fPIC -g 23 | OCAMLFLAGS = -bin-annot 24 | OCAMLNCFLAGS = -g -safe-string 25 | OCAMLBCFLAGS = -g -safe-string 26 | OCAMLLDFLAGS = -g 27 | 28 | TARGETS := byte-code byte-code-library htdoc 29 | 30 | LIBINSTALL_FILES = cpdf.cma \ 31 | $(foreach x,$(MODS),$x.mli) $(foreach x,$(MODS),$x.cmi) \ 32 | $(foreach x,$(MODS),$x.cmti) 33 | 34 | ifneq ($(shell ocamlopt -version),) 35 | TARGETS += native-code native-code-library 36 | LIBINSTALL_FILES += cpdf.a cpdf.cmxa $(foreach x,$(MODS),$x.cmx) 37 | endif 38 | 39 | all : $(TARGETS) 40 | 41 | clean :: 42 | rm -rf doc foo foo2 out.pdf out2.pdf out3.pdf foo.pdf decomp.pdf *.cmt \ 43 | *.cmti *.json test/*.pdf *.ps *.aux *.idx *.log *.out *.toc *.cut \ 44 | *.ttf *.ttx out.png cpdf.dSYM *.trace 45 | 46 | DOC_FILES = $(foreach x,$(DOC),$(x).mli) 47 | 48 | install : libinstall 49 | 50 | -include OCamlMakefile 51 | -------------------------------------------------------------------------------- /docsplits/splits/c14.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 13. Images. */ 2 | 3 | /* Get list of images. Call cpdf_startGetImages, which returns the total number 4 | * of images. Then serial numbers 0..<total number> - 1 are used to retreive 5 | * data. Finally, call cpdf_endGetImages to clean up. */ 6 | int cpdf_startGetImages(int); 7 | int cpdf_getImageObjNum(int); 8 | char *cpdf_getImagePages(int); 9 | char *cpdf_getImageName(int); 10 | int cpdf_getImageWidth(int); 11 | int cpdf_getImageHeight(int); 12 | int cpdf_getImageSize(int); 13 | int cpdf_getImageBPC(int); 14 | char *cpdf_getImageColSpace(int); 15 | char *cpdf_getImageFilter(int); 16 | void cpdf_endGetImages(void); 17 | 18 | /* 19 | * Get image data, including resolution at all points of use. Call 20 | * cpdf_startGetImageResolution(pdf, min_required_resolution) will begin the 21 | * process of obtaining data on all image uses below min_required_resolution, 22 | * returning the total number. So, to return all image uses, specify a very 23 | * high min_required_resolution. Then, call the other functions giving a 24 | * serial number 0..<total number> - 1, to retrieve the data. Finally, call 25 | * cpdf_endGetImageResolution to clean up. 26 | */ 27 | int cpdf_startGetImageResolution(int, double); 28 | int cpdf_getImageResolutionPageNumber(int); 29 | char *cpdf_getImageResolutionImageName(int); 30 | int cpdf_getImageResolutionXPixels(int); 31 | int cpdf_getImageResolutionYPixels(int); 32 | double cpdf_getImageResolutionXRes(int); 33 | double cpdf_getImageResolutionYRes(int); 34 | int cpdf_getImageResolutionObjNum(int); 35 | void cpdf_endGetImageResolution(void); 36 | 37 | /* Get image resolution data in JSON format */ 38 | void *cpdf_imageResolutionJSON(int, int *, float); 39 | 40 | /* Get image data in JSON format */ 41 | void *cpdf_imagesJSON(int, int *); 42 | 43 | -------------------------------------------------------------------------------- /html_manual/splits/c13.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 12. File Attachments */ 2 | 3 | /* 4 | * cpdf_attachFile(filename, pdf) attaches a file to the pdf. It is attached 5 | * at document level. 6 | */ 7 | void cpdf_attachFile(const char[], int); 8 | 9 | /* 10 | * cpdf_attachFileToPage(filename, pdf, pagenumber) attaches a file, given 11 | * its file name, pdf, and the page number to which it should be attached. 12 | */ 13 | void cpdf_attachFileToPage(const char[], int, int); 14 | 15 | /* 16 | * cpdf_attachFileFromMemory(memory, length, filename, pdf) attaches from 17 | * memory, just like cpdf_attachFile. 18 | */ 19 | void cpdf_attachFileFromMemory(void *, int, const char[], int); 20 | 21 | /* 22 | * cpdf_attachFileToPageFromMemory(memory, length, filename, pdf, pagenumber) 23 | * attaches from memory, just like cpdf_attachFileToPage. 24 | */ 25 | void cpdf_attachFileToPageFromMemory(void *, int, const char[], int, int); 26 | 27 | /* Remove all page- and document-level attachments from a document */ 28 | void cpdf_removeAttachedFiles(int); 29 | 30 | /* 31 | * List information about attachments. Call cpdf_startGetAttachments(pdf) 32 | * first, then cpdf_numberGetAttachments to find out how many there are. Then 33 | * cpdf_getAttachmentName to return each one 0...(n - 1). Finally, call 34 | * cpdf_endGetAttachments to clean up. 35 | */ 36 | void cpdf_startGetAttachments(int); 37 | 38 | /* Get the number of attachments. */ 39 | int cpdf_numberGetAttachments(void); 40 | 41 | /* Get the name of the attachment. */ 42 | char *cpdf_getAttachmentName(int); 43 | 44 | /* Gets the page number. 0 = document level. */ 45 | int cpdf_getAttachmentPage(int); 46 | 47 | /* 48 | * cpdf_getAttachmentData(serial number, &length) returns a pointer to the 49 | * data, and its length. 50 | */ 51 | void *cpdf_getAttachmentData(int, int *); 52 | 53 | /* Clean up after getting attachments. */ 54 | void cpdf_endGetAttachments(void); 55 | 56 | -------------------------------------------------------------------------------- /docsplits/javasplits/c10.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 9. Multipage facilities */ 2 | 3 | /** Imposes a PDF. 4 | @param pdf PDF document 5 | @param x x parameter 6 | @param y y parameter 7 | @param fit <code>true</code>: impose to fit a page of size x by y; 8 | <code>false</code>: impose x by y 9 | @param columns imposes by columns rather than rows 10 | @param rtl impose right-to-left 11 | @param btt impose bottom-to-top 12 | @param center unused for now 13 | @param margin margin around the output 14 | @param spacing spacing between imposed inputs */ 15 | public native void impose(Pdf pdf, double x, double y, boolean fit, 16 | boolean columns, boolean rtl, boolean btt, 17 | boolean center, double margin, double spacing, 18 | double linewidth) 19 | throws CpdfError; 20 | 21 | /** Imposes a document two up. twoUp does so by shrinking the page size, to 22 | fit two pages on one. */ 23 | public native void twoUp(Pdf pdf) throws CpdfError; 24 | 25 | /** Imposes a document two up. twoUpStack does so by doubling the page 26 | size, to fit two pages on one. */ 27 | public native void twoUpStack(Pdf pdf) throws CpdfError; 28 | 29 | /** Adds a blank page before each page in the given range. */ 30 | public native void padBefore(Pdf pdf, Range range) throws CpdfError; 31 | 32 | /** Adds a blank page after each page in the given range. */ 33 | public native void padAfter(Pdf pdf, Range range) throws CpdfError; 34 | 35 | /** Adds a blank page after every n pages. */ 36 | public native void padEvery(Pdf pdf, int n) throws CpdfError; 37 | 38 | /** Adds pages at the end to pad the file to a multiple of n pages in 39 | length. */ 40 | public native void padMultiple(Pdf pdf, int n) throws CpdfError; 41 | 42 | /** Adds pages at the beginning to pad the file to a multiple of n pages in 43 | length. */ 44 | public native void padMultipleBefore(Pdf pdf, int n) throws CpdfError; 45 | -------------------------------------------------------------------------------- /docsplits/splits/c13.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 12. File Attachments */ 2 | 3 | /* 4 | * cpdf_attachFile(filename, pdf) attaches a file to the pdf. It is attached 5 | * at document level. 6 | */ 7 | void cpdf_attachFile(const char[], int); 8 | 9 | /* 10 | * cpdf_attachFileToPage(filename, pdf, pagenumber) attaches a file, given 11 | * its file name, pdf, and the page number to which it should be attached. 12 | */ 13 | void cpdf_attachFileToPage(const char[], int, int); 14 | 15 | /* 16 | * cpdf_attachFileFromMemory(memory, length, filename, pdf) attaches from 17 | * memory, just like cpdf_attachFile. 18 | */ 19 | void cpdf_attachFileFromMemory(void *, int, const char[], int); 20 | 21 | /* 22 | * cpdf_attachFileToPageFromMemory(memory, length, filename, pdf, pagenumber) 23 | * attaches from memory, just like cpdf_attachFileToPage. 24 | */ 25 | void cpdf_attachFileToPageFromMemory(void *, int, const char[], int, int); 26 | 27 | /* Remove all page- and document-level attachments from a document. */ 28 | void cpdf_removeAttachedFiles(int); 29 | 30 | /* 31 | * List information about attachments. Call cpdf_startGetAttachments(pdf) 32 | * first, then cpdf_numberGetAttachments to find out how many there are. Then 33 | * cpdf_getAttachmentName etc. to return each one 0...(n - 1). Finally, call 34 | * cpdf_endGetAttachments to clean up. 35 | */ 36 | void cpdf_startGetAttachments(int); 37 | 38 | /* Get the number of attachments. */ 39 | int cpdf_numberGetAttachments(void); 40 | 41 | /* Get the name of the attachment. */ 42 | char *cpdf_getAttachmentName(int); 43 | 44 | /* Gets the page number. 0 = document level. */ 45 | int cpdf_getAttachmentPage(int); 46 | 47 | /* 48 | * cpdf_getAttachmentData(serial number, length) returns a pointer to the 49 | * data, and its length. 50 | */ 51 | void *cpdf_getAttachmentData(int, int *); 52 | 53 | /* Clean up after getting attachments. */ 54 | void cpdf_endGetAttachments(void); 55 | 56 | -------------------------------------------------------------------------------- /html_manual/javasplits/c10.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 9. Multipage facilities */ 2 | 3 | /** Imposes a PDF. 4 | @param pdf PDF document 5 | @param x x parameter 6 | @param y y parameter 7 | @param fit <code>true</code>: impose to fit a page of size x by y; 8 | <code>false</code>: impose x by y 9 | @param columns imposes by columns rather than rows 10 | @param rtl impose right-to-left 11 | @param btt impose bottom-to-top 12 | @param center unused for now 13 | @param margin margin around the output 14 | @param spacing spacing between imposed inputs */ 15 | public native void impose(Pdf pdf, double x, double y, boolean fit, 16 | boolean columns, boolean rtl, boolean btt, 17 | boolean center, double margin, double spacing, 18 | double linewidth) 19 | throws CpdfError; 20 | 21 | /** Imposes a document two up. twoUp does so by shrinking the page size, to 22 | fit two pages on one. */ 23 | public native void twoUp(Pdf pdf) throws CpdfError; 24 | 25 | /** Imposes a document two up. twoUpStack does so by doubling the page 26 | size, to fit two pages on one. */ 27 | public native void twoUpStack(Pdf pdf) throws CpdfError; 28 | 29 | /** Adds a blank page before each page in the given range. */ 30 | public native void padBefore(Pdf pdf, Range range) throws CpdfError; 31 | 32 | /** Adds a blank page after each page in the given range. */ 33 | public native void padAfter(Pdf pdf, Range range) throws CpdfError; 34 | 35 | /** Adds a blank page after every n pages. */ 36 | public native void padEvery(Pdf pdf, int n) throws CpdfError; 37 | 38 | /** Adds pages at the end to pad the file to a multiple of n pages in 39 | length. */ 40 | public native void padMultiple(Pdf pdf, int n) throws CpdfError; 41 | 42 | /** Adds pages at the beginning to pad the file to a multiple of n pages in 43 | length. */ 44 | public native void padMultipleBefore(Pdf pdf, int n) throws CpdfError; 45 | -------------------------------------------------------------------------------- /cpdfbookmarks.mli: -------------------------------------------------------------------------------- 1 | (** Bookmarks *) 2 | 3 | (** [parse_bookmark_file verify pdf input] parses the bookmark file in [input]. 4 | Details of the bookmark file format can be found in cpdfmanual.pdf. *) 5 | val parse_bookmark_file : bool -> Pdf.t -> Pdfio.input -> Pdfmarks.t list 6 | 7 | (** [add_bookmarks verify input pdf] adds bookmarks from the bookmark file 8 | give. If [verify] is given, bookmarks will be verified to ensure, for example, 9 | that they are not out of the page range. In the new JSON format if chosen. *) 10 | val add_bookmarks : json:bool -> bool -> Pdfio.input -> Pdf.t -> Pdf.t 11 | 12 | (** [list_bookmarks encoding range pdf output] lists the bookmarks to the given 13 | output in the format specified in cpdfmanual.pdf. In the new JSON format if 14 | chosen. *) 15 | val list_bookmarks : json:bool -> json_preserve_actions:bool -> Cpdfmetadata.encoding -> int list -> Pdf.t -> Pdfio.output -> unit 16 | 17 | (** Get bookmarks in JSON format. *) 18 | val get_bookmarks_json : json_preserve_actions:bool -> Pdf.t -> Pdfio.bytes 19 | 20 | (** [name_of_spec encoding marks pdf splitlevel spec n filename startpage 21 | endpage] expands a bookmark specifiation filename. *) 22 | val name_of_spec : Cpdfmetadata.encoding -> 23 | Pdfmarks.t list -> 24 | Pdf.t -> int -> string -> int -> string -> int -> int -> string 25 | 26 | (** Indent bookmarks in each file by one and add a title bookmark pointing to 27 | the first page. If the boolean is set, then use the PDF's metadata title 28 | instead of the filename. *) 29 | val add_bookmark_title : string -> bool -> Pdf.t -> Pdf.t 30 | 31 | (** Set bookmarks to be open to the given level. *) 32 | val bookmarks_open_to_level : int -> Pdf.t -> Pdf.t 33 | 34 | (** Alter bookmark destinations given a hash table of (old page reference 35 | number, new page reference number) pairings *) 36 | val change_bookmark : (int, int) Hashtbl.t -> Pdfmarks.t -> Pdfmarks.t 37 | -------------------------------------------------------------------------------- /cpdfpagelabels.ml: -------------------------------------------------------------------------------- 1 | open Pdfutil 2 | 3 | (* Split the given range (which is in order) into multiple contiguous ones. *) 4 | let rec ranges_of_range curr prev = function 5 | | [] -> begin match curr with [] -> rev prev | _ -> rev (rev curr::prev) end 6 | | x::xs -> 7 | match curr with 8 | | [] -> ranges_of_range [x] prev xs 9 | | c::cs when x = c + 1 -> ranges_of_range (x::curr) prev xs 10 | | cs -> ranges_of_range [x] (rev cs::prev) xs 11 | 12 | (* Predicate which is true if at least one page range starts at page 1 *) 13 | let page1 labels = 14 | mem true (map (function l -> l.Pdfpagelabels.startpage = 1) labels) 15 | 16 | let add_page_labels pdf progress style prefix startval range = 17 | let ranges = map extremes (ranges_of_range [] [] range) 18 | and labels = Pdfpagelabels.read pdf in 19 | assert (length ranges > 0); 20 | let startval_additions = 21 | let r = ref [] in 22 | let sofar = ref 0 in 23 | iter (fun (s, e) -> r := !sofar :: !r; sofar := e - s + 1 + !sofar) ranges; 24 | rev !r 25 | in 26 | let labels = 27 | if not (page1 labels) then 28 | ref 29 | ({Pdfpagelabels.labelstyle = Pdfpagelabels.DecimalArabic; 30 | Pdfpagelabels.labelprefix = None; 31 | Pdfpagelabels.startpage = 1; 32 | Pdfpagelabels.startvalue = 1}::labels) 33 | else 34 | ref labels 35 | in 36 | iter2 37 | (fun (s, e) addition -> 38 | let label = 39 | {Pdfpagelabels.labelstyle = style; 40 | Pdfpagelabels.labelprefix = prefix; 41 | Pdfpagelabels.startpage = s; 42 | Pdfpagelabels.startvalue = startval + if progress then addition else 0} 43 | in 44 | labels := Pdfpagelabels.add_label (Pdfpage.endpage pdf) !labels label e) 45 | ranges 46 | startval_additions; 47 | Pdfpagelabels.write pdf !labels 48 | -------------------------------------------------------------------------------- /docsplits/pysplits/c10.tex: -------------------------------------------------------------------------------- 1 | def twoUp(pdf): 2 | """Impose a document two up by retaining the existing page size, scaling 3 | pages down.""" 4 | 5 | def twoUpStack(pdf): 6 | """Impose a document two up by doubling the page size, to fit two pages on 7 | one.""" 8 | 9 | def impose(pdf, x, y, fit, columns, rtl, btt, center, margin, spacing, linewidth): 10 | """Impose a PDF. There are two modes: imposing x * y, or imposing to fit a 11 | page of size x * y. This is controlled by fit. Columns imposes by columns 12 | rather than rows. rtl is right-to-left, btt bottom-to-top. Center is unused 13 | for now. Margin is the margin around the output, spacing the spacing 14 | between imposed inputs.""" 15 | 16 | def chop(pdf, r, x, y, columns, rtl, btt): 17 | """Chop each page in the range into x * y pieces. If columns is set, the 18 | pieces go by columns instead of rows. If rtl is set, the pieces are taken 19 | right-to-left. If btt is set, the pieces are taken from bottom to top. """ 20 | 21 | def chopH(pdf, r, columns, y): 22 | """Chop each page in the range horizontally at position y. If columns is 23 | set, the pieces are arranged in reverse order. """ 24 | 25 | def chopV(pdf, r, columns, x): 26 | """Chop each page in the range vertically at position x. If columns is 27 | set, the pieces are arranged in reverse order. """ 28 | 29 | def padBefore(pdf, r): 30 | """Adds a blank page before each page in the given range.""" 31 | 32 | def padAfter(pdf, r): 33 | """Adds a blank page after each page in the given range.""" 34 | 35 | def padEvery(pdf, n): 36 | """Adds a blank page after every n pages.""" 37 | 38 | def padMultiple(pdf, n): 39 | """Adds pages at the end to pad the file to a multiple of n pages in 40 | length.""" 41 | 42 | def padMultipleBefore(pdf, n): 43 | """Adds pages at the beginning to pad the file to a multiple of n pages in 44 | length.""" 45 | -------------------------------------------------------------------------------- /docsplits/splits/c01.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 0. Preliminaries */ 2 | 3 | /* The function cpdf_startup(argv) must be called before using the library. */ 4 | void cpdf_startup(char **); 5 | 6 | /* Return the version of the cpdflib library as a string */ 7 | char *cpdf_version(); 8 | 9 | /* 10 | * Some operations have a fast mode. The default is 'slow' mode, which works 11 | * even on old-fashioned files. For more details, see section 1.13 of the 12 | * CPDF manual. These functions set the mode globally. 13 | */ 14 | void cpdf_setFast(); 15 | void cpdf_setSlow(); 16 | 17 | /* Calling this function with a true argument sets embedding for the Standard 18 | * 14 fonts. You must also set the directory to load them from with the 19 | * cpdf_embedStd14Dir function. Default value: false. */ 20 | void cpdf_embedStd14(int); 21 | 22 | /* Set the directory to load Standard 14 fonts for embedding. */ 23 | void cpdf_embedStd14Dir(char *); 24 | 25 | /* 26 | * Errors. cpdf_lastError and cpdf_lastErrorString hold information about the 27 | * last error to have occurred. They should be consulted after each call. If 28 | * cpdf_lastError is non-zero, there was an error, and cpdf_lastErrorString 29 | * gives details. If cpdf_lastError is zero, there was no error on the most 30 | * recent cpdf call. 31 | */ 32 | extern int cpdf_lastError; 33 | extern char *cpdf_lastErrorString; 34 | 35 | /* In some contexts, for example, .NET or JNI, constants in DLLs can be 36 | * difficult or impossible to access. We provide functions in addition. */ 37 | int cpdf_fLastError(void); 38 | char *cpdf_fLastErrorString(void); 39 | 40 | /* cpdf_clearError clears the current error state. */ 41 | void cpdf_clearError(void); 42 | 43 | /* 44 | * cpdf_onExit is a debug function which prints some information about 45 | * resource usage. This can be used to detect if PDFs or ranges are being 46 | * deallocated properly. Contrary to its name, it may be run at any time. 47 | */ 48 | void cpdf_onExit(void); 49 | 50 | -------------------------------------------------------------------------------- /docsplits/pysplits/c20.tex: -------------------------------------------------------------------------------- 1 | def draft(pdf, r, boxes): 2 | """Remove images on the given pages, replacing them with crossed boxes if 3 | 'boxes' is True.""" 4 | 5 | def removeAllText(pdf, r): 6 | """Remove all text from the given pages in a document.""" 7 | 8 | def blackText(pdf, r): 9 | """Blacken all text on the given pages.""" 10 | 11 | def blackLines(pdf, r): 12 | """Blacken all lines on the given pages.""" 13 | 14 | def blackFills(pdf, r): 15 | """Blacken all fills on the given pages.""" 16 | 17 | def thinLines(pdf, r, linewidth): 18 | """Thicken every line less than linewidth to linewidth. Thickness given in 19 | points.""" 20 | 21 | def copyId(pdf, pdf2): 22 | """Copy the /ID from one pdf to pdf2.""" 23 | 24 | def removeId(pdf): 25 | """Remove a document's /ID""" 26 | 27 | def setVersion(pdf, version): 28 | """Set the minor version number of a document.""" 29 | 30 | def setFullVersion(pdf, major, minor): 31 | """Set the major and minor version number of a document.""" 32 | 33 | def removeDictEntry(pdf, key): 34 | """Remove any dictionary entry with the given key anywhere in the 35 | document.""" 36 | 37 | def removeDictEntrySearch(pdf, key, searchterm): 38 | """Remove any dictionary entry with the given key anywhere in the document, 39 | if its value matches the given search term.""" 40 | 41 | def replaceDictEntry(pdf, key, newvalue): 42 | """Replace any dictionary entry with the given key anywhere in the document 43 | using the new value given.""" 44 | 45 | def replaceDictEntrySearch(pdf, key, newvalue, searchterm): 46 | """Replace any dictionary entry with the given key anywhere in the 47 | document, if its value matches the given search term, with the new value 48 | given.""" 49 | 50 | def getDictEntries(pdf, key): 51 | """Return JSON of any dict entries with the given key.""" 52 | 53 | def removeClipping(pdf, r): 54 | """Remove all clipping from pages in the given range""" 55 | -------------------------------------------------------------------------------- /docsplits/dotnetsplits/c19.tex: -------------------------------------------------------------------------------- 1 | CHAPTER 18. Miscellaneous 2 | 3 | Cpdf.draft(Cpdf.Pdf, List{Int32}, Boolean) 4 | 5 | Removes images on the given pages, replacing them with crossed boxes if 'boxes' 6 | is true. 7 | 8 | Cpdf.removeAllText(Cpdf.Pdf, List{Int32}) 9 | 10 | Removes all text from the given pages in a given document. 11 | 12 | Cpdf.blackText(Cpdf.Pdf, List{Int32}) 13 | 14 | Blackens all text on the given pages. 15 | 16 | Cpdf.blackLines(Cpdf.Pdf, List{Int32}) 17 | 18 | Blackens all lines on the given pages. 19 | 20 | Cpdf.blackFills(Cpdf.Pdf, List{Int32}) 21 | 22 | Blackens all fills on the given pages. 23 | 24 | Cpdf.thinLines(Cpdf.Pdf, List{Int32}, Double) 25 | 26 | Thickens every line less than min_thickness to min_thickness. Thickness given 27 | in points. 28 | 29 | Cpdf.copyId(Cpdf.Pdf, Cpdf.Pdf) 30 | 31 | Copies the /ID from one document to another. 32 | 33 | Cpdf.removeId(Cpdf.Pdf) 34 | 35 | Removes a document's /ID. 36 | 37 | Cpdf.setVersion(Cpdf.Pdf, Int32) 38 | 39 | Sets the minor version number of a document. 40 | 41 | Cpdf.setFullVersion(Cpdf.Pdf, Int32, Int32) 42 | 43 | Sets the full version number of a document. 44 | 45 | Cpdf.removeDictEntry(Cpdf.Pdf, String) 46 | 47 | Removes any dictionary entry with the given key anywhere in the document. 48 | 49 | Cpdf.removeDictEntrySearch(Cpdf.Pdf, String, String) 50 | 51 | Removes any dictionary entry with the given key whose value matches the given 52 | search term. 53 | 54 | Cpdf.replaceDictEntry(Cpdf.Pdf, String, String) 55 | 56 | Replaces the value associated with the given key. 57 | 58 | Cpdf.replaceDictEntrySearch(Cpdf.Pdf, String, String, String) 59 | 60 | Replaces the value associated with the given key if the existing value matches 61 | the search term. 62 | 63 | Cpdf.removeClipping(Cpdf.Pdf, List{Int32}) 64 | 65 | Removes all clipping from pages in the given range. 66 | 67 | Cpdf.getDictEntries(Cpdf.Pdf, String) 68 | 69 | Returns a JSON array containing any and all values associated with the given 70 | key, and fills in its length. 71 | -------------------------------------------------------------------------------- /html_manual/dotnetsplits/c19.tex: -------------------------------------------------------------------------------- 1 | CHAPTER 18. Miscellaneous 2 | 3 | Cpdf.draft(Cpdf.Pdf, List{Int32}, Boolean) 4 | 5 | Removes images on the given pages, replacing them with crossed boxes if 'boxes' 6 | is true. 7 | 8 | Cpdf.removeAllText(Cpdf.Pdf, List{Int32}) 9 | 10 | Removes all text from the given pages in a given document. 11 | 12 | Cpdf.blackText(Cpdf.Pdf, List{Int32}) 13 | 14 | Blackens all text on the given pages. 15 | 16 | Cpdf.blackLines(Cpdf.Pdf, List{Int32}) 17 | 18 | Blackens all lines on the given pages. 19 | 20 | Cpdf.blackFills(Cpdf.Pdf, List{Int32}) 21 | 22 | Blackens all fills on the given pages. 23 | 24 | Cpdf.thinLines(Cpdf.Pdf, List{Int32}, Double) 25 | 26 | Thickens every line less than min_thickness to min_thickness. Thickness given 27 | in points. 28 | 29 | Cpdf.copyId(Cpdf.Pdf, Cpdf.Pdf) 30 | 31 | Copies the /ID from one document to another. 32 | 33 | Cpdf.removeId(Cpdf.Pdf) 34 | 35 | Removes a document's /ID. 36 | 37 | Cpdf.setVersion(Cpdf.Pdf, Int32) 38 | 39 | Sets the minor version number of a document. 40 | 41 | Cpdf.setFullVersion(Cpdf.Pdf, Int32, Int32) 42 | 43 | Sets the full version number of a document. 44 | 45 | Cpdf.removeDictEntry(Cpdf.Pdf, String) 46 | 47 | Removes any dictionary entry with the given key anywhere in the document. 48 | 49 | Cpdf.removeDictEntrySearch(Cpdf.Pdf, String, String) 50 | 51 | Removes any dictionary entry with the given key whose value matches the given 52 | search term. 53 | 54 | Cpdf.replaceDictEntry(Cpdf.Pdf, String, String) 55 | 56 | Replaces the value associated with the given key. 57 | 58 | Cpdf.replaceDictEntrySearch(Cpdf.Pdf, String, String, String) 59 | 60 | Replaces the value associated with the given key if the existing value matches 61 | the search term. 62 | 63 | Cpdf.removeClipping(Cpdf.Pdf, List{Int32}) 64 | 65 | Removes all clipping from pages in the given range. 66 | 67 | Cpdf.getDictEntries(Cpdf.Pdf, String) 68 | 69 | Returns a JSON array containing any and all values associated with the given 70 | key, and fills in its length. 71 | -------------------------------------------------------------------------------- /html_manual/pysplits/c19.tex: -------------------------------------------------------------------------------- 1 | # CHAPTER 18. Miscellaneous 2 | 3 | def draft(pdf, r, boxes): 4 | """Remove images on the given pages, replacing 5 | them with crossed boxes if 'boxes' is True.""" 6 | 7 | def removeAllText(pdf, r): 8 | """Remove all text from the given pages in a document.""" 9 | 10 | def blackText(pdf, r): 11 | """Blacken all text on the given pages.""" 12 | 13 | def blackLines(pdf, r): 14 | """Blacken all lines on the given pages.""" 15 | 16 | def blackFills(pdf, r): 17 | """Blacken all fills on the given pages.""" 18 | 19 | def thinLines(pdf, r, linewidth): 20 | """Thicken every line less than 21 | linewidth to linewidth. Thickness given in points.""" 22 | 23 | def copyId(pdf, pdf2): 24 | """Copy the /ID from one pdf to pdf2.""" 25 | 26 | def removeId(pdf): 27 | """Remove a document's /ID""" 28 | 29 | def setVersion(pdf, version): 30 | """Set the minor version number of a document.""" 31 | 32 | def setFullVersion(pdf, major, minor): 33 | """Set the major and minor version number of 34 | a document.""" 35 | 36 | def removeDictEntry(pdf, key): 37 | """Remove any dictionary entry with the given 38 | key anywhere in the document.""" 39 | 40 | def removeDictEntrySearch(pdf, key, searchterm): 41 | """Remove any dictionary entry with the given 42 | key anywhere in the document, if its value matches the given search term.""" 43 | 44 | def replaceDictEntry(pdf, key, newvalue): 45 | """Replace any dictionary entry with the given 46 | key anywhere in the document using the new value given.""" 47 | 48 | def replaceDictEntrySearch(pdf, key, newvalue, searchterm): 49 | """Replace any dictionary entry with the given key anywhere in the 50 | document, if its value matches the given search term, with the new value 51 | given.""" 52 | 53 | def getDictEntries(pdf, key): 54 | """Return JSON of any dict entries with the given key.""" 55 | 56 | def removeClipping(pdf, r): 57 | """Remove all clipping from pages in the given range""" 58 | -------------------------------------------------------------------------------- /docsplits/splits/c18.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 17. Creating New PDFs */ 2 | 3 | /* cpdf_blankDocument(width, height, num_pages) creates a blank document with 4 | * pages of the given width (in points), height (in points), and number of 5 | * pages. 6 | */ 7 | int cpdf_blankDocument(double, double, int); 8 | 9 | /* 10 | * cpdf_blankDocumentPaper(papersize, num_pages) makes a blank document given 11 | * a page size and number of pages. 12 | */ 13 | int cpdf_blankDocumentPaper(enum cpdf_papersize, int); 14 | 15 | /* cpdf_textToPDF(w, h, font, fontsize, filename) typesets a UTF8 text file 16 | * ragged right on a page of size w * h in points in the given font and font 17 | * size. */ 18 | int cpdf_textToPDF(double, double, const char[], double, const char[]); 19 | 20 | /* cpdf_textToPDFMemory(w, h, font, fontsize, data, length) typesets a UTF8 text 21 | * file ragged right on a page of size w * h in points in the given font and 22 | * font size. */ 23 | int cpdf_textToPDFMemory(double, double, const char[], double, void *, int); 24 | 25 | /* cpdf_textToPDF(papersize, font, fontsize, filename) typesets a UTF8 text file 26 | * ragged right on a page of the given size in the given font and font size. */ 27 | int cpdf_textToPDFPaper(int, const char[], double, const char[]); 28 | 29 | /* cpdf_textToPDFMemory(papersize font, fontsize, data, length) typesets a UTF8 30 | * text file ragged right on a page of the given size in the given font and 31 | * font size. */ 32 | int cpdf_textToPDFPaperMemory(int, const char[], double, void *, int); 33 | 34 | /* cpdf_fromPNG(filename) builds a PDF from a non-interlaced non-transparent 35 | * PNG. */ 36 | int cpdf_fromPNG(const char[]); 37 | 38 | /* cpdf_fromPNGMemory(data, length) builds a PDF from a non-interlaced 39 | * non-transparent PNG. */ 40 | int cpdf_fromPNGMemory(void *, int); 41 | 42 | /* cpdf_fromJPEG(filename) builds a PDF from a JPEG. */ 43 | int cpdf_fromJPEG(const char[]); 44 | 45 | /* cpdf_fromJPEGMemory(data, length) builds a PDF from a JPEG. */ 46 | int cpdf_fromJPEGMemory(void *, int); 47 | 48 | -------------------------------------------------------------------------------- /docsplits/dotnetsplits/c07.tex: -------------------------------------------------------------------------------- 1 | CHAPTER 6. Bookmarks 2 | 3 | Cpdf.startGetBookmarkInfo(Cpdf.Pdf) 4 | 5 | Starts the bookmark retrieval process for a given PDF. 6 | 7 | Cpdf.numberBookmarks 8 | 9 | Gets the number of bookmarks for the PDF given to startGetBookmarkInfo. 10 | 11 | Cpdf.getBookmarkLevel(Int32) 12 | 13 | Gets the bookmark level for the given bookmark (0...(n - 1)). 14 | 15 | Cpdf.getBookmarkPage(Cpdf.Pdf, Int32) 16 | 17 | Gets the bookmark target page for the given PDF (which must be the same as the 18 | PDF passed to startSetBookmarkInfo) and bookmark (0...(n - 1)). 19 | 20 | Cpdf.getBookmarkText(Int32) 21 | 22 | Returns the text of bookmark (0...(n - 1)). 23 | 24 | Cpdf.getBookmarkOpenStatus(Int32) 25 | 26 | True if the bookmark is open. 27 | 28 | Cpdf.endGetBookmarkInfo 29 | 30 | Ends the bookmark retrieval process, cleaning up. 31 | 32 | Cpdf.startSetBookmarkInfo(Int32) 33 | 34 | Starts the bookmark setting process for n bookmarks. 35 | 36 | Cpdf.setBookmarkLevel(Int32, Int32) 37 | 38 | Set bookmark level for the given bookmark (0...(n - 1)). 39 | 40 | Cpdf.setBookmarkPage(Cpdf.Pdf, Int32, Int32) 41 | 42 | Sets the bookmark target page for the given PDF (which must be the same as the 43 | PDF to be passed to endSetBookmarkInfo) and bookmark (0...(n - 1)). 44 | 45 | Cpdf.setBookmarkOpenStatus(Int32, Boolean) 46 | 47 | Sets the open status of bookmark (0...(n - 1)). 48 | 49 | Cpdf.setBookmarkText(Int32, String) 50 | 51 | Sets the text of bookmark (0...(n - 1)). 52 | 53 | Cpdf.endSetBookmarkInfo(Cpdf.Pdf) 54 | 55 | Ends the bookmark setting process, writing the bookmarks to the given PDF. 56 | 57 | Cpdf.getBookmarksJSON(Cpdf.Pdf) 58 | 59 | Returns the bookmark data in JSON format. 60 | 61 | Cpdf.setBookmarksJSON(Cpdf.Pdf, Byte[]) 62 | 63 | Sets the bookmarks from JSON bookmark data. 64 | 65 | Cpdf.tableOfContents(Cpdf.Pdf, Cpdf.Font, Double, String, Boolean) 66 | 67 | Typesets a table of contents from existing bookmarks and prepends it to the 68 | document. If bookmark is set, the table of contents gets its own bookmark. 69 | -------------------------------------------------------------------------------- /html_manual/dotnetsplits/c07.tex: -------------------------------------------------------------------------------- 1 | CHAPTER 6. Bookmarks 2 | 3 | Cpdf.startGetBookmarkInfo(Cpdf.Pdf) 4 | 5 | Starts the bookmark retrieval process for a given PDF. 6 | 7 | Cpdf.numberBookmarks 8 | 9 | Gets the number of bookmarks for the PDF given to startGetBookmarkInfo. 10 | 11 | Cpdf.getBookmarkLevel(Int32) 12 | 13 | Gets the bookmark level for the given bookmark (0...(n - 1)). 14 | 15 | Cpdf.getBookmarkPage(Cpdf.Pdf, Int32) 16 | 17 | Gets the bookmark target page for the given PDF (which must be the same as the 18 | PDF passed to startSetBookmarkInfo) and bookmark (0...(n - 1)). 19 | 20 | Cpdf.getBookmarkText(Int32) 21 | 22 | Returns the text of bookmark (0...(n - 1)). 23 | 24 | Cpdf.getBookmarkOpenStatus(Int32) 25 | 26 | True if the bookmark is open. 27 | 28 | Cpdf.endGetBookmarkInfo 29 | 30 | Ends the bookmark retrieval process, cleaning up. 31 | 32 | Cpdf.startSetBookmarkInfo(Int32) 33 | 34 | Starts the bookmark setting process for n bookmarks. 35 | 36 | Cpdf.setBookmarkLevel(Int32, Int32) 37 | 38 | Set bookmark level for the given bookmark (0...(n - 1)). 39 | 40 | Cpdf.setBookmarkPage(Cpdf.Pdf, Int32, Int32) 41 | 42 | Sets the bookmark target page for the given PDF (which must be the same as the 43 | PDF to be passed to endSetBookmarkInfo) and bookmark (0...(n - 1)). 44 | 45 | Cpdf.setBookmarkOpenStatus(Int32, Boolean) 46 | 47 | Sets the open status of bookmark (0...(n - 1)). 48 | 49 | Cpdf.setBookmarkText(Int32, String) 50 | 51 | Sets the text of bookmark (0...(n - 1)). 52 | 53 | Cpdf.endSetBookmarkInfo(Cpdf.Pdf) 54 | 55 | Ends the bookmark setting process, writing the bookmarks to the given PDF. 56 | 57 | Cpdf.getBookmarksJSON(Cpdf.Pdf) 58 | 59 | Returns the bookmark data in JSON format. 60 | 61 | Cpdf.setBookmarksJSON(Cpdf.Pdf, Byte[]) 62 | 63 | Sets the bookmarks from JSON bookmark data. 64 | 65 | Cpdf.tableOfContents(Cpdf.Pdf, Cpdf.Font, Double, String, Boolean) 66 | 67 | Typesets a table of contents from existing bookmarks and prepends it to the 68 | document. If bookmark is set, the table of contents gets its own bookmark. 69 | -------------------------------------------------------------------------------- /docsplits/javascriptsplits/c18.tex: -------------------------------------------------------------------------------- 1 | // CHAPTER 17. Creating new PDFs 2 | 3 | /** Creates a blank document with pages of the given width (in points), height 4 | (in points), and number of pages. 5 | @arg {number} w page width 6 | @arg {number} h page height 7 | @arg {number} number of pages 8 | @return {pdf} PDF document */ 9 | function blankDocument(w, h, pages) {} 10 | 11 | /** Makes a blank document given a page size and number of pages. 12 | @arg {"paper size"} papersize paper size 13 | @arg {number} pages number of pages 14 | @return {pdf} PDF document */ 15 | function blankDocumentPaper(papersize, pages) {} 16 | 17 | /** Typesets a UTF8 text file ragged right on a page of size w * h in points 18 | in the given font and font size. 19 | @arg {number} w page width 20 | @arg {number} h page height 21 | @arg {font} font font 22 | @arg {number} fontsize font size 23 | @arg {string} filename file name 24 | @result {pdf} PDF document */ 25 | function textToPDF(w, h, font, fontsize, filename) {} 26 | 27 | /** Typesets a UTF8 text file ragged right on a page of size w * h in points 28 | in the given font and font size. 29 | @arg {number} w page width 30 | @arg {number} h page height 31 | @arg {font} font font 32 | @arg {number} fontsize font size 33 | @arg {Uint8Array} data text 34 | @result {pdf} PDF document */ 35 | function textToPDFMemory(w, h, font, fontsize, data) {} 36 | 37 | /** Typesets a UTF8 text file ragged right on a page of the given size in the 38 | given font and font size. 39 | @arg {"paper size"} papersize paper size 40 | @arg {font} font font 41 | @arg {number} fontsize font size 42 | @arg {string} filename file name 43 | @result {pdf} PDF document */ 44 | function textToPDFPaper(papersize, font, fontsize, filename) {} 45 | 46 | /** Typesets a UTF8 text file ragged right on a page of the given size in the 47 | given font and font size. 48 | @arg {"paper size"} papersize paper size 49 | @arg {font} font font 50 | @arg {number} fontsize font size 51 | @arg {Uint8Array} data text 52 | @result {pdf} PDF document */ 53 | function textToPDFPaperMemory(papersize, font, fontsize, data) {} 54 | 55 | -------------------------------------------------------------------------------- /html_manual/javascriptsplits/c18.tex: -------------------------------------------------------------------------------- 1 | // CHAPTER 17. Creating new PDFs 2 | 3 | /** Creates a blank document with pages of the given width (in points), height 4 | (in points), and number of pages. 5 | @arg {number} w page width 6 | @arg {number} h page height 7 | @arg {number} number of pages 8 | @return {pdf} PDF document */ 9 | function blankDocument(w, h, pages) {} 10 | 11 | /** Makes a blank document given a page size and number of pages. 12 | @arg {"paper size"} papersize paper size 13 | @arg {number} pages number of pages 14 | @return {pdf} PDF document */ 15 | function blankDocumentPaper(papersize, pages) {} 16 | 17 | /** Typesets a UTF8 text file ragged right on a page of size w * h in points 18 | in the given font and font size. 19 | @arg {number} w page width 20 | @arg {number} h page height 21 | @arg {font} font font 22 | @arg {number} fontsize font size 23 | @arg {string} filename file name 24 | @result {pdf} PDF document */ 25 | function textToPDF(w, h, font, fontsize, filename) {} 26 | 27 | /** Typesets a UTF8 text file ragged right on a page of size w * h in points 28 | in the given font and font size. 29 | @arg {number} w page width 30 | @arg {number} h page height 31 | @arg {font} font font 32 | @arg {number} fontsize font size 33 | @arg {Uint8Array} data text 34 | @result {pdf} PDF document */ 35 | function textToPDFMemory(w, h, font, fontsize, data) {} 36 | 37 | /** Typesets a UTF8 text file ragged right on a page of the given size in the 38 | given font and font size. 39 | @arg {"paper size"} papersize paper size 40 | @arg {font} font font 41 | @arg {number} fontsize font size 42 | @arg {string} filename file name 43 | @result {pdf} PDF document */ 44 | function textToPDFPaper(papersize, font, fontsize, filename) {} 45 | 46 | /** Typesets a UTF8 text file ragged right on a page of the given size in the 47 | given font and font size. 48 | @arg {"paper size"} papersize paper size 49 | @arg {font} font font 50 | @arg {number} fontsize font size 51 | @arg {Uint8Array} data text 52 | @result {pdf} PDF document */ 53 | function textToPDFPaperMemory(papersize, font, fontsize, data) {} 54 | 55 | -------------------------------------------------------------------------------- /cpdfimage.mli: -------------------------------------------------------------------------------- 1 | (** Images *) 2 | 3 | (** Print info when processing image *) 4 | val debug_image_processing : bool ref 5 | 6 | (** Extract images. *) 7 | val extract_images : 8 | merge_masks:bool -> inline:bool -> ?raw:bool -> ?path_to_p2p:string -> ?path_to_im:string -> 9 | Cpdfmetadata.encoding -> bool -> bool -> Pdf.t -> int list -> string -> unit 10 | 11 | (** Extract single image. *) 12 | val extract_single_image : 13 | merge_masks:bool -> ?raw:bool -> ?path_to_p2p:string -> ?path_to_im:string -> 14 | Cpdfmetadata.encoding -> Pdf.t -> int -> string -> unit 15 | 16 | (** Report image resolutions. *) 17 | val image_resolution : inline:bool -> Pdf.t -> int list -> float -> (int * string * int * int * float * float * int) list 18 | 19 | (** Report image resolution data in JSON format *) 20 | val image_resolution_json : inline:bool -> Pdf.t -> int list -> float -> Pdfio.bytes 21 | 22 | (** List images in JSON format *) 23 | val images : inline:bool -> Pdf.t -> int list -> Cpdfyojson.Safe.t 24 | 25 | (** Reprocess images. See manual for details. *) 26 | val process : 27 | force:bool -> q:float -> qlossless:float -> qlossless2000:float -> onebppmethod:string -> jbig2_lossy_threshold:float -> 28 | length_threshold:int -> percentage_threshold:float -> pixel_threshold:int -> 29 | dpi_threshold:float -> factor:float -> interpolate:bool -> 30 | jpeg_to_jpeg_scale:float -> jpeg_to_jpeg_dpi:float -> 31 | path_to_jbig2dec:string -> path_to_jbig2enc:string -> path_to_convert:string -> int list -> Pdf.t -> unit 32 | 33 | (**/**) 34 | val image_of_input : ?subformat:Cpdfua.subformat -> ?title:string -> process_struct_tree:bool -> (Pdf.t -> Pdfio.bytes -> Pdf.pdfobject * (int * Pdf.pdfobject) list) -> Pdfio.input -> Pdf.t 35 | val obj_of_jpeg_data : path_to_im:string -> Pdfio.bytes -> Pdf.pdfobject * (int * Pdf.pdfobject) list 36 | val obj_of_png_data : Pdf.t -> Pdfio.bytes -> Pdf.pdfobject * (int * Pdf.pdfobject) list 37 | val obj_of_jbig2_data : ?global:Pdfio.bytes -> Pdfio.bytes -> Pdf.pdfobject * (int * Pdf.pdfobject) list 38 | val obj_of_jpeg2000_data : Pdfio.bytes -> Pdf.pdfobject * (int * Pdf.pdfobject) list 39 | -------------------------------------------------------------------------------- /cpdfutil.ml: -------------------------------------------------------------------------------- 1 | open Pdfutil 2 | 3 | let progress = ref false 4 | 5 | let progress_line s = 6 | if !progress then Printf.eprintf "%s\n%!" s 7 | 8 | let progress_line_no_end s = 9 | if !progress then Printf.eprintf "%s%!" s 10 | 11 | let progress_page n = 12 | if !progress then Printf.eprintf "%i%!" n 13 | 14 | let progress_endpage () = 15 | if !progress then Printf.eprintf ".%!" 16 | 17 | let progress_done () = 18 | if !progress then Printf.eprintf "\n%!" 19 | 20 | let rec dict_entry_single_object f pdf = function 21 | | (Pdf.Dictionary d) -> f (Pdf.recurse_dict (dict_entry_single_object f pdf) d) 22 | | (Pdf.Stream {contents = (Pdf.Dictionary dict, data)}) -> 23 | f (Pdf.Stream {contents = (Pdf.recurse_dict (dict_entry_single_object f pdf) dict, data)}) 24 | | Pdf.Array a -> Pdf.recurse_array (dict_entry_single_object f pdf) a 25 | | x -> x 26 | 27 | (* FIXME are we sure that functional values can never appear in the equality here? *) 28 | let remove_dict_entry pdf key search = 29 | let f d = 30 | match search with 31 | | None -> Pdf.remove_dict_entry d key 32 | | Some s -> 33 | match Pdf.lookup_direct pdf key d with 34 | | Some v when v = s -> Pdf.remove_dict_entry d key 35 | | _ -> d 36 | in 37 | Pdf.objselfmap (dict_entry_single_object f pdf) pdf; 38 | pdf.Pdf.trailerdict <- dict_entry_single_object f pdf pdf.Pdf.trailerdict 39 | 40 | let replace_dict_entry pdf key value search = 41 | let f d = 42 | match search with 43 | | None -> begin try Pdf.replace_dict_entry d key value with _ -> d end 44 | | Some s -> 45 | match Pdf.lookup_direct pdf key d with 46 | | Some v when v = s -> Pdf.replace_dict_entry d key value 47 | | _ -> d 48 | in 49 | Pdf.objselfmap (dict_entry_single_object f pdf) pdf; 50 | pdf.Pdf.trailerdict <- dict_entry_single_object f pdf pdf.Pdf.trailerdict 51 | 52 | let injectible = function '&' | '|' | '\n' | '`' | '$' -> true | _ -> false 53 | 54 | let check_injectible s = 55 | if List.exists injectible (explode s) then 56 | begin 57 | Pdfe.log "Insecure character in path name. Exiting\n"; 58 | exit 2 59 | end 60 | -------------------------------------------------------------------------------- /docsplits/javascriptsplits/c10.tex: -------------------------------------------------------------------------------- 1 | // CHAPTER 9. Multipage facilities 2 | 3 | /** Imposes a PDF. There are two modes: imposing x * y, or imposing to fit a 4 | page of size x * y. This is controlled by fit. Columns imposes by columns 5 | rather than rows. rtl is right-to-left, btt bottom-to-top. Center is unused 6 | for now. Margin is the margin around the output, spacing the spacing between 7 | imposed inputs. 8 | @arg {pdf} pdf PDF document 9 | @arg {number} x (explained above) 10 | @arg {number} y (explained above) 11 | @arg {boolean} fit (explained above) 12 | @arg {boolean} rtl impose right to left 13 | @arg {boolean} btt impose bottom to top 14 | @arg {boolean} center unused 15 | @arg {number} margin margin around output pages 16 | @arg {number} spacing spacing between imposed pages 17 | @arg {number} linewidth line width */ 18 | function impose(pdf, x, y, fit, columns, rtl, btt, center, margin, spacing, linewidth) {} 19 | 20 | /** Imposes a document two up. twoUp does so by shrinking the page size, to fit 21 | two pages on one. 22 | @arg {pdf} pdf PDF document */ 23 | function twoUp(pdf) {} 24 | 25 | /** Impose a document two up. twoUpStack does so by doubling the page size, 26 | to fit two pages on one. 27 | @arg {pdf} pdf PDF document */ 28 | function twoUpStack(pdf) {} 29 | 30 | /** Adds a blank page before each page in the given range. 31 | @arg {pdf} pdf PDF document 32 | @arg {range} range page range */ 33 | function padBefore(pdf, range) {} 34 | 35 | /** Adds a blank page after every n pages. 36 | @arg {pdf} pdf PDF document 37 | @arg {range} range page range */ 38 | function padAfter(pdf, range) {} 39 | 40 | /** Adds a blank page after every n pages. 41 | @arg {pdf} pdf PDF document 42 | @arg {number} interval */ 43 | function padEvery(pdf, n) {} 44 | 45 | /** Adds pages at the end to pad the file to a multiple of n pages in 46 | length. 47 | @arg {pdf} pdf PDF document 48 | @arg {number} multiple to pad to */ 49 | function padMultiple(pdf, n) {} 50 | 51 | /** Adds pages at the beginning to pad the file to a multiple of n pages in 52 | length. 53 | @arg {pdf} pdf PDF document 54 | @arg {number} multiple to pad to */ 55 | function padMultipleBefore(pdf, n) {} 56 | 57 | -------------------------------------------------------------------------------- /html_manual/javascriptsplits/c10.tex: -------------------------------------------------------------------------------- 1 | // CHAPTER 9. Multipage facilities 2 | 3 | /** Imposes a PDF. There are two modes: imposing x * y, or imposing to fit a 4 | page of size x * y. This is controlled by fit. Columns imposes by columns 5 | rather than rows. rtl is right-to-left, btt bottom-to-top. Center is unused 6 | for now. Margin is the margin around the output, spacing the spacing between 7 | imposed inputs. 8 | @arg {pdf} pdf PDF document 9 | @arg {number} x (explained above) 10 | @arg {number} y (explained above) 11 | @arg {boolean} fit (explained above) 12 | @arg {boolean} rtl impose right to left 13 | @arg {boolean} btt impose bottom to top 14 | @arg {boolean} center unused 15 | @arg {number} margin margin around output pages 16 | @arg {number} spacing spacing between imposed pages 17 | @arg {number} linewidth line width */ 18 | function impose(pdf, x, y, fit, columns, rtl, btt, center, margin, spacing, linewidth) {} 19 | 20 | /** Imposes a document two up. twoUp does so by shrinking the page size, to fit 21 | two pages on one. 22 | @arg {pdf} pdf PDF document */ 23 | function twoUp(pdf) {} 24 | 25 | /** Impose a document two up. twoUpStack does so by doubling the page size, 26 | to fit two pages on one. 27 | @arg {pdf} pdf PDF document */ 28 | function twoUpStack(pdf) {} 29 | 30 | /** Adds a blank page before each page in the given range. 31 | @arg {pdf} pdf PDF document 32 | @arg {range} range page range */ 33 | function padBefore(pdf, range) {} 34 | 35 | /** Adds a blank page after every n pages. 36 | @arg {pdf} pdf PDF document 37 | @arg {range} range page range */ 38 | function padAfter(pdf, range) {} 39 | 40 | /** Adds a blank page after every n pages. 41 | @arg {pdf} pdf PDF document 42 | @arg {number} interval */ 43 | function padEvery(pdf, n) {} 44 | 45 | /** Adds pages at the end to pad the file to a multiple of n pages in 46 | length. 47 | @arg {pdf} pdf PDF document 48 | @arg {number} multiple to pad to */ 49 | function padMultiple(pdf, n) {} 50 | 51 | /** Adds pages at the beginning to pad the file to a multiple of n pages in 52 | length. 53 | @arg {pdf} pdf PDF document 54 | @arg {number} multiple to pad to */ 55 | function padMultipleBefore(pdf, n) {} 56 | 57 | -------------------------------------------------------------------------------- /cpdfportfolio.ml: -------------------------------------------------------------------------------- 1 | open Pdfutil 2 | open Pdfio 3 | 4 | type entry = 5 | {filename : string; 6 | relationship : string option; 7 | description : string option} 8 | 9 | let process_afrelationship = function 10 | | None -> "/Unspecified" 11 | | Some x -> "/" ^ x 12 | 13 | (* Build a PDF portfolio a.k.a collection *) 14 | let portfolio pdf entries = 15 | let embedded_files = 16 | map 17 | (fun e -> 18 | let basename = Filename.basename e.filename in 19 | let bytes = bytes_of_string (contents_of_file e.filename) in 20 | let contents = 21 | Pdf.addobj pdf 22 | (Pdf.Stream {contents = Pdf.Dictionary 23 | [("/Params", Pdf.Dictionary [("/ModDate", Pdf.String (Cpdfmetadata.expand_date "now")); ("/Size", Pdf.Integer (bytes_size bytes))]); 24 | ("/Length", Pdf.Integer (bytes_size bytes))], Pdf.Got bytes}) 25 | in 26 | Pdf.Indirect (Pdf.addobj pdf (Pdf.Dictionary 27 | [("/Type", Pdf.Name "/FileSpec"); 28 | ("/Desc", Pdf.String (match e.description with Some x -> x | None -> basename)); 29 | ("/F", Pdf.String basename); 30 | ("/UF", Pdf.String basename); 31 | ("/AFRelationship", Pdf.Name (process_afrelationship e.relationship)); 32 | ("/EF", Pdf.Dictionary [("/F", Pdf.Indirect contents); ("/UF", Pdf.Indirect contents)])]))) 33 | entries 34 | in 35 | (* We need unique keys, even if basenames are not unique. We use a number 36 | followed by a forward slash. Since the forward slash is illegal in a 37 | filename, prefixing with a number cannot accidentally produce another of 38 | the names. *) 39 | let keys = map (fun (n, e) -> string_of_int n ^ "/" ^ e.filename) (combine (indx0 entries) entries) in 40 | assert (length (setify keys) = length keys); 41 | let name_tree = 42 | Pdf.Indirect (Pdf.addobj pdf (Pdftree.build_name_tree false pdf (map3 (fun k {filename} e -> (k, e)) keys entries embedded_files))) 43 | in 44 | Pdf.replace_chain pdf ["/Root"; "/Names"; "/EmbeddedFiles"] name_tree; 45 | Pdf.replace_chain pdf ["/Root"; "/Collection"] (Pdf.Dictionary [("/View", Pdf.Name "/T")]) 46 | -------------------------------------------------------------------------------- /cpdfpagespec.mli: -------------------------------------------------------------------------------- 1 | (** Page specifications and ranges *) 2 | 3 | (** Here are the rules for building input ranges: 4 | 5 | {ul 6 | {- Page numbers can be given plain, like 1 or 2, or as page labels, like <1> or <iii> (backslash to escape intended angle bracket)} 7 | {- A page label may be used in place of a number e.g [[iii]] represents the first page found which is labelled [iii]. } 8 | {- A dash (-) defines ranges e.g 1-5 or 6-3.} 9 | {- A comma (,) allows one to specify several ranges, e.g. 1-2,4-5.} 10 | {- The word end represents the last page number.} 11 | {- The words odd and even can be used in place of or at the end of a page range to restrict to just the odd or even pages. } 12 | {- The words portrait and landscape can be used in place of or at the end of a page range to restrict to just those pages which are portrait or landscape. Note that the meaning of portrait and landscape does not take account of any viewing rotation in place. A page with equal width and height is considered neither portrait nor landscape.} 13 | {- The word reverse is the same as end-1.} 14 | {- The word all is the same as 1-end.} 15 | {- The word empty is the empty range, containing no pages.} 16 | {- A range must contain no spaces.} 17 | {- A tilde (~) defines a page number counting from the end of the document rather than the beginning. Page ~1 is the last page, ~2 the penultimate page etc.} 18 | {- The word "annotated" refers to only such pages as contain annotations. Restrain with, e.g. "annotated:Highlight".} 19 | {- Prepending NOT to a whole page range inverts it, once the whole is parsed. } 20 | {- Appending DUP2 to a whole page range duplicates each page twice (or 3, or 4 etc. times), once the whole is parsed. } 21 | } 22 | *) 23 | 24 | (** Parse a (valid) page specification to a page range *) 25 | val parse_pagespec : Pdf.t -> string -> int list 26 | 27 | (** Same, but without a PDF. Thus 'end' etc. don't work *) 28 | val parse_pagespec_without_pdf : string -> int list 29 | 30 | (** Return a string for the given range. Knows how to identify all, odd, even, 31 | x-y ranges etc. *) 32 | val string_of_pagespec : Pdf.t -> int list -> string 33 | 34 | (** Invert a range, given the maximum page number and the range. *) 35 | val invert_range : int -> int list -> int list 36 | -------------------------------------------------------------------------------- /cpdfpresent.ml: -------------------------------------------------------------------------------- 1 | (* Build PDF Presentations *) 2 | open Pdfutil 3 | 4 | let change_page_effect t d horizontal inward direction effect_duration page = 5 | let checkname = function 6 | | "Split" | "Blinds" | "Box" | "Wipe" | "Dissolve" | "Glitter" -> () 7 | | _ -> Cpdferror.error "Unknown presentation type" 8 | in 9 | let rest = page.Pdfpage.rest in 10 | let transdict = 11 | match t with 12 | | None -> 13 | Pdf.Dictionary [] 14 | | Some name -> 15 | checkname name; 16 | Pdf.Dictionary [("/S", Pdf.Name ("/" ^ name))] 17 | in 18 | let transdict = Pdf.add_dict_entry transdict "/D" (Pdf.Real effect_duration) in 19 | let transdict = 20 | match t with 21 | | Some ("Split" | "Blinds") -> 22 | Pdf.add_dict_entry 23 | transdict "/Dm" (Pdf.Name (if horizontal then "/H" else "/V")) 24 | | _ -> transdict 25 | in 26 | let transdict = 27 | match t with 28 | | Some ("Split" | "Box") -> 29 | Pdf.add_dict_entry 30 | transdict "/M" (Pdf.Name (if inward then "/I" else "/O")) 31 | | _ -> transdict 32 | in 33 | let transdict = 34 | match t with 35 | | Some ("Wipe" | "Glitter") -> 36 | Pdf.add_dict_entry transdict "/Di" (Pdf.Integer direction) 37 | | _ -> transdict 38 | in 39 | let rest = Pdf.add_dict_entry rest "/Trans" transdict in 40 | let rest = 41 | match d with 42 | | None -> Pdf.remove_dict_entry rest "/Dur" 43 | | Some delay -> Pdf.add_dict_entry rest "/Dur" (Pdf.Real delay) 44 | in 45 | {page with Pdfpage.rest = rest} 46 | 47 | let presentation range t d h i dir effect_dur pdf = 48 | let pages = Pdfpage.pages_of_pagetree pdf in 49 | let pages' = 50 | map2 51 | (fun page num -> 52 | if mem num range 53 | then change_page_effect t d h i dir effect_dur page 54 | else page) 55 | pages 56 | (indx pages) 57 | in 58 | Pdfpage.change_pages true pdf pages' 59 | 60 | -------------------------------------------------------------------------------- /cpdfextracttext.ml: -------------------------------------------------------------------------------- 1 | open Pdfutil 2 | 3 | let extract_page_text only_fontsize pdf _ page = 4 | let text_extractor = ref None in 5 | let right_font_size = ref false in 6 | fold_left ( ^ ) "" 7 | (map 8 | (function 9 | | Pdfops.Op_Tf (fontname, fontsize) -> 10 | right_font_size := 11 | begin match only_fontsize with 12 | Some x -> x = fontsize 13 | | _ -> false 14 | end; 15 | let fontdict = 16 | match Pdf.lookup_direct pdf "/Font" page.Pdfpage.resources with 17 | | None -> raise (Pdf.PDFError "Missing /Font in text extraction") 18 | | Some d -> 19 | match Pdf.lookup_direct pdf fontname d with 20 | | None -> raise (Pdf.PDFError "Missing font in text extraction") 21 | | Some d -> d 22 | in 23 | text_extractor := Some (Pdftext.text_extractor_of_font pdf fontdict); 24 | "" 25 | | Pdfops.Op_Tj text when !text_extractor <> None -> 26 | if not !right_font_size then 27 | "" 28 | else 29 | Pdftext.utf8_of_codepoints 30 | (Pdftext.codepoints_of_text (unopt !text_extractor) text) 31 | | Pdfops.Op_TJ (Pdf.Array objs) when !text_extractor <> None -> 32 | if not !right_font_size then 33 | "" 34 | else 35 | fold_left ( ^ ) "" 36 | (option_map 37 | (function 38 | | Pdf.String text -> 39 | Some 40 | (Pdftext.utf8_of_codepoints 41 | (Pdftext.codepoints_of_text (unopt !text_extractor) text)) 42 | | _ -> None) 43 | objs) 44 | | _ -> "") 45 | (Pdfops.parse_operators pdf page.Pdfpage.resources page.Pdfpage.content)) 46 | 47 | (* For each page, extract all the ops with text in them, and concatenate it all together *) 48 | let extract_text extract_text_font_size pdf range = 49 | fold_left (fun x y -> x ^ (if x <> "" && y <> "" then "\n" else "") ^ y) "" 50 | (Cpdfpage.map_pages (extract_page_text extract_text_font_size pdf) pdf range) 51 | 52 | -------------------------------------------------------------------------------- /cpdfjs.ml: -------------------------------------------------------------------------------- 1 | open Pdfutil 2 | 3 | (* Empty any /JS string, Empty any /URI (javascript:). *) 4 | let remove_javascript pdf = 5 | let rec remove_javascript_single_object f pdf = function 6 | | (Pdf.Dictionary d) -> f (Pdf.recurse_dict (remove_javascript_single_object f pdf) d) 7 | | (Pdf.Stream {contents = (Pdf.Dictionary dict, data)}) -> 8 | f (Pdf.Stream {contents = (Pdf.recurse_dict (remove_javascript_single_object f pdf) dict, data)}) 9 | | Pdf.Array a -> Pdf.recurse_array (remove_javascript_single_object f pdf) a 10 | | x -> x 11 | in 12 | let f d = 13 | let d = 14 | match Pdf.lookup_direct pdf "/JS" d with 15 | | Some _ -> Pdf.add_dict_entry d "/JS" (Pdf.String "") 16 | | None -> d 17 | in 18 | match Pdf.lookup_direct pdf "/URI" d with 19 | | Some (Pdf.String s) when String.length s >= 11 && String.sub s 0 11 = "javascript:" -> Pdf.add_dict_entry d "/URI" (Pdf.String "") 20 | | _ -> d 21 | in 22 | Pdf.objselfmap (remove_javascript_single_object f pdf) pdf; 23 | ignore (Pdf.remove_chain pdf ["/Root"; "/Names"; "/JavaScript"]) 24 | 25 | (* Any dictionary with /S /JavaScript or any /URI (javascript:...) *) 26 | let contains_javascript pdf = 27 | let found = ref false in 28 | let rec contains_javascript_single_object f pdf = function 29 | | (Pdf.Dictionary d) -> f (Pdf.recurse_dict (contains_javascript_single_object f pdf) d) 30 | | (Pdf.Stream {contents = (Pdf.Dictionary dict, data)}) -> 31 | f (Pdf.Stream {contents = (Pdf.recurse_dict (contains_javascript_single_object f pdf) dict, data)}) 32 | | Pdf.Array a -> Pdf.recurse_array (contains_javascript_single_object f pdf) a 33 | | x -> x 34 | in 35 | let f d = 36 | begin match Pdf.lookup_direct pdf "/S" d with 37 | | Some (Pdf.String "/JavaScript") -> set found 38 | | _ -> () 39 | end; 40 | begin match Pdf.lookup_direct pdf "/URI" d with 41 | | Some (Pdf.String s) when String.length s >= 11 && String.sub s 0 11 = "javascript:" -> set found; d 42 | | _ -> d 43 | end 44 | in 45 | Pdf.objiter (fun _ obj -> ignore (contains_javascript_single_object f pdf obj)) pdf; 46 | (* Any /Root -> /Names -> /JavaScript *) 47 | begin match Pdf.lookup_chain pdf pdf.Pdf.trailerdict ["/Root"; "/Names"; "/JavaScript"] with 48 | | Some _ -> set found 49 | | None -> () 50 | end; 51 | !found 52 | -------------------------------------------------------------------------------- /cpdfaddtext.mli: -------------------------------------------------------------------------------- 1 | (** Adding text *) 2 | 3 | (** Colours *) 4 | type colour = 5 | Grey of float 6 | | RGB of float * float * float 7 | | CYMK of float * float * float * float 8 | 9 | (** Build a colour operation for filling with the given colour. *) 10 | val colour_op : colour -> Pdfops.t 11 | 12 | (** Build a colour operation for filing with the given colour *) 13 | val colour_op_stroke : colour -> Pdfops.t 14 | 15 | (** Justification of multiline text *) 16 | type justification = 17 | | LeftJustify 18 | | CentreJustify 19 | | RightJustify 20 | 21 | (** Call [add_texts linewidth outline fast fontname font bates batespad colour 22 | position linespacing fontsize underneath text pages orientation 23 | relative_to_cropbox midline_adjust topline filename pdf]. For details see cpdfmanual.pdf *) 24 | val addtexts : 25 | float -> (*linewidth*) 26 | bool -> (*outline*) 27 | bool -> (*fast*) 28 | string -> (*fontname*) 29 | Cpdfembed.cpdffont -> (*font*) 30 | int -> (* bates number *) 31 | int option -> (* bates padding width *) 32 | colour -> (*colour*) 33 | Cpdfposition.position -> (*position*) 34 | float -> (*linespacing*) 35 | float -> (*fontsize*) 36 | bool -> (*underneath*) 37 | string ->(*text*) 38 | int list ->(*page range*) 39 | bool ->(*relative to cropbox?*) 40 | float ->(*opacity*) 41 | justification ->(*justification*) 42 | bool ->(*midline adjust?*) 43 | bool ->(*topline adjust?*) 44 | string ->(*filename*) 45 | float option -> (*extract_text_font_size*) 46 | string -> (* shift *) 47 | ?raw:bool -> (* raw *) 48 | Pdf.t ->(*pdf*) 49 | Pdf.t 50 | 51 | (** Add a rectangle to the given pages. [addrectangle fast coordinate colour outline linewidth opacity position relative_to_cropbox underneath range pdf]. *) 52 | val addrectangle : 53 | bool -> 54 | string -> 55 | colour -> 56 | bool -> 57 | float -> 58 | float -> 59 | Cpdfposition.position -> 60 | bool -> bool -> int list -> Pdf.t -> Pdf.t 61 | 62 | (**/**) 63 | val replace_pairs : 64 | Pdfmarks.t list -> 65 | (int, int) Hashtbl.t -> 66 | Pdf.t -> 67 | int -> 68 | float option -> 69 | string -> 70 | int -> 71 | int option -> int -> Pdfpage.t -> (string * (unit -> string)) list 72 | 73 | val process_text : 74 | Cpdfstrftime.t -> string -> (string * (unit -> string)) list -> string 75 | 76 | -------------------------------------------------------------------------------- /docsplits/splits/c10.tex: -------------------------------------------------------------------------------- 1 | /* CHAPTER 9. Multipage facilities */ 2 | 3 | /* 4 | * cpdf_padBefore(pdf, range) adds a blank page before each page in the given 5 | * range. 6 | */ 7 | void cpdf_padBefore(int, int); 8 | 9 | /* 10 | * cpdf_padAfter(pdf, range) adds a blank page after each page in the given 11 | * range. 12 | */ 13 | void cpdf_padAfter(int, int); 14 | 15 | /* cpdf_pageEvery(pdf, n) adds a blank page after every n pages. */ 16 | void cpdf_padEvery(int, int); 17 | 18 | /* 19 | * cpdf_padMultiple(pdf, n) adds pages at the end to pad the file to a 20 | * multiple of n pages in length. 21 | */ 22 | void cpdf_padMultiple(int, int); 23 | 24 | /* 25 | * cpdf_padMultiple(pdf, n) adds pages at the beginning to pad the file to a 26 | * multiple of n pages in length. 27 | */ 28 | void cpdf_padMultipleBefore(int, int); 29 | 30 | /* cpdf_impose(pdf, x, y, fit, columns, rtl, btt, center, margin, spacing, 31 | * linewidth) imposes a PDF. There are two modes: imposing x * y, or imposing 32 | * to fit a page of size x * y. This is controlled by fit. Columns imposes by 33 | * columns rather than rows. rtl is right-to-left, btt bottom-to-top. Center is 34 | * unused for now. Margin is the margin around the output, spacing the spacing 35 | * between imposed inputs. */ 36 | void cpdf_impose(int, double, double, int, int, int, int, int, double, double, 37 | double); 38 | 39 | /* cpdf_chop(pdf, range, x, y, columns, rtl, btt) chops each page in the range 40 | * into x * y pieces. If columns is set, the pieces go by columns instead of 41 | * rows. If rtl is set, the pieces are taken right-to-left. If btt is set, the 42 | * pieces are taken from bottom to top. */ 43 | void cpdf_chop(int, int, int, int, int, int, int); 44 | 45 | /* cpdf_chopH(pdf, range, columns, y) chops each page in the range horizontally 46 | * at position y. If columns is set, the pieces are arranged in reverse order. 47 | * */ 48 | void cpdf_chopH(int, int, int, double); 49 | 50 | /* cpdf_chopV(pdf, range, columns, x) chops each page in the range vertically 51 | * at position x. If columns is set, the pieces are arranged in reverse order. 52 | * */ 53 | void cpdf_chopV(int, int, int, double); 54 | 55 | /* 56 | * Impose a document two up. cpdf_twoUp does so by retaining the existing 57 | * page size, scaling pages down. cpdf_twoUpStack does so by doubling the 58 | * page size, to fit two pages on one. 59 | */ 60 | void cpdf_twoUp(int); 61 | void cpdf_twoUpStack(int); 62 | 63 | --------------------------------------------------------------------------------