pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thad Humphries <thad.humphr...@gmail.com>
Subject Re: rubberstamp annotation with base 64 image
Date Thu, 01 Jun 2017 12:48:13 GMT
On Thu, Jun 1, 2017 at 8:13 AM, chitgoks <chitgoks@gmail.com> wrote:

> Hi Peter
>
> PDImageXObject imageSig = LosslessFactory.createFromImage(pdfDocument,
>                           ImageIO.read(new
> ByteArrayInputStream(DatatypeConverter.parseBase64Binary(base64Png))));
>
> works if base64 string is png..
>
> but it does not work if the base 64 is an svg.
>
> data:image/svg+xml;base64,PHN2ZyB4bW......
>
> is this a limitation?
>
> please advise
>
> mark


PDImageXObject requires a bitmap image. Internally it holds a
java.awt.image.BufferedImage. You will need to convert your SVG to a
BufferedImage. I've not done this, but  code on there is code on
Stackoverflow for it using Apache Batik:
https://stackoverflow.com/a/13931120/1316011


>
>
> Website/Java Games: http://www.chitgoks.com
> My Blogs:
> http://tech.chitgoks.com
> http://wuhtevah.chitgoks.com
> http://disneyusa.blogspot.com
>
> On Thu, Jun 1, 2017 at 8:08 PM, Peter Pinnau <peter.pinnau@unterbrecher.de
> >
> wrote:
>
> > Hallo
> >
> >> but the sample shows loading it from a file.
> >>
> >> im looking to create a BufferedImage from a base64 svg string. has
> anybody
> >> tried this?
> >>
> > I think you can create a PDImageXObject object from a BufferedImage using
> >
> > org.apache.pdfbox.pdmodel.graphics.image.JPEGFactory factory
> >
> > JPEGFactory.createFromImage( PDDocument, BufferedImage , float quality,
> > int resolution);
> >
> >
> > --
> > Viele Grüße
> > Peter Pinnau
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> > For additional commands, e-mail: users-help@pdfbox.apache.org
> >
> >
>



-- 
"Hell hath no limits, nor is circumscrib'd In one self-place; but where we
are is hell, And where hell is, there must we ever be" --Christopher
Marlowe, *Doctor Faustus* (v. 121-24)

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