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}
|
\end{jcpdflib}
|
||||||
|
|
||||||
\begin{jscpdflib}
|
\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
|
This program loads a file \texttt{hello.pdf} from disk and writes out a
|
||||||
document with the original included three times.
|
document with the original included three times.
|
||||||
|
@ -538,41 +538,26 @@ document with the original included three times.
|
||||||
\begin{small}
|
\begin{small}
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
//Merge example
|
//Merge example
|
||||||
import com.coherentpdf.Jcpdf
|
|
||||||
|
|
||||||
public static void main(String[] args)
|
//Load coherentpdf.js
|
||||||
{
|
const coherentpdf = require('./coherentpdf.js');
|
||||||
// Initialise cpdf
|
|
||||||
Jcpdf jcpdf = new Jcpdf();
|
//Load the file hello.pdf from the current directory
|
||||||
try
|
var pdf = coherentpdf.fromFile('hello.pdf', '');
|
||||||
{
|
|
||||||
jcpdf.startup();
|
//Merge three copies of it
|
||||||
}
|
var merged = coherentpdf.mergeSimple([pdf, pdf, pdf]);
|
||||||
catch (Jcpdf.CpdfError e)
|
|
||||||
{
|
//Write to merged.pdf
|
||||||
System.out.println("Error during cpdf startup");
|
coherentpdf.toFile(merged, 'merged.pdf', false, false);
|
||||||
}
|
|
||||||
// We will take the input hello.pdf and repeat it three times
|
//Clean up the two PDFs
|
||||||
try (Jcpdf.Pdf mergepdf = jcpdf.fromFile("hello.pdf", ""))
|
coherentpdf.deletePdf(pdf);
|
||||||
{
|
coherentpdf.deletePdf(merged);
|
||||||
// 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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
\end{small}
|
\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}
|
\end{jscpdflib}
|
||||||
|
|
||||||
\pagestyle{plain}
|
\pagestyle{plain}
|
||||||
|
|
|
@ -4,15 +4,19 @@
|
||||||
Use
|
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
|
The file `cpdflibtest.js` uses every function in coherentpdf.js. Call `./run`
|
||||||
`cpdf.min.js`) Load with `const cpdf = require('cpdf.js')` if installed in npm,
|
to run it in node.
|
||||||
or `const cpdf = require('./cpdf.js')` to load from current directory.
|
|
||||||
|
|
||||||
For development client-side with the browser : `cpdf.browser.js` (minified
|
For development server-side with node: `coherentpdf.js` (minified version
|
||||||
version for deployment : `cpdf.browser.min.js`). Load with `<script
|
`coherentpdf.min.js`). Load with `const coherentpdf = require('coherentpdf')`
|
||||||
src="cpdf.browser.js"></script>` or similar.
|
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
|
Data types
|
||||||
|
@ -37,6 +41,6 @@ Any function may raise an exception, containing a string describing the problem.
|
||||||
Concurrency
|
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
|
#!/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/c00 javascriptsplits/c00.tex
|
||||||
mv javascriptsplits/c01 javascriptsplits/c01.tex
|
mv javascriptsplits/c01 javascriptsplits/c01.tex
|
||||||
mv javascriptsplits/c02 javascriptsplits/c02.tex
|
mv javascriptsplits/c02 javascriptsplits/c02.tex
|
||||||
|
|
Loading…
Reference in New Issue