This commit is contained in:
John Whitington
2022-05-18 17:47:31 +01:00
parent 15bee681ae
commit 0ea7d45506
20 changed files with 813 additions and 1153 deletions

View File

@@ -1,120 +1,47 @@
/* CHAPTER 8. Logos, Watermarks and Stamps */
// CHAPTER 8. Logos, Watermarks and Stamps
/** A stamping function with extra features. - isover true, pdf goes over pdf2,
isover false, pdf goes under pdf2 - scale_stamp_to_fit scales the stamp to fit
the page - pos gives the position to put the stamp - relative_to_cropbox: if
true, pos is relative to cropbox not mediabox. */
function stampOn(stamp_pdf, pdf, range)
/** Stamps another PDF on top of all the pages in the document which are in
the range. The stamp is placed with its origin at the origin of the target
document.
@param stamp_pdf stamp PDF document
@param pdf PDF document
@param range page range */
public native void stampOn(Pdf stamp_pdf, Pdf pdf, Range range)
throws CpdfError;
/** Stamps another PDF under all the pages in the document which are in the
/** Stamps stamp_pdf under all the pages in the document which are in the
range. The stamp is placed with its origin at the origin of the target
document.
@param stamp_pdf stamp PDF document
@param pdf PDF document
@param range page range */
public native void stampUnder(Pdf stamp_pdf, Pdf pdf, Range range)
throws CpdfError;
document. */
function stampUnder(stamp_pdf, pdf, range)
/** A stamping function with extra features.
@param pdf first PDF document
@param pdf2 second PDF document
@param range page range
@param isover if <code>true</code>, <code>pdf</code> goes over
<code>pdf2</code> otherwise under
@param scale_stamp_to_fit if <code>true</code> scales the stamp to fit
the page.
@param anchor position anchor, such as {@link #posCentre posCentre}
@param p1 position parameter one
@param p2 position parameter two
@param relative_to_cropbox if <code>true</code>, the position is relative
to the crop box rather than the media box. */
public native void stampExtended(Pdf pdf, Pdf pdf2, Range range,
boolean isover,
boolean scale_stamp_to_fit, int anchor,
double p1, double p2,
boolean relative_to_cropbox)
throws CpdfError;
/** A stamping function with extra features. - isover true, pdf goes over
pdf2, isover false, pdf goes under pdf2 - scale_stamp_to_fit scales the
stamp to fit the page - pos gives the position to put the stamp -
relative_to_cropbox: if true, pos is relative to cropbox not mediabox. */
function stampExtended(pdf, pdf2, range, isover, scale_stamp_to_fit, position,
relative_to_cropbox)
/** Combines the two PDFs page-by-page, putting each page of 'over' over
each page of 'under'. */
public native Pdf combinePages(Pdf under, Pdf over) throws CpdfError;
/** Combines the PDFs page-by-page, putting each page of 'over' over each page
of 'under'. */
function combinePages(under, over)
/** Adds text to the pages in the given range.
@param metrics if <code>true</code>, only collect metrics
@param pdf PDF document
@param range page range
@param text the text to stamp, including any special codes
@param anchor position anchor, such as {@link #posCentre posCentre}
@param p1 position parameter one
@param p2 position parameter two
@param linespacing line spacing
@param bates starting bates number
@param font font, such as {@link #timesRoman timesRoman}
@param fontsize font size
@param r red component of colour
@param g green component of colour
@param b blue component of colour
@param underneath if <code>true</code>, text goes under page
@param cropbox if <code>true</code>,
relative to cropbox rather than media box
@param outline text is outline
@param opacity opacity
@param justification justification,
such as {@link #leftJustify leftJustify}
@param midline position is relative to midline not baseline
@param topline position is relative to topline not baseline
@param filename file name, if requied by special code in text
@param linewidth line width
@param embed_fonts if true, embed fonts
*/
public void addText(boolean metrics, Pdf pdf, Range range, String text,
int anchor, double p1, double p2, double linespacing,
int bates, int font, double fontsize, double r,
double g, double b, boolean underneath,
boolean cropbox, boolean outline, double opacity,
int justification, boolean midline, boolean topline,
String filename, double linewidth, boolean embed_fonts)
throws CpdfError;
/** Adds text to the pages in the given range. */
function addText(metrics, pdf, range, text, position, linespacing,
bates, font, fontsize, r, g, b, underneath, relative_to_cropbox,
outline, opacity, justification, midline, topline, filename,
linewidth, embed_fonts)
/** Adds text with most parameters default.
@param pdf PDF document
@param range page range
@param text the text to stamp, including any special codes
@param anchor position anchor, such as {@link #posCentre posCentre}
@param p1 position parameter one
@param p2 position parameter two
@param font font, such as {@link #timesRoman timesRoman}
@param fontsize font size
*/
public void addTextSimple(Pdf pdf, Range range, String text, int anchor,
double p1, double p2, int font, double fontsize)
throws CpdfError;
/** Adds text with most parameters default. */
function addTextSimple(pdf, range, text, position, font, fontsize)
/** Removes any text added by Jcpdf from the given pages. */
public native void removeText(Pdf pdf, Range range) throws CpdfError;
/** Removes any text added by cpdf from the given pages. */
function removeText(pdf, range)
/** Returns the width of a given string in the given font in thousandths of
a point.
@param font font, such as {@link #timesRoman timesRoman}
@param text text*/
public int textWidth(int font, String text) throws CpdfError;
/** Returns the width of a given string in the given font in thousandths of a
point. */
function textWidth(font, text)
/** Adds page content before or after the existing content to pages in the
given range in the given PDF.
@param s page content to add
@param before if <code>true</code> new content goes before, else after
@param pdf PDF document
@param range page range */
public void addContent(String s, boolean before, Pdf pdf, Range range)
throws CpdfError;
/** Adds page content before (if true) or after (if false) the existing
content to pages in the given range in the given PDF. */
function addContent(content, before, pdf, range)
/** Stamps a PDF onto the pages in the given range in pdf as a shared Form
XObject. The name of the newly-created XObject is returned.
@param pdf PDF document
@param range page range
@param stamp_pdf PDF document to stamp */
public native String stampAsXObject(Pdf pdf, Range range, Pdf stamp_pdf)
throws CpdfError;
/** Stamps stamp_pdf onto the pages in the given range in pdf as a shared Form
XObject. The name of the newly-created XObject is returned. */
function stampAsXObject(pdf, range, stamp_pdf)