pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chitgoks <chitg...@gmail.com>
Subject Re: stamp annotation in pdf page 270 degree rotation incorrectly disdplayed
Date Mon, 15 Jan 2018 04:31:35 GMT
Hi tilman. i ended up rotating the returned BufferedImage instead.

I tried not to use raw commands and using only PDImageXObject  like in the
code above but the resized image is not accurate and i never did get the
transforming right so
i opted to just rotate the BufferedImage.

thanks for the help

mark

On Sun, Jan 14, 2018 at 9:59 PM, Tilman Hausherr <THausherr@t-online.de>
wrote:

> Am 14.01.2018 um 14:35 schrieb chitgoks:
>
>> i have not seen a sample appearance stream except that one involving raw
>> commands
>>
>
> In the CreateVisibleSignature2 code:
>
>
>
>             PDAppearanceDictionary appearance = new
> PDAppearanceDictionary();
>             appearance.getCOSObject().setDirect(true);
>             PDAppearanceStream appearanceStream = new
> PDAppearanceStream(form.getCOSObject());
>             appearance.setNormalAppearance(appearanceStream);
>             widget.setAppearance(appearance);
>
>             try (PDPageContentStream cs = new PDPageContentStream(doc,
> appearanceStream))
>             {
>                 // for 90° and 270° scale ratio of width / height
>                 // not really sure about this
>                 // why does scale have no effect when done in the form
> matrix???
>                 if (initialScale != null)
>                 {
>                     cs.transform(initialScale);
>                 }
>
>                 // show background (just for debugging, to see the rect
> size + position)
>                 cs.setNonStrokingColor(Color.yellow);
>                 cs.addRect(-5000, -5000, 10000, 10000);
>                 cs.fill();
>
>                 // show background image
>                 // save and restore graphics if the image is too large and
> needs to be scaled
>                 cs.saveGraphicsState();
>                 cs.transform(Matrix.getScaleInstance(0.25f, 0.25f));
>                 PDImageXObject img = PDImageXObject.createFromFileByExtension(imageFile,
> doc);
>                 cs.drawImage(img, 0, 0);
>                 cs.restoreGraphicsState();
>
>                 // show text
>                 float fontSize = 10;
>                 float leading = fontSize * 1.5f;
>                 cs.beginText();
>                 cs.setFont(font, fontSize);
>                 cs.setNonStrokingColor(Color.black);
>                 cs.newLineAtOffset(fontSize, height - leading);
>                 cs.setLeading(leading);
>                 cs.showText("(Signature very wide line 1)");
>                 cs.newLine();
>                 cs.showText("(Signature very wide line 2)");
>                 cs.newLine();
>                 cs.showText("(Signature very wide line 3)");
>                 cs.endText();
>             }
>
>             // no need to set annotations and /P entry
>
>             ByteArrayOutputStream baos = new ByteArrayOutputStream();
>             doc.save(baos);
>             return new ByteArrayInputStream(baos.toByteArray());
>         }
>     }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message