Package org.apache.pdfbox.pdmodel.interactive.annotation

Examples of org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationRubberStamp


                }
                for (PDPage page : document.getPages())
                {
                    List annotations = page.getAnnotations();

                    PDAnnotationRubberStamp rs = new PDAnnotationRubberStamp();
                    rs.setName(PDAnnotationRubberStamp.NAME_TOP_SECRET);
                    rs.setRectangle(new PDRectangle(100, 100));
                    rs.setContents("A top secret note");

                    annotations.add(rs);
                }

                document.save( args[1] );
View Full Code Here


   
                for (int i = 0; i < document.getNumberOfPages(); i++)
                {
                    PDPage page = document.getPage(i);
                    List annotations = page.getAnnotations();
                    PDAnnotationRubberStamp rubberStamp = new PDAnnotationRubberStamp();
                    rubberStamp.setName(PDAnnotationRubberStamp.NAME_TOP_SECRET);
                    rubberStamp.setRectangle(new PDRectangle(200,100));
                    rubberStamp.setContents("A top secret note");

                    // create a PDXObjectImage with the given image file
                    String imageFilename = args[2];
                    PDImageXObject ximage;
                    if( imageFilename.toLowerCase().endsWith( ".jpg" ) )
                    {
                        ximage = JPEGFactory.createFromStream(document, new FileInputStream(imageFilename));
                    }
                    else if (imageFilename.toLowerCase().endsWith(".tif") || imageFilename.toLowerCase().endsWith(".tiff"))
                    {
                        ximage = CCITTFactory.createFromRandomAccess(document, new RandomAccessFile(new File(imageFilename),"r"));
                    }
                    else if (imageFilename.toLowerCase().endsWith(".gif") ||
                            imageFilename.toLowerCase().endsWith(".bmp") ||
                            imageFilename.toLowerCase().endsWith(".png"))
                    {
                        BufferedImage bim = ImageIO.read(new File(imageFilename));
                        ximage = LosslessFactory.createFromImage(document, bim);
                    }
                    else
                    {
                        throw new IOException( "Image type not supported: " + imageFilename );
                    }                   

                    // define and set the target rectangle
                    int lowerLeftX = 250;
                    int lowerLeftY = 550;
                    int formWidth = 150;
                    int formHeight = 25;
                    int imgWidth = 50;
                    int imgHeight = 25;
                   
                    PDRectangle rect = new PDRectangle();
                    rect.setLowerLeftX(lowerLeftX);
                    rect.setLowerLeftY(lowerLeftY);
                    rect.setUpperRightX(lowerLeftX + formWidth);
                    rect.setUpperRightY(lowerLeftY + formHeight);

                    // Create a PDFormXObject
                    PDStream stream = new PDStream(document);
                    OutputStream os = stream.createOutputStream();
                    PDFormXObject form = new PDFormXObject(stream);
                    form.setResources(new PDResources());
                    form.setBBox(rect);
                    form.setFormType(1);

                    // adjust the image to the target rectangle and add it to the stream
                    drawXObject(ximage, form.getResources(), os, lowerLeftX, lowerLeftY, imgWidth, imgHeight);
                    os.close();

                    PDAppearanceStream myDic = new PDAppearanceStream(form.getCOSStream());
                    PDAppearanceDictionary appearance = new PDAppearanceDictionary(new COSDictionary());
                    appearance.setNormalAppearance(myDic);
                    rubberStamp.setAppearance(appearance);
                    rubberStamp.setRectangle(rect);

                    // add the new RubberStamp to the document
                    annotations.add(rubberStamp);
               
                }
View Full Code Here

    protected PDAnnotationRubberStamp pdRStamp = null;

    public RubberStampAnnotationValidator(PreflightContext ctx, COSDictionary annotDictionary)
    {
        super(ctx, annotDictionary);
        this.pdRStamp = new PDAnnotationRubberStamp(annotDictionary);
        this.pdAnnot = this.pdRStamp;
    }
View Full Code Here

    protected PDAnnotationRubberStamp pdRStamp = null;

    public RubberStampAnnotationValidator(PreflightContext ctx, COSDictionary annotDictionary)
    {
        super(ctx, annotDictionary);
        this.pdRStamp = new PDAnnotationRubberStamp(annotDictionary);
        this.pdAnnot = this.pdRStamp;
    }
View Full Code Here

  protected PDAnnotationRubberStamp pdRStamp = null;

  public RubberStampAnnotationValidator(DocumentHandler handler,
      COSDictionary annotDictionary) {
    super(handler, annotDictionary);
    this.pdRStamp = new PDAnnotationRubberStamp(annotDictionary);
    this.pdAnnot = this.pdRStamp;
  }
