IPdfFileStamp

public interface IPdfFileStamp

interface for adding stamps (watermark or background) to PDF files.

Fields

FieldDescription
POS_BOTTOM_MIDDLEBottom middle position.
POS_BOTTOM_RIGHTBottom right position.
POS_UPPER_RIGHTRight upper position.
POS_SIDES_RIGHTRight position.
POS_UPPER_MIDDLEUpper middle position.
POS_BOTTOM_LEFTBottom left position.
POS_SIDES_LEFTLeft position.
POS_UPPER_LEFTUpper let position.

Methods

MethodDescription
getKeepSecurity()Keeps security if true.
setKeepSecurity(boolean value)Set Keep Security
getInputFile()Gets name and path of input file.
setInputFile(String value)Sets name and path of input file.
getInputStream()Gets input stream.
setInputStream(InputStream value)Sets input stream.
getOutputFile()Gets name and path of output file.
setOutputFile(String value)Sets name and path of output file.
getOutputStream()Gets output stream.
setOutputStream(OutputStream value)Sets or sets output stream.
getPageNumberRotation()Gets rotation of page number.
setPageNumberRotation(float value)Sets rotation of page number.
setConvertTo(PdfFormat value)Sets PDF file format.
getPageHeight()Gets height of first page in souorce file.
getPageWidth()Gets width of first page in input file.
getStartingNumber()Gets or sets starting number for first page in input file.
setStartingNumber(int value)Sets starting number for first page in input file.
close()Closes opened files and saves changes.
dispose()Closes opened files and saves changes.
addStamp(Stamp stamp)Adds stamp to the file.
addPageNumber(String formatString)Add page number to file.
addPageNumber(FormattedText formattedText)Adds page number to the page.
addPageNumber(String formatString, int position, float leftMargin, float rightMargin, float topMargin, float bottomMargin)Adds page number to the pages of document.
addPageNumber(String formatString, float x, float y)Adds page number at the specified position on the page.
addPageNumber(FormattedText formattedText, int position, float leftMargin, float rightMargin, float topMargin, float bottomMargin)Adds page number to the pages of document.
addPageNumber(FormattedText formattedText, float x, float y)Adds page number at the specified position on the page.
addHeader(FormattedText formattedText, float topMargin)Adds header to the page.
addHeader(FormattedText formattedText, float topMargin, float leftMargin, float rightMargin)Adds header to the pages of file.
addHeader(String imageFile, float topMargin)Adds image as header to the pages of the file.
addHeader(String imageFile, float topMargin, float leftMargin, float rightMargin)Adds image as header on the pages.
addHeader(InputStream imageStream, float topMargin)Adds image as header on the pages.
addHeader(InputStream inputStream, float topMargin, float leftMargin, float rightMargin)Adds image at the top of the page.
addFooter(FormattedText formattedText, float bottomMargin)Adds footer to the pages of the document.
addFooter(FormattedText formattedText, float bottomMargin, float leftMargin, float rightMargin)Adds footer to the pages of the document.
addFooter(String imageFile, float bottomMargin)Adds image as footer to the pages of the document.
addFooter(String imageFile, float bottomMargin, float leftMargin, float rightMargin)Adds image as footer of the pages.
addFooter(InputStream imageStream, float bottomMargin)Adds image as footer of the page.
addFooter(InputStream imageStream, float bottomMargin, float leftMargin, float rightMargin)Adds image as footer of the page.
addPageNumber(String formatString, int position)Adds page number to the pages.
addPageNumber(FormattedText formattedText, int position)Adds page number to the pages.
getDocument()Gets the document PdfFileStamp is working on.
getContentDisposition()Gets how content will be stored when result of operation is stored into HttpResponse object.
setContentDisposition(int value)Sets how content will be stored when result of operation is stored into HttpResponse object.
getSaveOptions()Gets save options when result is stored as HttpResponse.
setSaveOptions(SaveOptions value)Sets save options when result is stored as HttpResponse.
getAttachmentName()Gets name of attachment when result of operation is stored into HttpResponse objects as attachment.
setAttachmentName(String value)Sets name of attachment when result of operation is stored into HttpResponse objects as attachment.

POS_BOTTOM_MIDDLE

public static final int POS_BOTTOM_MIDDLE

Bottom middle position.

POS_BOTTOM_RIGHT

public static final int POS_BOTTOM_RIGHT

Bottom right position.

POS_UPPER_RIGHT

public static final int POS_UPPER_RIGHT

Right upper position.

POS_SIDES_RIGHT

public static final int POS_SIDES_RIGHT

Right position.

POS_UPPER_MIDDLE

