Home  Products  Purchase  Downloads  Demos  Forums  Blogs  Ticket  Wiki  API  Corporate

com.aspose.pdf.kit
Class PdfFileMend

java.lang.Object
  extended bycom.aspose.pdf.kit.PdfFileMend

public class PdfFileMend
extends java.lang.Object

Represents a class for adding texts and images on the pages of existing Pdf file.


Constructor Summary
PdfFileMend(java.io.InputStream inputStream, java.io.OutputStream outputStream)
          Initializes an object instance of PdfFileMend.
PdfFileMend(java.lang.String inputFileName, java.lang.String outputFileName)
          Initializes an object instance of PdfFileMend.
 
Method Summary
 boolean addImage(java.io.InputStream imageStream, int[] pageNums, float lowerLeftX, float lowerLeftY, float upperRightX, float upperRightY)
          Adheres image to the page of Pdf file at given coordinates,Jpg,Gif,Png,Bmp are supported.
 boolean addImage(java.io.InputStream imageStream, int pageNum, float lowerLeftX, float lowerLeftY, float upperRightX, float upperRightY)
          Adheres image to the page of Pdf file at given coordinates,Jpg,Gif,Png,Bmp are supported.
 boolean addImage(java.lang.String imageName, int[] pageNums, float lowerLeftX, float lowerLeftY, float upperRightX, float upperRightY)
          Adheres image to the page of Pdf file at given coordinates,Jpg,Gif,Png,Bmp are supported.
 boolean addImage(java.lang.String imageName, int pageNum, float lowerLeftX, float lowerLeftY, float upperRightX, float upperRightY)
          Adheres image to the page of Pdf file at given coordinates,Jpg,Gif,Png,Bmp are supported.
 boolean addText(FormattedText text, int[] pageNums, float lowerLeftX, float lowerLeftY, float upperRightX, float upperRightY)
          Adheres text to the page of Pdf file at given coordinates.
 boolean addText(FormattedText text, int pageNum, float lowerLeftX, float lowerLeftY, float upperRightX, float upperRightY)
          Adheres text to the page of Pdf file at given coordinates.
 void close()
          Writes the text and image to the input stream or file,and closes the PdfFileMend object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PdfFileMend

public PdfFileMend(java.lang.String inputFileName,
                   java.lang.String outputFileName)
            throws java.io.FileNotFoundException,
                   java.io.IOException,
                   PdfKitException
Initializes an object instance of PdfFileMend.

Parameters:
inputFileName - String Input Pdf file (path)name.
outputFileName - String Output Pdf file (path)name.
Throws:
java.io.FileNotFoundException
java.io.IOException
PdfKitException

PdfFileMend

public PdfFileMend(java.io.InputStream inputStream,
                   java.io.OutputStream outputStream)
            throws java.io.IOException,
                   PdfKitException
Initializes an object instance of PdfFileMend.

Parameters:
inputStream - InputStream Input Pdf stream.
outputStream - OutputStream Output Pdf stream.
Throws:
java.io.IOException
PdfKitException
Method Detail

addText

public boolean addText(FormattedText text,
                       int pageNum,
                       float lowerLeftX,
                       float lowerLeftY,
                       float upperRightX,
                       float upperRightY)
                throws PdfKitException,
                       java.io.IOException
Adheres text to the page of Pdf file at given coordinates.

Parameters:
text - FormattedText Text with format to be added.
pageNum - int Indicates which page will the text be added to.
lowerLeftX - float The horizontal position of lower left point on the retangle area lined out for adding text.
lowerLeftY - float The vertical position of lower left point on the retangle area lined out for adding text.
upperRightX - float The horizontal position of upper right point on the retangle area lined out for adding text.
upperRightY - float The vertical position of upper right point on the retangle area lined out for adding text.
Returns:
boolean - True for success,or false.
Throws:
PdfKitException
java.io.IOException

addText

public boolean addText(FormattedText text,
                       int[] pageNums,
                       float lowerLeftX,
                       float lowerLeftY,
                       float upperRightX,
                       float upperRightY)
                throws java.io.IOException,
                       PdfKitException
Adheres text to the page of Pdf file at given coordinates.

 [SampleCode]
 String inputFile = "rotation270.pdf";
 String outputFile = "kitOut.pdf";
 int[] pages = new int[] {1,2};
 PdfFileInfo fileInfo = new PdfFileInfo(inputFile);
 float height = fileInfo.getPageHeight(1);
 float width = fileInfo.getPageWidth(1);
 int rotation = fileInfo.getPageRotation(1);
 PdfFileMend mendor = new PdfFileMend(inputFile, outputFile);
 switch (rotation) {
 case 0:
 mendor.addText(new FormattedText("PdfFileMend testing! 0 rotation."),pages, 10, height - 25, width, height - 10); //lowerleftX < upperrightX,lowerleftY < upperrightY
 break;
 case 90:
 mendor.addText(new FormattedText("PdfFileMend testing! 90 rotation."),pages, width - 25, height - 10, width - 45,height - 150); //lowerleftX > upperrightX,lowerleftY > upperrightY
 break;
 case 180:
 mendor.addText(new FormattedText("PdfFileMend testing! 180 rotation."),pages, 10, 10, width, 25); //lowerleftX < upperrightX,lowerleftY < upperrightY
 break;
 case 270:
 mendor.addText(new FormattedText("PdfFileMend testing! 270 rotation."),pages, 10, 10, 25, height - 10); //lowerleftX < upperrightX,lowerleftY < upperrightY
 break;
 default:
 break;
 }
 mendor.close();
 }
 

