IPdfFileStamp
public interface IPdfFileStamp
interface for adding stamps (watermark or background) to PDF files.
Fields
Field | Description |
---|---|
POS_BOTTOM_MIDDLE | Bottom middle position. |
POS_BOTTOM_RIGHT | Bottom right position. |
POS_UPPER_RIGHT | Right upper position. |
POS_SIDES_RIGHT | Right position. |
POS_UPPER_MIDDLE | Upper middle position. |
POS_BOTTOM_LEFT | Bottom left position. |
POS_SIDES_LEFT | Left position. |
POS_UPPER_LEFT | Upper let position. |
Methods
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:
Parameter | Type | Description |
---|---|---|
value | boolean | boolean 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:
Parameter | Type | Description |
---|---|---|
value | java.lang.String | String 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:
Parameter | Type | Description |
---|---|---|
value | java.io.InputStream | InputStream 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:
Parameter | Type | Description |
---|---|---|
value | java.lang.String | String 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:
Parameter | Type | Description |
---|---|---|
value | java.io.OutputStream | OutputStream 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:
Parameter | Type | Description |
---|---|---|
value | float | float 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:
Parameter | Type | Description |
---|---|---|
value | PdfFormat | PdfFormat 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:
Parameter | Type | Description |
---|---|---|
value | int | int 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:
Parameter | Type | Description |
---|---|---|
stamp | Stamp | Stamp 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:
Parameter | Type | Description |
---|---|---|
formatString | java.lang.String | Text 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:
Parameter | Type | Description |
---|---|---|
formattedText | FormattedText | Format 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:
Parameter | Type | Description |
---|---|---|
formatString | java.lang.String | Format string for page number. |
position | int | Position 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 |
leftMargin | float | Margin on the left edge of the page. |
rightMargin | float | Margin on the right edge of the page. |
topMargin | float | Margin on the top edge of the page. |
bottomMargin | float | Margin 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:
Parameter | Type | Description |
---|---|---|
formatString | java.lang.String | Format string. Format string can contain # sign which will be replaced with page number. |
x | float | X coordinate of page number. |
y | float | Y 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:
Parameter | Type | Description |
---|---|---|
formattedText | FormattedText | FormattedText object which represents page number format and properties iof the text. |
position | int | Position 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 |
leftMargin | float | Margin on the left edge of the page. |
rightMargin | float | Margin on the right edge of the page. |
topMargin | float | Margin on the top edge of the page. |
bottomMargin | float | Margin 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:
Parameter | Type | Description |
---|---|---|
formattedText | FormattedText | Formatted text which represents page number format and properties of the text. Format string can contain # sign which will be replaced with page number. |
x | float | X coordinate of page number. |
y | float | Y 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:
Parameter | Type | Description |
---|---|---|
formattedText | FormattedText | Text for header and properties of the text. |
topMargin | float | Margin 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:
Parameter | Type | Description |
---|---|---|
formattedText | FormattedText | Formatted text object which contains page text and its properties. |
topMargin | float | Margin on the top of the page. |
leftMargin | float | Margin on the left of the page. |
rightMargin | float | Margin 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:
Parameter | Type | Description |
---|---|---|
imageFile | java.lang.String | Path to the image file. |
topMargin | float | Margin 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:
Parameter | Type | Description |
---|---|---|
imageFile | java.lang.String | Path to the image file. |
topMargin | float | Margin at top of the page. |
leftMargin | float | Margin at left side of the page. |
rightMargin | float | Margin 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:
Parameter | Type | Description |
---|---|---|
imageStream | java.io.InputStream | Stream of the image. |
topMargin | float | Margin 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:
Parameter | Type | Description |
---|---|---|
inputStream | java.io.InputStream | Stream which contains image data. |
topMargin | float | Margin at top of the page. |
leftMargin | float | Margin at left side of the page. |
rightMargin | float | Margin 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:
Parameter | Type | Description |
---|---|---|
formattedText | FormattedText | FormattedText object which contains text of the footer and text properties. |
bottomMargin | float | Margin 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:
Parameter | Type | Description |
---|---|---|
formattedText | FormattedText | FormattedText object which contains footer text and text properties. |
bottomMargin | float | Margin at the bottom of the page. |
leftMargin | float | Margin at the left side of the page. |
rightMargin | float | Margin 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:
Parameter | Type | Description |
---|---|---|
imageFile | java.lang.String | Image file name and path. |
bottomMargin | float | Margin 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:
Parameter | Type | Description |
---|---|---|
imageFile | java.lang.String | Iamge file name and path. |
bottomMargin | float | Margin at the bottom of the page. |
leftMargin | float | Margin at the left side of the page. |
rightMargin | float | Margin 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:
Parameter | Type | Description |
---|---|---|
imageStream | java.io.InputStream | Stream contains image data. |
bottomMargin | float | Margin 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:
Parameter | Type | Description |
---|---|---|
imageStream | java.io.InputStream | Stream contains image data. |
bottomMargin | float | Margin at the bottom of the page. |
leftMargin | float | Margin at the left side of the page. |
rightMargin | float | Margin 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:
Parameter | Type | Description |
---|---|---|
formatString | java.lang.String | Format of the page number. This text may contain # which will be replaced with page number. |
position | int | Position 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:
Parameter | Type | Description |
---|---|---|
formattedText | FormattedText | FormattedText object which contains format of the page number and text properties. This text may contain # which will be replaced with page number. |
position | int | Position 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:
Parameter | Type | Description |
---|---|---|
value | int | ContentDisposition 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:
Parameter | Type | Description |
---|---|---|
value | SaveOptions | SaveOptions 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:
Parameter | Type | Description |
---|---|---|
value | java.lang.String | String value |