public static final int POS_UPPER_MIDDLE

Upper middle position.

POS_BOTTOM_LEFT

public static final int POS_BOTTOM_LEFT

Bottom left position.

POS_SIDES_LEFT

public static final int POS_SIDES_LEFT

Left position.

POS_UPPER_LEFT

public static final int POS_UPPER_LEFT

Upper let position.

getKeepSecurity()

public abstract boolean getKeepSecurity()

Keeps security if true. (This feature will be implemented in next versions).

Returns: boolean - boolean value

setKeepSecurity(boolean value)

public abstract void setKeepSecurity(boolean value)

Set Keep Security

Parameters:

ParameterTypeDescription
valuebooleanboolean value

getInputFile()

public abstract String getInputFile()

Gets name and path of input file.

Returns: java.lang.String - String object

setInputFile(String value)

public abstract void setInputFile(String value)

Sets name and path of input file.

Parameters:

ParameterTypeDescription
valuejava.lang.StringString value

getInputStream()

public abstract InputStream getInputStream()

Gets input stream.

Returns: java.io.InputStream - InputStream object

setInputStream(InputStream value)

public abstract void setInputStream(InputStream value)

Sets input stream.

Parameters:

ParameterTypeDescription
valuejava.io.InputStreamInputStream object

getOutputFile()

public abstract String getOutputFile()

Gets name and path of output file.

Returns: java.lang.String - String object

setOutputFile(String value)

public abstract void setOutputFile(String value)

Sets name and path of output file.

Parameters:

ParameterTypeDescription
valuejava.lang.StringString object

getOutputStream()

public abstract OutputStream getOutputStream()

Gets output stream.

Returns: java.io.OutputStream - OutputStream object

setOutputStream(OutputStream value)

public abstract void setOutputStream(OutputStream value)

Sets or sets output stream.

Parameters:

ParameterTypeDescription
valuejava.io.OutputStreamOutputStream object

getPageNumberRotation()

public abstract float getPageNumberRotation()

Gets rotation of page number. Rotation is in degrees. Default is 0.

Returns: float - float value

setPageNumberRotation(float value)

public abstract void setPageNumberRotation(float value)

Sets rotation of page number. Rotation is in degrees. Default is 0.

Parameters:

ParameterTypeDescription
valuefloatfloat value

setConvertTo(PdfFormat value)

public abstract void setConvertTo(PdfFormat value)

Sets PDF file format. Result file will be saved in specified file format. If this property is not specified then file will be save in default PDF format without conversion.

Parameters:

ParameterTypeDescription
valuePdfFormatPdfFormat element

getPageHeight()

public abstract float getPageHeight()

Gets height of first page in souorce file.


PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", "output.pdf");
 System.out.println("Height = " + fileStamp.getPageHeight());
 fileStamp.close();

Returns: float - float value

getPageWidth()

public abstract float getPageWidth()

Gets width of first page in input file.


PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", "output.pdf");
 System.out.println("Width = " + fileStamp.getPageWidth());
 fileStamp.close();

Returns: float - float value

getStartingNumber()

public abstract int getStartingNumber()

Gets or sets starting number for first page in input file. Next pages will be numbered starting from this value.

Returns: int - int value

setStartingNumber(int value)

public abstract void setStartingNumber(int value)

Sets starting number for first page in input file. Next pages will be numbered starting from this value. For example if StartingNumber is set to 100, document pages will have numbers 100, 101, 102…


PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", "output.pdf");
 fileStamp.setStartingNumber(100);
 fileStamp.addPageNumber("Page #");
 fileStamp.close();

Parameters:

ParameterTypeDescription
valueintint value

close()

public abstract void close()

Closes opened files and saves changes. Warning. If input or output streams are specified they are not closed by Close() method.


PdfFileStamp stamp = new PdfFileStamp("input.pdf", "output.pdf");
 // do some work...
 stamp.close();

dispose()

public abstract void dispose()

Closes opened files and saves changes. Warning. If input or output streams are specified they are not closed by Close() method.


PdfFileStamp stamp = new PdfFileStamp("input.pdf", "output.pdf");
 // do some work...
 stamp.dispose();

This method is obsolete, use close() instead.

addStamp(Stamp stamp)

public abstract void addStamp(Stamp stamp)

Adds stamp to the file.


PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", "output.pdf");
 Stamp stamp = new com.aspose.pdf.facades.Stamp();
 stamp.setOrigin(140, 400);
 stamp.setImageSize(50, 50);
 stamp.setOpacity(0.8f);
 stamp.isBackground(true);
 stamp.bindImage("image.jpg");
 fileStamp.addStamp(stamp);
 fileStamp.close();

