public final class PdfPageEditor extends SaveableFacade
Represents a class to edit the PDF file's page, including rotating page, zooming page, moving position and changing page size.
Modifier and Type | Field and Description |
---|---|
static int |
BLINDH
Vertical Blinds
|
static int |
BLINDV
Vertical Blinds
|
static int |
BTWIPE
Bottom-Top Wipe
|
static int |
DGLITTER
Diagonal Glitter
|
static int |
DISSOLVE
The old page dissolves
|
static int |
INBOX
Inward Box
|
static int |
LRGLITTER
Left-Right Glitter
|
static int |
LRWIPE
Left-Right Wipe
|
static int |
OUTBOX
Outward Box
|
static int |
RLWIPE
Right-Left Wipe
|
static int |
SPLITHIN
IN Horizontal Split
|
static int |
SPLITHOUT
Out Horizontal Split
|
static int |
SPLITVIN
In Vertical Split
|
static int |
SPLITVOUT
Out Vertical Split
|
static int |
TBGLITTER
Top-Bottom Glitter
|
static int |
TBWIPE
Top-Bottom Wipe
|
Constructor and Description |
---|
PdfPageEditor()
Constructor for PdfPageEditor class.
|
PdfPageEditor(Document document)
Constructor for PdfPageEditor class.
|
Modifier and Type | Method and Description |
---|---|
void |
applyChanges()
Apply changes made to the document pages.
|
AlignmentType |
getAlignment()
Deprecated.
|
int |
getDisplayDuration()
Gets display duration for pages.
|
int |
getHorizontalAlignment()
Gets the horizontal alignment of the original PDF content on the result page, default is
AlignmentType.Left.
|
Rectangle |
getPageBoxSize(int page,
String pageBoxName)
Returns size of specified box in document.
|
int |
getPageRotation(int page)
Returns the rotation of specified page.
|
Map<Integer,Integer> |
getPageRotations()
Gets the rotation of the pages, A hashtable contains the page number and rotation degree, the
key represents the page number, the value of key represents the rotation in degrees.
|
int |
getPages()
Returns total number of pages.
|
PageSize |
getPageSize()
Gets the output file's page size.
|
PageSize |
getPageSize(int page)
Returns the page size of the specified page.
|
int[] |
getProcessPages()
Gets the page numbers to be edited.
|
int |
getRotation()
Gets the rotation of the pages, the rotation must be 0, 90, 180 or 270.
|
int |
getTransitionDuration()
Gets duration of the transition effect.
|
int |
getTransitionType()
Gets transition style to use when moving to this page from another during a presentation.
|
VerticalAlignmentType |
getVerticalAlignment()
Deprecated.
|
int |
getVerticalAlignmentType()
Gets the vertical alignment of the original PDF content on the result page, default is
VerticalAlignmentType.Bottom.
|
float |
getZoom()
Get zoom coefficient.
|
void |
movePosition(float moveX,
float moveY)
Moves the origin from (0, 0) to the point that appointted.
|
void |
save(OutputStream outputStream)
Saves changed document into stream.
|
void |
save(String outputFile)
Saves changed document into file.
|
void |
setAlignment(AlignmentType value)
Deprecated.
|
void |
setDisplayDuration(int value)
Sets display duration for pages.
|
void |
setHorizontalAlignment(int value)
Sets the horizontal alignment of the original PDF content on the result page, default is
AlignmentType.Left.
|
void |
setPageRotations(Map<Integer,Integer> value)
Sets the rotation of the pages, A hashtable contains the page number and rotation degree, the
key represents the page number, the value of key represents the rotation in degrees.
|
void |
setPageSize(PageSize value)
Sets the output file's page size.
|
void |
setProcessPages(int[] value)
Sets the page numbers to be edited.
|
void |
setRotation(int value)
Sets the rotation of the pages, the rotation must be 0, 90, 180 or 270.
|
void |
setTransitionDuration(int value)
Sets duration of the transition effect.
|
void |
setTransitionType(int value)
Sets transition style to use when moving to this page from another during a presentation.
|
void |
setVerticalAlignment(VerticalAlignmentType value)
Deprecated.
|
void |
setVerticalAlignmentType(int value)
Sets the vertical alignment of the original PDF content on the result page, default is
VerticalAlignmentType.Bottom.
|
void |
setZoom(float value)
Sets zoom coefficient.
|
bindPdf, bindPdf, bindPdf, bindPdf, bindPdf, close, dispose, getDocument
public static final int SPLITVOUT
Out Vertical Split
public static final int SPLITHOUT
Out Horizontal Split
public static final int SPLITVIN
In Vertical Split
public static final int SPLITHIN
IN Horizontal Split
public static final int BLINDV
Vertical Blinds
public static final int BLINDH
Vertical Blinds
public static final int INBOX
Inward Box
public static final int OUTBOX
Outward Box
public static final int LRWIPE
Left-Right Wipe
public static final int RLWIPE
Right-Left Wipe
public static final int BTWIPE
Bottom-Top Wipe
public static final int TBWIPE
Top-Bottom Wipe
public static final int DISSOLVE
The old page dissolves
public static final int LRGLITTER
Left-Right Glitter
public static final int TBGLITTER
Top-Bottom Glitter
public static final int DGLITTER
Diagonal Glitter
public PdfPageEditor()
Constructor for PdfPageEditor class.
public PdfPageEditor(Document document)
Constructor for PdfPageEditor class.
document
- Document object which should be processed.public int getTransitionDuration()
Gets duration of the transition effect.
public void setTransitionDuration(int value)
Sets duration of the transition effect.
value
- int valuepublic int getTransitionType()
Gets transition style to use when moving to this page from another during a presentation.
public void setTransitionType(int value)
Sets transition style to use when moving to this page from another during a presentation.
value
- int valuepublic int getDisplayDuration()
Gets display duration for pages.
public void setDisplayDuration(int value)
Sets display duration for pages.
value
- int valuepublic int[] getProcessPages()
Gets the page numbers to be edited. By default, each page would be edited.
public void setProcessPages(int[] value)
Sets the page numbers to be edited. By default, each page would be edited.
value
- array of int valuespublic int getRotation()
Gets the rotation of the pages, the rotation must be 0, 90, 180 or 270. Default value is 0.
public void setRotation(int value)
Sets the rotation of the pages, the rotation must be 0, 90, 180 or 270. Default value is 0.
value
- int valuepublic Map<Integer,Integer> getPageRotations()
Gets the rotation of the pages, A hashtable contains the page number and rotation degree, the key represents the page number, the value of key represents the rotation in degrees.
Map<Integer, Integer>
objectpublic void setPageRotations(Map<Integer,Integer> value)
Sets the rotation of the pages, A hashtable contains the page number and rotation degree, the key represents the page number, the value of key represents the rotation in degrees.
value
- Map<Integer, Integer>
objectpublic float getZoom()
Get zoom coefficient. Value 1.0 corresponds to 100%. Default value is 1.0.
public void setZoom(float value)
Sets zoom coefficient. Value 1.0 corresponds to 100%. Default value is 1.0.
value
- float value
The following example demonstrates how to change zoom of the document pages. PdfPageEditor editor = new PdfPageEditor(); editor.bindPdf("sample.pdf"); editor.setZoom ( 0.5f);
public PageSize getPageSize()
Gets the output file's page size.
public void setPageSize(PageSize value)
Sets the output file's page size.
value
- PageSize object@Deprecated public AlignmentType getAlignment()
Gets the horizontal alignment of the original PDF content on the result page, default is
AlignmentType.Left.
Use getHorizontalAlignment instead
HorizontalAlignment
@Deprecated public void setAlignment(AlignmentType value)
Sets the horizontal alignment of the original PDF content on the result page, default is
AlignmentType.Left.
Use setHorizontalAlignment instead
value
- AlignmentType valuepublic int getHorizontalAlignment()
Gets the horizontal alignment of the original PDF content on the result page, default is AlignmentType.Left.
HorizontalAlignment
public void setHorizontalAlignment(int value)
Sets the horizontal alignment of the original PDF content on the result page, default is AlignmentType.Left.
value
- int valueHorizontalAlignment
@Deprecated public VerticalAlignmentType getVerticalAlignment()
Gets the vertical alignment of the original PDF content on the result page, default is
VerticalAlignmentType.Bottom.
Use getVerticalAlignmentType instead
@Deprecated public void setVerticalAlignment(VerticalAlignmentType value)
Sets the vertical alignment of the original PDF content on the result page, default is
VerticalAlignmentType.Bottom.
Use setVerticalAlignmentType instead
value
- VerticalAlignmentType valuepublic int getVerticalAlignmentType()
Gets the vertical alignment of the original PDF content on the result page, default is VerticalAlignmentType.Bottom.
VerticalAlignmentType
public void setVerticalAlignmentType(int value)
Sets the vertical alignment of the original PDF content on the result page, default is VerticalAlignmentType.Bottom.
value
- VerticalAlignment elementVerticalAlignment
public void movePosition(float moveX, float moveY)
Moves the origin from (0, 0) to the point that appointted. The origin is left-bottom and the unit is point(1 inch = 72 points).
PdfPageEditor editor = new PdfPageEditor(); editor.bindPdf("input.pdf"); editor.movePosition(-100, 60); editor.save("moved.pdf");
moveX
- X-coordinate.moveY
- Y-coordinate.public int getPages()
Returns total number of pages.
The following example demonstrates using of GetPages() method: PdfPageEditor editor = new PdfPageEditor(); editor.bindPdf("sample.pdf"); System.out.println("Document has: " + editor.GetPages());
public PageSize getPageSize(int page)
Returns the page size of the specified page.
The following example demonstrates using of GetPageSize method: PdfPageEditor editor = new PdfPageEditor(); editor.bindPdf("sample.pdf"); PageSize size = editor.getPageSize(1); System.out.println("Size of 1st page : " + size.getWidth() + " x " + size.getHeight());
page
- Page index. Document pages are numbered from 1.public int getPageRotation(int page)
Returns the rotation of specified page.
The following example demonstrates how to get page rotation: PdfPageEditor editor = new PdfPageEditor(); editor.bindPdf("sample.pdf"); int rotation = editor.getPageSize(1); System.out.println("Rotation of 1st page : " + rotation + " degrees");
page
- Page index. Document pages are numbered from 1.public Rectangle getPageBoxSize(int page, String pageBoxName)
Returns size of specified box in document.
The following example demonstrates how to get media box of the 1st page: PdfPageEditor editor = new PdfPageEditor(); editor.bindPdf("sample.pdf"); Rectangle rect = editor.getBoxSize(1, "media");
page
- Page index. Document pages are numbered from 1.pageBoxName
- Box type name. Valid values are: "art", "bleed", "crop", "media", "trim".public void save(String outputFile)
Saves changed document into file.
The following sample demonstrates how to save changed PDF document PdfPageEditor editor = new PdfPageEditor(); editor.bindPdf("sample.pdf"); editor.setZoom ( 0.5f); editor.save("newdocument.pdf");
save
in interface ISaveableFacade
save
in class SaveableFacade
outputFile
- Path to file where document will be saved.public void save(OutputStream outputStream)
Saves changed document into stream.
The following sample demonstrates how to save changed PDF document into stream. PdfPageEditor editor = new PdfPageEditor(); editor.bindPdf("sample.pdf"); editor.setZoom ( 0.5f); editor.save("newdocument.pdf");
save
in interface ISaveableFacade
save
in class SaveableFacade
outputStream
- Stream where changed PDF document will be saved.public void applyChanges()
Apply changes made to the document pages.