Alternative text for images

View: New views
2 Messages — Rating Filter:   Alert me  

Alternative text for images

by Juan Antonio Mayol :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I have a pdf created with Adobe Acrobat 9, I am trying to access the alternate text for images of this document, but always appears as null.

This is the code I'm using:


PdfReader reader = new PdfReader("c:\\tmp\\textoAlternativo.pdf");

for (int i = 0; i < reader.getXrefSize(); i++) {
    PdfObject pdfobj = reader.getPdfObject(i);
    if (pdfobj != null) {
        if (pdfobj.isStream()) {
            PdfStream stream = (PdfStream) pdfobj;
            PdfObject pdfsubtype = stream.get(PdfName.SUBTYPE);
            if (pdfsubtype != null) {
                if (pdfsubtype.toString().equals(PdfName.IMAGE.toString())) {
                   
                    byte[] img = PdfReader.getStreamBytesRaw((PRStream) stream);
                   
                    Image img1 = Image.getInstance(img);
                    System.out.println("alt1 "+img1.getAlt());

                    System.out.println("alt2 "+stream.get(PdfName.ALT));

                }
            }
        }
    }
}

Thanks,

Juan Antonio Mayol

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
iText-questions mailing list
iText-questions@...
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Re: Alternative text for images

by 1T3XT info :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Juan Antonio Mayol wrote:
> Hi,
>
> I have a pdf created with Adobe Acrobat 9, I am trying to access the
> alternate text for images of this document, but always appears as null.

Read the PDF Reference or ISO-32000.
The alternative text isn't part of the image bytes!
Alternative text is added using the concept of marked content.
It's beyond the scope of the mailing list to explain this concept,
as it would take too much time to do this for free.
--
This answer is provided by 1T3XT BVBA
http://www.1t3xt.com/ - http://www.1t3xt.info

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
iText-questions mailing list
iText-questions@...
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/