Parameters:

ParameterTypeDescription
stampStampStamp object which.

addPageNumber(String formatString)

public abstract void addPageNumber(String formatString)

Add page number to file. Page number text may contain # sign which will be replaced with number of the page. Page number is placed in the bottom of the page centered horizontally.


PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", "output.pdf");
 fileStamp.addPageNumber("Page #");
 fileStamp.close();

Parameters:

ParameterTypeDescription
formatStringjava.lang.StringText of page number

addPageNumber(FormattedText formattedText)

public abstract void addPageNumber(FormattedText formattedText)

Adds page number to the page. Page number may contain # sign which will be replaced with page number. Page number is placed in the bottom of the page centered horizontally.


PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", "output.pdf");
 fileStamp.addPageNumber(new FormattedText("Page #"));
 fileStamp.close();

Parameters:

ParameterTypeDescription
formattedTextFormattedTextFormat string for page number representes as FormattedText.

addPageNumber(String formatString, int position, float leftMargin, float rightMargin, float topMargin, float bottomMargin)

public abstract void addPageNumber(String formatString, int position, float leftMargin, float rightMargin, float topMargin, float bottomMargin)

Adds page number to the pages of document.


PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", "output.pdf");
 fileStamp.addPageNumber("Page #", PdfFileStamp.PosBottomLeft, 100, 100, 200, 200);
 fileStamp.close();

Parameters:

ParameterTypeDescription
formatStringjava.lang.StringFormat string for page number.
positionintPosition where page number will be placed on the page. 0-bottom middle, 1-bottom right, 2-upper right, 3 - sides right, 4 - upper middle,5 - bottom left,6 - sides left,7 - upper left. You can use the following constants: PosBottomMiddle = 0, PosBottomRight = 1, PosUpperRight = 2, PosSidesRight = 3, PosUpperMiddle, PosBottomLeft = 5, PosSidesLeft, PosUpperLeft
leftMarginfloatMargin on the left edge of the page.
rightMarginfloatMargin on the right edge of the page.
topMarginfloatMargin on the top edge of the page.
bottomMarginfloatMargin on the bottom edge of the page.

addPageNumber(String formatString, float x, float y)

public abstract void addPageNumber(String formatString, float x, float y)

Adds page number at the specified position on the page.


PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", "output.pdf");
 fileStamp.addPageNumber(new FormattedText("Page  #"), 123, 357);
 fileStamp.close();

Parameters:

ParameterTypeDescription
formatStringjava.lang.StringFormat string. Format string can contain # sign which will be replaced with page number.
xfloatX coordinate of page number.
yfloatY coordinate of page number.

addPageNumber(FormattedText formattedText, int position, float leftMargin, float rightMargin, float topMargin, float bottomMargin)

public abstract void addPageNumber(FormattedText formattedText, int position, float leftMargin, float rightMargin, float topMargin, float bottomMargin)

Adds page number to the pages of document.


PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", "output.pdf");
 fileStamp.addPageNumber(new FormattedText("Page #"), PdfFileStamp.PosBottomLeft, 100, 100, 200, 200);
 fileStamp.close();

Parameters:

ParameterTypeDescription
formattedTextFormattedTextFormattedText object which represents page number format and properties iof the text.
positionintPosition where page number will be placed on the page. 0-bottom middle, 1-bottom right, 2-upper right, 3 - sides right, 4 - upper middle,5 - bottom left,6 - sides left,7 - upper left. You can use the following constants: PosBottomMiddle = 0, PosBottomRight = 1, PosUpperRight = 2, PosSidesRight = 3, PosUpperMiddle, PosBottomLeft = 5, PosSidesLeft, PosUpperLeft
leftMarginfloatMargin on the left edge of the page.
rightMarginfloatMargin on the right edge of the page.
topMarginfloatMargin on the top edge of the page.
bottomMarginfloatMargin on the bottom edge of the page.

addPageNumber(FormattedText formattedText, float x, float y)

public abstract void addPageNumber(FormattedText formattedText, float x, float y)

Adds page number at the specified position on the page.


PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", "output.pdf");
 fileStamp.addPageNumber(new FormattedText("Page  #"), 123, 357);
 fileStamp.close();

Parameters:

ParameterTypeDescription
formattedTextFormattedTextFormatted text which represents page number format and properties of the text. Format string can contain # sign which will be replaced with page number.
xfloatX coordinate of page number.
yfloatY coordinate of page number.

addHeader(FormattedText formattedText, float topMargin)

public abstract void addHeader(FormattedText formattedText, float topMargin)

Adds header to the page.


PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", "output.pdf");
 fileStamp.addHeader(new FormattedText("Head of the page"), 50);
 fileStamp.close();

Parameters:

ParameterTypeDescription
formattedTextFormattedTextText for header and properties of the text.
topMarginfloatMargin on the top of page.

addHeader(FormattedText formattedText, float topMargin, float leftMargin, float rightMargin)

public abstract void addHeader(FormattedText formattedText, float topMargin, float leftMargin, float rightMargin)

Adds header to the pages of file.


PdfFileStamp stamp = new PdfFileStamp("input.pdf", "output.pdf");
 stamp.addHeader(new FormattedText("Head of the page"), 10, 50, 50);

Parameters:

ParameterTypeDescription
formattedTextFormattedTextFormatted text object which contains page text and its properties.
topMarginfloatMargin on the top of the page.
leftMarginfloatMargin on the left of the page.
rightMarginfloatMargin on the right of the page.

addHeader(String imageFile, float topMargin)

public abstract void addHeader(String imageFile, float topMargin)

Adds image as header to the pages of the file.


PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", output.pdf");
 fileStamp.addHeader("image.jpg", 50);
 fileStamp.close();

Parameters:

ParameterTypeDescription
imageFilejava.lang.StringPath to the image file.
topMarginfloatMargin at top of the page.

addHeader(String imageFile, float topMargin, float leftMargin, float rightMargin)

public abstract void addHeader(String imageFile, float topMargin, float leftMargin, float rightMargin)

Adds image as header on the pages.


PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", output.pdf");
 fileStamp.addHeader("image.jpg", 50, 100, 100);
 fileStamp.close();

Parameters:

ParameterTypeDescription
imageFilejava.lang.StringPath to the image file.
topMarginfloatMargin at top of the page.
leftMarginfloatMargin at left side of the page.
rightMarginfloatMargin at right side of the page.

addHeader(InputStream imageStream, float topMargin)

public abstract void addHeader(InputStream imageStream, float topMargin)

Adds image as header on the pages.


PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", output.pdf");
 fileStamp.addHeader(new FileInputStream("image.jpg"), 50);
 fileStamp.close();

Parameters:

ParameterTypeDescription
imageStreamjava.io.InputStreamStream of the image.
topMarginfloatMargin at top of the page.

addHeader(InputStream inputStream, float topMargin, float leftMargin, float rightMargin)

public abstract void addHeader(InputStream inputStream, float topMargin, float leftMargin, float rightMargin)

Adds image at the top of the page.


PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", output.pdf");
 fileStamp.addHeader(new FileInputStream("image.jpg"), 50, 100, 100);
 fileStamp.close();

Parameters:

ParameterTypeDescription
inputStreamjava.io.InputStreamStream which contains image data.
topMarginfloatMargin at top of the page.
leftMarginfloatMargin at left side of the page.
rightMarginfloatMargin at right side of the page.

addFooter(FormattedText formattedText, float bottomMargin)

public abstract void addFooter(FormattedText formattedText, float bottomMargin)

Adds footer to the pages of the document.


PdfFileStamp stamp = new PdfFileStamp("input.pdf", "output.pdf");
 stamp.addFooter(new FormattedText("Foot of the page"), 10);

Parameters:

ParameterTypeDescription
formattedTextFormattedTextFormattedText object which contains text of the footer and text properties.
bottomMarginfloatMargin at the top of page.

addFooter(FormattedText formattedText, float bottomMargin, float leftMargin, float rightMargin)

public abstract void addFooter(FormattedText formattedText, float bottomMargin, float leftMargin, float rightMargin)

Adds footer to the pages of the document.


PdfFileStamp stamp = new PdfFileStamp("input.pdf", "output.pdf");
 stamp.addFooter(new FormattedText("Foot of the page"), 10, 50, 50);

Parameters:

ParameterTypeDescription
formattedTextFormattedTextFormattedText object which contains footer text and text properties.
bottomMarginfloatMargin at the bottom of the page.
leftMarginfloatMargin at the left side of the page.
rightMarginfloatMargin at the right side of the page.

addFooter(String imageFile, float bottomMargin)

public abstract void addFooter(String imageFile, float bottomMargin)

Adds image as footer to the pages of the document.


PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", output.pdf");
 fileStamp.addFooter("image.jpg", 50);
 fileStamp.close();

Parameters:

ParameterTypeDescription
imageFilejava.lang.StringImage file name and path.
bottomMarginfloatMargin at the bottom of the page.

addFooter(String imageFile, float bottomMargin, float leftMargin, float rightMargin)

public abstract void addFooter(String imageFile, float bottomMargin, float leftMargin, float rightMargin)

