public class PdfDocument extends Document
Represents a pdf document where a watermark can be placed.
This example demonstrates how to load and save PDF document of any supported version.
PdfDocument document = Document.load(PdfDocument.class, "D:\\input.pdf"); // Use addWatermark method to add watermark to all pages. // Use the collection of pages to add watermark to a particular page. // Save changes. document.save("D:\\output.pdf"); document.close();
Modifier and Type | Method and Description |
---|---|
void |
addAnnotationWatermark(Watermark watermark)
Adds an annotation watermark to all pages of this
PdfDocument . |
void |
addAnnotationWatermark(Watermark watermark,
boolean isPrintOnly)
Adds an annotation watermark to all pages of this
PdfDocument . |
void |
addArtifactWatermark(Watermark watermark)
Adds an artifact watermark to all pages of this
PdfDocument . |
void |
decrypt()
Decrypts the document.
|
protected void |
dispose(boolean disposing)
Releases all resources used by the
PdfDocument |
void |
encrypt(String password)
Encrypts the document using the same password as user password and owner password.
|
void |
encrypt(String userPassword,
String ownerPassword,
int permissions,
int cryptoAlgorithm)
Encrypts the document.
|
PdfAttachmentCollection |
getAttachments()
Gets the collection of all attachments of this
PdfDocument . |
int |
getPageMarginType()
Gets pdf page margins to be used during watermark adding.
|
PdfPageCollection |
getPages()
Gets the collection of all pages of this
PdfDocument . |
void |
rasterize(int horizontalResolution,
int verticalResolution,
int imageFormat)
Converts all document pages into images.
|
void |
setPageMarginType(int value)
Sets pdf page margins to be used during watermark adding.
|
close, dispose, getDefaultSearchableObjects, getInfo, getInfo, getSearchableObjects, load, load, load, load, load, load, load, load, save, save, setDefaultSearchableObjects, setSearchableObjects
addWatermark, findImages, findImages, findWatermarks, findWatermarks
public final PdfPageCollection getPages()
Gets the collection of all pages of this PdfDocument
.
PdfDocument
.
This example demonstrates how to add watermark to a particular page.
PdfDocument document = Document.load(PdfDocument.class, "D:\\input.pdf"); // Initialize text or image watermark. TextWatermark watermark = new TextWatermark("DRAFT", new Font("Arial", 19)); // Add watermark to a particular page. document.getPages().get_Item(0).addWatermark(watermark); // Save changes. document.save("D:\\output.pdf"); document.close();
public final PdfAttachmentCollection getAttachments()
Gets the collection of all attachments of this PdfDocument
.
PdfDocument
.public final int getPageMarginType()
Gets pdf page margins to be used during watermark adding.
This property works only when GroupDocs.Watermark.Watermark.ConsiderParentMargins
is set to true.
If GroupDocs.Watermark.Watermark.ConsiderParentMargins
is false, when pdf CropBox is used as watermarking area.
P:WatermarkingPageMargins.TrimBox
.public final void setPageMarginType(int value)
Sets pdf page margins to be used during watermark adding.
This property works only when GroupDocs.Watermark.Watermark.ConsiderParentMargins
is set to true.
If GroupDocs.Watermark.Watermark.ConsiderParentMargins
is false, when pdf CropBox is used as watermarking area.
value
- Pdf page margins to be used during watermark adding.
The default value is P:WatermarkingPageMargins.TrimBox
.public final void addArtifactWatermark(Watermark watermark)
Adds an artifact watermark to all pages of this PdfDocument
.
This method assumes that watermark offset and size are measured in points (if they are assigned).
watermark
- The watermark to add to the document.public final void addAnnotationWatermark(Watermark watermark, boolean isPrintOnly)
Adds an annotation watermark to all pages of this PdfDocument
.
This method assumes that watermark offset and size are measured in points (if they are assigned).
watermark
- The watermark to add to the document.isPrintOnly
- The value indicating whether annotation will be printed,
but not displayed in pdf viewing application.public final void addAnnotationWatermark(Watermark watermark)
Adds an annotation watermark to all pages of this PdfDocument
.
This method assumes that watermark offset and size are measured in points (if they are assigned).
watermark
- The watermark to add to the document.public final void encrypt(String password)
Encrypts the document using the same password as user password and owner password.
password
- User and owner password.public final void encrypt(String userPassword, String ownerPassword, int permissions, int cryptoAlgorithm)
Encrypts the document.
userPassword
- User password.ownerPassword
- Owner password.permissions
- Document permissions.cryptoAlgorithm
- Cryptographic algorithm.public final void decrypt()
Decrypts the document.
public final void rasterize(int horizontalResolution, int verticalResolution, int imageFormat)
Converts all document pages into images.
horizontalResolution
- Horizontal image resolution.verticalResolution
- Vertical image resolution.imageFormat
- Image format.Copyright © 2018. All rights reserved.