public interface IPdfFileStamp
interface for adding stamps (watermark or background) to PDF files.
Modifier and Type | Field and Description |
---|---|
static int |
POS_BOTTOM_LEFT
Bottom left position.
|
static int |
POS_BOTTOM_MIDDLE
Bottom middle position.
|
static int |
POS_BOTTOM_RIGHT
Bottom right position.
|
static int |
POS_SIDES_LEFT
Left position.
|
static int |
POS_SIDES_RIGHT
Right position.
|
static int |
POS_UPPER_LEFT
Upper let position.
|
static int |
POS_UPPER_MIDDLE
Upper middle position.
|
static int |
POS_UPPER_RIGHT
Right upper position.
|
Modifier and Type | Method and Description |
---|---|
void |
addFooter(FormattedText formattedText,
float bottomMargin)
Adds footer to the pages of the document.
|
void |
addFooter(FormattedText formattedText,
float bottomMargin,
float leftMargin,
float rightMargin)
Adds footer to the pages of the document.
|
void |
addFooter(InputStream imageStream,
float bottomMargin)
Adds image as footer of the page.
|
void |
addFooter(InputStream imageStream,
float bottomMargin,
float leftMargin,
float rightMargin)
Adds image as footer of the page.
|
void |
addFooter(String imageFile,
float bottomMargin)
Adds image as footer to the pages of the document.
|
void |
addFooter(String imageFile,
float bottomMargin,
float leftMargin,
float rightMargin)
Adds image as footer of the pages.
|
void |
addHeader(FormattedText formattedText,
float topMargin)
Adds header to the page.
|
void |
addHeader(FormattedText formattedText,
float topMargin,
float leftMargin,
float rightMargin)
Adds header to the pages of file.
|
void |
addHeader(InputStream imageStream,
float topMargin)
Adds image as header on the pages.
|
void |
addHeader(InputStream inputStream,
float topMargin,
float leftMargin,
float rightMargin)
Adds image at the top of the page.
|
void |
addHeader(String imageFile,
float topMargin)
Adds image as header to the pages of the file.
|
void |
addHeader(String imageFile,
float topMargin,
float leftMargin,
float rightMargin)
Adds image as header on the pages.
|
void |
addPageNumber(FormattedText formattedText)
Adds page number to the page.
|
void |
addPageNumber(FormattedText formattedText,
float x,
float y)
Adds page number at the specified position on the page.
|
void |
addPageNumber(FormattedText formattedText,
int position)
Adds page number to the pages.
|
void |
addPageNumber(FormattedText formattedText,
int position,
float leftMargin,
float rightMargin,
float topMargin,
float bottomMargin)
Adds page number to the pages of document.
|
void |
addPageNumber(String formatString)
Add page number to file.
|
void |
addPageNumber(String formatString,
float x,
float y)
Adds page number at the specified position on the page.
|
void |
addPageNumber(String formatString,
int position)
Adds page number to the pages.
|
void |
addPageNumber(String formatString,
int position,
float leftMargin,
float rightMargin,
float topMargin,
float bottomMargin)
Adds page number to the pages of document.
|
void |
addStamp(Stamp stamp)
Adds stamp to the file.
|
void |
close()
Closes opened files and saves changes.
|
void |
dispose()
Closes opened files and saves changes.
|
String |
getAttachmentName()
Gets name of attachment when result of operation is stored into HttpResponse objects as
attachment.
|
int |
getContentDisposition()
Gets how content will be stored when result of operation is stored into HttpResponse object.
|
IDocument |
getDocument()
Gets the document
PdfFileStamp is working on. |
String |
getInputFile()
Gets name and path of input file.
|
InputStream |
getInputStream()
Gets input stream.
|
boolean |
getKeepSecurity()
Keeps security if true.
|
String |
getOutputFile()
Gets name and path of output file.
|
OutputStream |
getOutputStream()
Gets output stream.
|
float |
getPageHeight()
Gets height of first page in souorce file.
|
float |
getPageNumberRotation()
Gets rotation of page number.
|
float |
getPageWidth()
Gets width of first page in input file.
|
SaveOptions |
getSaveOptions()
Gets save options when result is stored as HttpResponse.
|
int |
getStartingNumber()
Gets or sets starting number for first page in input file.
|
void |
setAttachmentName(String value)
Sets name of attachment when result of operation is stored into HttpResponse objects as
attachment.
|
void |
setContentDisposition(int value)
Sets how content will be stored when result of operation is stored into HttpResponse object.
|
void |
setConvertTo(int value)
Sets PDF file format.
|
void |
setInputFile(String value)
Sets name and path of input file.
|
void |
setInputStream(InputStream value)
Sets input stream.
|
void |
setKeepSecurity(boolean value)
Set Keep Security
|
void |
setOutputFile(String value)
Sets name and path of output file.
|
void |
setOutputStream(OutputStream value)
Sets or sets output stream.
|
void |
setPageNumberRotation(float value)
Sets rotation of page number.
|
void |
setSaveOptions(SaveOptions value)
Sets save options when result is stored as HttpResponse.
|
void |
setStartingNumber(int value)
Sets starting number for first page in input file.
|
static final int POS_BOTTOM_MIDDLE
Bottom middle position.
static final int POS_BOTTOM_RIGHT
Bottom right position.
static final int POS_UPPER_RIGHT
Right upper position.
static final int POS_SIDES_RIGHT
Right position.
static final int POS_UPPER_MIDDLE
Upper middle position.
static final int POS_BOTTOM_LEFT
Bottom left position.
static final int POS_SIDES_LEFT
Left position.
static final int POS_UPPER_LEFT
Upper let position.
boolean getKeepSecurity()
Keeps security if true. (This feature will be implemented in next versions).
void setKeepSecurity(boolean value)
value
- boolean valueString getInputFile()
Gets name and path of input file.
void setInputFile(String value)
Sets name and path of input file.
value
- String valueInputStream getInputStream()
Gets input stream.
void setInputStream(InputStream value)
Sets input stream.
value
- InputStream objectString getOutputFile()
Gets name and path of output file.
void setOutputFile(String value)
Sets name and path of output file.
value
- String objectOutputStream getOutputStream()
Gets output stream.
void setOutputStream(OutputStream value)
Sets or sets output stream.
value
- OutputStream objectfloat getPageNumberRotation()
Gets rotation of page number. Rotation is in degrees. Default is 0.
void setPageNumberRotation(float value)
Sets rotation of page number. Rotation is in degrees. Default is 0.
value
- float valuevoid setConvertTo(int 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.
value
- PdfFormat elementPdfFormat
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();
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();
int getStartingNumber()
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();
value
- int valuevoid 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();
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();
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();
stamp
- Stamp object which.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();
formatString
- Text of page numbervoid 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();
formattedText
- Format string for page number representes as FormattedText.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();
formatString
- Format string for page number.position
- 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,
PosUpperLeftleftMargin
- Margin on the left edge of the page.rightMargin
- Margin on the right edge of the page.topMargin
- Margin on the top edge of the page.bottomMargin
- Margin on the bottom edge of the page.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();
formatString
- Format string. Format string can contain # sign which will be replaced with page number.x
- X coordinate of page number.y
- Y coordinate of page number.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();
formattedText
- FormattedText object which represents page number format and properties iof the text.position
- 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,
PosUpperLeftleftMargin
- Margin on the left edge of the page.rightMargin
- Margin on the right edge of the page.topMargin
- Margin on the top edge of the page.bottomMargin
- Margin on the bottom edge of the page.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();
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
- X coordinate of page number.y
- Y coordinate of page number.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();
formattedText
- Text for header and properties of the text.topMargin
- Margin on the top of page.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);
formattedText
- Formatted text object which contains page text and its properties.topMargin
- Margin on the top of the page.leftMargin
- Margin on the left of the page.rightMargin
- Margin on the right of the page.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();
imageFile
- Path to the image file.topMargin
- Margin at top of the page.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();
imageFile
- Path to the image file.topMargin
- Margin at top of the page.leftMargin
- Margin at left side of the page.rightMargin
- Margin at right side of the page.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();
imageStream
- Stream of the image.topMargin
- Margin at top of the page.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();
inputStream
- Stream which contains image data.topMargin
- Margin at top of the page.leftMargin
- Margin at left side of the page.rightMargin
- Margin at right side of the page.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);
formattedText
- FormattedText object which contains text of the footer and text properties.bottomMargin
- Margin at the top of page.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);
formattedText
- FormattedText object which contains footer text and text properties.bottomMargin
- Margin at the bottom of the page.leftMargin
- Margin at the left side of the page.rightMargin
- Margin at the right side of the page.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();
imageFile
- Image file name and path.bottomMargin
- Margin at the bottom of the page.void addFooter(String imageFile, float bottomMargin, float leftMargin, float rightMargin)
Adds image as footer of the pages.
imageFile
- Iamge file name and path.bottomMargin
- Margin at the bottom of the page.leftMargin
- Margin at the left side of the page.rightMargin
- Margin at the right side of the page.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();
imageStream
- Stream contains image data.bottomMargin
- Margin at the bottom of the page.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();
imageStream
- Stream contains image data.bottomMargin
- Margin at the bottom of the page.leftMargin
- Margin at the left side of the page.rightMargin
- Margin at the right side of the page.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();
formatString
- Format of the page number. This text may contain # which will be replaced with page number.position
- 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,
PosUpperLeftvoid 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();
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
- 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,
PosUpperLeftIDocument getDocument()
Gets the document PdfFileStamp
is working on.
int getContentDisposition()
Gets how content will be stored when result of operation is stored into HttpResponse object. Possible value: inline / attachment. Default: inline.
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.
value
- ContentDisposition elementContentDisposition
SaveOptions getSaveOptions()
Gets save options when result is stored as HttpResponse. Default value: PdfSaveOptions.
void setSaveOptions(SaveOptions value)
Sets save options when result is stored as HttpResponse. Default value: PdfSaveOptions.
value
- SaveOptions valueString getAttachmentName()
Gets name of attachment when result of operation is stored into HttpResponse objects as attachment.
void setAttachmentName(String value)
Sets name of attachment when result of operation is stored into HttpResponse objects as attachment.
value
- String value