Adds image as footer of the pages.

Parameters:

ParameterTypeDescription
imageFilejava.lang.StringIamge file name and path.
bottomMarginfloatMargin at the bottom of the page.
leftMarginfloatMargin at the left side of the page.
rightMarginfloatMargin at the right side of the page.

addFooter(InputStream imageStream, float bottomMargin)

public abstract void addFooter(InputStream imageStream, float bottomMargin)

Adds image as footer of the page.


PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", output.pdf");
 fileStamp.addFooter(new FileInputStream("image.jpg"), 50);
 fileStamp.close();

Parameters:

ParameterTypeDescription
imageStreamjava.io.InputStreamStream contains image data.
bottomMarginfloatMargin at the bottom of the page.

addFooter(InputStream imageStream, float bottomMargin, float leftMargin, float rightMargin)

public abstract void addFooter(InputStream imageStream, float bottomMargin, float leftMargin, float rightMargin)

Adds image as footer of the page.


PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", output.pdf");
 fileStamp.addFooter(new FileInputStream("image.jpg"), 50, 50, 50);
 fileStamp.close();

Parameters:

ParameterTypeDescription
imageStreamjava.io.InputStreamStream contains image data.
bottomMarginfloatMargin at the bottom of the page.
leftMarginfloatMargin at the left side of the page.
rightMarginfloatMargin at the right side of the page.

addPageNumber(String formatString, int position)

public abstract void addPageNumber(String formatString, int position)

Adds page number to the pages.


PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", "output.pdf");
 fileStamp.addPageNumber("Page #", PdfFileStamp.PosUpperRight);
 fileStamp.close();

Parameters:

ParameterTypeDescription
formatStringjava.lang.StringFormat of the page number. This text may contain # which will be replaced with page number.
positionintPosition where page number will be placed on the page. 0-bottom middle, 1-bottom right, 2-upper right, 3 - sides right, 4 - upper middle,5 - bottom left,6 - sides left,7 - upper left. You can use the following constants: PosBottomMiddle = 0, PosBottomRight = 1, PosUpperRight = 2, PosSidesRight = 3, PosUpperMiddle, PosBottomLeft = 5, PosSidesLeft, PosUpperLeft

addPageNumber(FormattedText formattedText, int position)

public abstract void addPageNumber(FormattedText formattedText, int position)

Adds page number to the pages.


PdfFileStamp fileStamp = new PdfFileStamp("input.pdf", "output.pdf");
 fileStamp.addPageNumber("Page #", PdfFileStamp.PosUpperRight);
 fileStamp.close();

Parameters:

ParameterTypeDescription
formattedTextFormattedTextFormattedText object which contains format of the page number and text properties. This text may contain # which will be replaced with page number.
positionintPosition where page number will be placed on the page. 0-bottom middle, 1-bottom right, 2-upper right, 3 - sides right, 4 - upper middle,5 - bottom left,6 - sides left,7 - upper left. You can use the following constants: PosBottomMiddle = 0, PosBottomRight = 1, PosUpperRight = 2, PosSidesRight = 3, PosUpperMiddle, PosBottomLeft = 5, PosSidesLeft, PosUpperLeft

getDocument()

public abstract IDocument getDocument()

Gets the document PdfFileStamp is working on.

Returns: IDocument - IDocument object

getContentDisposition()

public abstract int getContentDisposition()

Gets how content will be stored when result of operation is stored into HttpResponse object. Possible value: inline / attachment. Default: inline.

Returns: int - ContentDisposition element

setContentDisposition(int value)

public abstract void setContentDisposition(int value)

Sets how content will be stored when result of operation is stored into HttpResponse object. Possible value: inline / attachment. Default: inline.

Parameters:

ParameterTypeDescription
valueintContentDisposition element

getSaveOptions()

public abstract SaveOptions getSaveOptions()

Gets save options when result is stored as HttpResponse. Default value: PdfSaveOptions.

Returns: SaveOptions - SaveOptions object

setSaveOptions(SaveOptions value)

public abstract void setSaveOptions(SaveOptions value)

Sets save options when result is stored as HttpResponse. Default value: PdfSaveOptions.

Parameters:

ParameterTypeDescription
valueSaveOptionsSaveOptions value

getAttachmentName()

public abstract String getAttachmentName()

Gets name of attachment when result of operation is stored into HttpResponse objects as attachment.

Returns: java.lang.String - String value

setAttachmentName(String value)

public abstract void setAttachmentName(String value)

Sets name of attachment when result of operation is stored into HttpResponse objects as attachment.

Parameters:

ParameterTypeDescription
valuejava.lang.StringString value