more
This commit is contained in:
parent
209b3b637c
commit
8ce990f715
BIN
cpdfmanual.pdf
BIN
cpdfmanual.pdf
Binary file not shown.
|
@ -530,7 +530,7 @@ public static void main(String[] args)
|
|||
\end{jcpdflib}
|
||||
|
||||
\begin{jscpdflib}
|
||||
\chapter*{Example Program in Java}
|
||||
\chapter*{Example Program in JavaScript}
|
||||
|
||||
This program loads a file \texttt{hello.pdf} from disk and writes out a
|
||||
document with the original included three times.
|
||||
|
@ -538,41 +538,26 @@ document with the original included three times.
|
|||
\begin{small}
|
||||
\begin{verbatim}
|
||||
//Merge example
|
||||
import com.coherentpdf.Jcpdf
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// Initialise cpdf
|
||||
Jcpdf jcpdf = new Jcpdf();
|
||||
try
|
||||
{
|
||||
jcpdf.startup();
|
||||
}
|
||||
catch (Jcpdf.CpdfError e)
|
||||
{
|
||||
System.out.println("Error during cpdf startup");
|
||||
}
|
||||
// We will take the input hello.pdf and repeat it three times
|
||||
try (Jcpdf.Pdf mergepdf = jcpdf.fromFile("hello.pdf", ""))
|
||||
{
|
||||
// The array of PDFs to merge
|
||||
Jcpdf.Pdf[] pdfs = {mergepdf, mergepdf, mergepdf};
|
||||
// Merge them
|
||||
Jcpdf.Pdf merged = jcpdf.mergeSimple(pdfs);
|
||||
// Write output
|
||||
jcpdf.toFile(merged, "merged.pdf", false, false);
|
||||
// Dispose of merged PDF
|
||||
merged.close();
|
||||
}
|
||||
catch (Jcpdf.CpdfError e)
|
||||
{
|
||||
System.out.println("Error during cpdf operation");
|
||||
}
|
||||
}
|
||||
//Load coherentpdf.js
|
||||
const coherentpdf = require('./coherentpdf.js');
|
||||
|
||||
//Load the file hello.pdf from the current directory
|
||||
var pdf = coherentpdf.fromFile('hello.pdf', '');
|
||||
|
||||
//Merge three copies of it
|
||||
var merged = coherentpdf.mergeSimple([pdf, pdf, pdf]);
|
||||
|
||||
//Write to merged.pdf
|
||||
coherentpdf.toFile(merged, 'merged.pdf', false, false);
|
||||
|
||||
//Clean up the two PDFs
|
||||
coherentpdf.deletePdf(pdf);
|
||||
coherentpdf.deletePdf(merged);
|
||||
\end{verbatim}
|
||||
\end{small}
|
||||
|
||||
\noindent Note the use of \texttt{try} and \texttt{close()} to ensure the PDFs are thrown away when no longer required.
|
||||
\noindent To be run in node. A browser example is included in the distribution of coherentpdf.js.
|
||||
\end{jscpdflib}
|
||||
|
||||
\pagestyle{plain}
|
||||
|
|
|
@ -4,15 +4,19 @@
|
|||
Use
|
||||
---
|
||||
|
||||
cpdf.js can be used from both node and the browser.
|
||||
coherentpdf.js can be used from both node and the browser.
|
||||
|
||||
For development server-side with node: `cpdf.js` (minified version
|
||||
`cpdf.min.js`) Load with `const cpdf = require('cpdf.js')` if installed in npm,
|
||||
or `const cpdf = require('./cpdf.js')` to load from current directory.
|
||||
The file `cpdflibtest.js` uses every function in coherentpdf.js. Call `./run`
|
||||
to run it in node.
|
||||
|
||||
For development client-side with the browser : `cpdf.browser.js` (minified
|
||||
version for deployment : `cpdf.browser.min.js`). Load with `<script
|
||||
src="cpdf.browser.js"></script>` or similar.
|
||||
For development server-side with node: `coherentpdf.js` (minified version
|
||||
`coherentpdf.min.js`). Load with `const coherentpdf = require('coherentpdf')`
|
||||
if installed in npm, or `const coherentpdf = require('./coherentpdf.js')` to
|
||||
load from current directory.
|
||||
|
||||
For development client-side with the browser : `coherentpdf.browser.js`
|
||||
(minified version for deployment : `coherentpdf.browser.min.js`). Load with
|
||||
`<script src="coherentpdf.browser.js"></script>` or similar.
|
||||
|
||||
|
||||
Data types
|
||||
|
@ -37,6 +41,6 @@ Any function may raise an exception, containing a string describing the problem.
|
|||
Concurrency
|
||||
-----------
|
||||
|
||||
cpdf.js is synchronous and non-re-entrant. In the browser, best used in a worker.
|
||||
coherentpdf.js is synchronous and non-re-entrant. In the browser, best used in a worker.
|
||||
**/
|
||||
|
||||
|
|
2
splitjs
2
splitjs
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
csplit -k -f javascriptsplits/c ../cpdf.js/cpdfdocs.js '/CHAPTER/' {18}
|
||||
csplit -k -f javascriptsplits/c ../coherentpdf.js/cpdfdocs.js '/CHAPTER/' {18}
|
||||
mv javascriptsplits/c00 javascriptsplits/c00.tex
|
||||
mv javascriptsplits/c01 javascriptsplits/c01.tex
|
||||
mv javascriptsplits/c02 javascriptsplits/c02.tex
|
||||
|
|
Loading…
Reference in New Issue