Parameters:
text - FormattedText Text with format to be added.
pageNums - int[] Indicates which pages will the text be added to.
lowerLeftX - float The horizontal position of lower left point on the retangle area lined out for adding text.
lowerLeftY - float The vertical position of lower left point on the retangle area lined out for adding text.
upperRightX - float The horizontal position of upper right point on the retangle area lined out for adding text.
upperRightY - float The vertical position of upper right point on the retangle area lined out for adding text.
Returns:
boolean - True for success,or false.
Throws:
java.io.IOException
PdfKitException

addImage

public boolean addImage(java.lang.String imageName,
                        int pageNum,
                        float lowerLeftX,
                        float lowerLeftY,
                        float upperRightX,
                        float upperRightY)
                 throws java.io.IOException,
                        com.aspose.pdf.kit.BadElementException,
                        PdfKitException
Adheres image to the page of Pdf file at given coordinates,Jpg,Gif,Png,Bmp are supported.

Parameters:
imageName - String Input image (path)name.
pageNum - int Indicates which page will the image be added to.
lowerLeftX - float The horizontal position of lower left point on the retangle area lined out for adding image.
lowerLeftY - float The vertical position of lower left point on the retangle area lined out for adding image.
upperRightX - float The horizontal position of upper right point on the retangle area lined out for adding image.
upperRightY - float The vertical position of upper right point on the retangle area lined out for adding image.
Returns:
boolean - True for success,or false.
Throws:
BadElementException
java.io.IOException
PdfKitException

addImage

public boolean addImage(java.lang.String imageName,
                        int[] pageNums,
                        float lowerLeftX,
                        float lowerLeftY,
                        float upperRightX,
                        float upperRightY)
                 throws com.aspose.pdf.kit.BadElementException,
                        java.io.IOException,
                        PdfKitException
Adheres image to the page of Pdf file at given coordinates,Jpg,Gif,Png,Bmp are supported.

Parameters:
imageName - String Input image (path)name.
pageNums - int[] Indicates which pages will the image be added to.
lowerLeftX - float The horizontal position of lower left point on the retangle area lined out for adding image.
lowerLeftY - float The vertical position of lower left point on the retangle area lined out for adding image.
upperRightX - float The horizontal position of upper right point on the retangle area lined out for adding image.
upperRightY - float The vertical position of upper right point on the retangle area lined out for adding image.
Returns:
boolean - True for success,or false.
Throws:
BadElementException
java.io.IOException
PdfKitException

addImage

public boolean addImage(java.io.InputStream imageStream,
                        int pageNum,
                        float lowerLeftX,
                        float lowerLeftY,
                        float upperRightX,
                        float upperRightY)
                 throws com.aspose.pdf.kit.BadElementException,
                        java.io.IOException,
                        PdfKitException
Adheres image to the page of Pdf file at given coordinates,Jpg,Gif,Png,Bmp are supported.

Parameters:
imageStream - InputStream Input image stream.
pageNum - int Indicates which page will the image be added to.
lowerLeftX - float The horizontal position of lower left point on the retangle area lined out for adding image.
lowerLeftY - float The vertical position of lower left point on the retangle area lined out for adding image.
upperRightX - float The horizontal position of upper right point on the retangle area lined out for adding image.
upperRightY - float The vertical position of upper right point on the retangle area lined out for adding image.
Returns:
boolean - True for success,or false.
Throws:
BadElementException
java.io.IOException
PdfKitException

addImage

public boolean addImage(java.io.InputStream imageStream,
                        int[] pageNums,
                        float lowerLeftX,
                        float lowerLeftY,
                        float upperRightX,
                        float upperRightY)
                 throws com.aspose.pdf.kit.BadElementException,
                        java.io.IOException,
                        PdfKitException
Adheres image to the page of Pdf file at given coordinates,Jpg,Gif,Png,Bmp are supported.

 [SampleCode]
 String inputFile = "example2.pdf";
 String imageName = "butterfly.jpg";
 String outputFile = "kitOut.pdf";
 int[] pages = new int[] {1, 2, 3, 4, 5};
 FileInputStream inPdfStream = new FileInputStream(inputFile);
 FileInputStream inImgStream = new FileInputStream(imageName);
 FileOutputStream outputStream = new FileOutputStream(outputFile);
 PdfFileMend mendor = new PdfFileMend(inPdfStream, outputStream);
 mendor.addImage(inImgStream, pages, 50, 50, 100, 100);
 mendor.close();
 outputStream.close();
 

Parameters:
imageStream - InputStream Input image stream.
pageNums - int[] Indicates which pages will the image be added to.
lowerLeftX - float The horizontal position of lower left point on the retangle area lined out for adding image.
lowerLeftY - float The vertical position of lower left point on the retangle area lined out for adding image.
upperRightX - float The horizontal position of upper right point on the retangle area lined out for adding image.
upperRightY - float The vertical position of upper right point on the retangle area lined out for adding image.
Returns:
boolean - True for success,or false.
Throws:
BadElementException
java.io.IOException
PdfKitException

close

public void close()
           throws java.io.IOException,
                  PdfKitException
Writes the text and image to the input stream or file,and closes the PdfFileMend object.

Throws:
java.io.IOException
PdfKitException