View Full Code Here

   
                for (int i=0; i < numberOfPages; i++)
                {
                    PDPage apage = (PDPage) allpages.get(i);
                    List annotations = apage.getAnnotations();
                    PDAnnotationRubberStamp rubberStamp = new PDAnnotationRubberStamp();
                    rubberStamp.setName(PDAnnotationRubberStamp.NAME_TOP_SECRET);
                    rubberStamp.setRectangle(new PDRectangle(100,100));
                    rubberStamp.setContents("A top secret note");

                    // create a PDXObjectImage with the given image file
                    String imageFilename = args[2];
                    PDXObjectImage ximage;
                    if (imageFilename.toLowerCase().endsWith(".jpg"))
                    {
                        ximage = new PDJpeg(document, new FileInputStream(imageFilename));
                    }
                    else if (imageFilename.toLowerCase().endsWith(".tif") || imageFilename.toLowerCase().endsWith(".tiff"))
                    {
                        ximage = new PDCcitt(document, new RandomAccessFile(new File(imageFilename), "r"));
                    }
                    else
                    {
                        BufferedImage awtImage = ImageIO.read(new File(imageFilename));
                        ximage = new PDPixelMap(document, awtImage);
                    }
                   
                    // define and set the target rectangle
                    int lowerLeftX = 250;
                    int lowerLeftY = 550;
                    int formWidth = 150;
                    int formHeight = 25;
                    int imgWidth = 50;
                    int imgHeight = 25;
                   
                    PDRectangle rect = new PDRectangle();
                    rect.setLowerLeftX(lowerLeftX);
                    rect.setLowerLeftY(lowerLeftY);
                    rect.setUpperRightX(lowerLeftX + formWidth);
                    rect.setUpperRightY(lowerLeftY + formHeight);

                    // Create a PDXObjectForm
                    PDStream stream = new PDStream(document);
                    OutputStream os = stream.createOutputStream();
                    PDXObjectForm form = new PDXObjectForm(stream);
                    form.setResources(new PDResources());
                    form.setBBox(rect);
                    form.setFormType(1);

                    // adjust the image to the target rectangle and add it to the stream
                    drawXObject(ximage, form.getResources(), os, lowerLeftX, lowerLeftY, imgWidth, imgHeight);
                    os.close();

                    PDAppearanceStream myDic = new PDAppearanceStream(form.getCOSStream());
                    PDAppearanceDictionary appearance = new PDAppearanceDictionary(new COSDictionary());
                    appearance.setNormalAppearance(myDic);
                    rubberStamp.setAppearance(appearance);
                    rubberStamp.setRectangle(rect);

                    //Add the new RubberStamp to the document
                    annotations.add(rubberStamp);
               
                }
View Full Code Here

   
                for (int i=0; i < numberOfPages; i++)
                {
                    PDPage apage = (PDPage) allpages.get(i);
                    List annotations = apage.getAnnotations();
                    PDAnnotationRubberStamp rubberStamp = new PDAnnotationRubberStamp();
                    rubberStamp.setName(PDAnnotationRubberStamp.NAME_TOP_SECRET);
                    rubberStamp.setRectangle(new PDRectangle(100,100));
                    rubberStamp.setContents("A top secret note");

                    // Create a PDXObjectImage with the given jpg
                    FileInputStream fin = new FileInputStream( args[2] );
                    PDJpeg mypic = new PDJpeg(document,fin);
                   
                    //Define and set the target rectangle
                    PDRectangle myrect = new PDRectangle();
                    myrect.setUpperRightX(275);
                    myrect.setUpperRightY(575);
                    myrect.setLowerLeftX(250);
                    myrect.setLowerLeftY(550);

                    // Create a PDXObjectForm
                    PDStream formstream = new PDStream(document);
                    OutputStream os = formstream.createOutputStream();
                    PDXObjectForm form = new PDXObjectForm(formstream);
                    form.setResources(new PDResources());
                    form.setBBox(myrect);
                    form.setFormType(1);
                    // adjust the image to the target rectangle and add it to the stream
                    drawXObject(mypic, form.getResources(), os, 250, 550, 25, 25);
                    os.close();

                    PDAppearanceStream myDic = new PDAppearanceStream(form.getCOSStream());
                    PDAppearanceDictionary appearance = new PDAppearanceDictionary(new COSDictionary());
                    appearance.setNormalAppearance(myDic);
                    rubberStamp.setAppearance(appearance);
                    rubberStamp.setRectangle(myrect);

                    //Add the new RubberStamp to the document
                    annotations.add(rubberStamp);
               
                }
View Full Code Here

                for (int i=0; i < allpages.size(); i++)
                {
                    PDPage apage = (PDPage) allpages.get(i);
                    List annotations = apage.getAnnotations();

                    PDAnnotationRubberStamp rs = new PDAnnotationRubberStamp();
                    rs.setName(PDAnnotationRubberStamp.NAME_TOP_SECRET);
                    rs.setRectangle(new PDRectangle(100,100));
                    rs.setContents("A top secret note");

                    annotations.add(rs);
                }

                document.save( args[1] );
View Full Code Here

TOP

Related Classes of org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationRubberStamp

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.