----------------------------------------
> Date: Fri, 20 Nov 2009 08:59:10 -0800
> From:
> To: itext-questions@lists.sourceforge.net
> Subject: Re: [iText-questions] How to find the position of an image in a 
> PDFfile?
>
> In general, unit testing PDF is all but impossible. You really need to 
> visually inspect the output.


One of my concerns about pdf has been its use to make computer readability
of informatio difficult. However, for human readability, there are
still some ways to do automated QA. Get an open source renderer
and verify that there really is white space where you think it should
be- pixel by pixel analysis should not be a mystery but it may be outside
the realm of itext. If you want exact replication of your image, you 
can check the pixels match your known source image or approximate it ( compress 
)
and verify some compression coefficients are close enough- DCT or DWT depending
on your preferences. 

Note that this is generally possible with audio and video too, you just need to 
find some way to measure the result, even computers running windoze can somtimes
run without a baby sitter and be used to automate data processing...




>
> As to your specific question, "where's my image?":
>
> 1: You need to know the resource name of the image in question. If there's 
> only one XObject Image and no XObject Form[s], you can simply latch onto the 
> first "Do" command you run into. If not... you need to hunt down the right 
> image... which may be burried in an XObject Form's resources which can be 
> burried in an XObject Form's resources... which can be... I think you get the 
> idea.
>
> 2: You need to determine the Current Transformation Matrix at the time the 
> image is drawn. com.cardiff.lowagie.pdf.parser.PdfContentStreamParser will 
> get you most of the way there, but NOT ALL. It doesn't recurse into XObject 
> Forms (and it probably should on general principle). When you locate the 
> correct "/MyResName Do" call, you need to peek() at the current GraphicsState 
> and get its Matrix.
>
> Which is package private. Huh. Well, if you're hacking up 
> PdfContentStreamParser, you might as well tweak that too.
>
> Oh, and in the general case, you need to check the page rotation and take 
> that into account as well.
>
> --Mark Storer
> Senior Software Engineer
> Cardiff.com
>
> #include 
> typedef std::Disclaimer DisCard;
>
>
>
>> -----Original Message-----
>> From: Larry Reeder [mailto:lnree...@gmail.com]
>> Sent: Friday, November 20, 2009 7:31 AM
>> To: Post all your questions about iText here
>> Subject: [iText-questions] How to find the position of an image in a
>> PDFfile?
>>
>>
>> Sorry to the list if you see this question twice. I previously posted
>> this message yesterday, but hasn't shown up on the list yet, so I'll
>> try it again.
>>
>> I've used the iText Java API to create a PDF with several images. Now
>> I'd like to write a unit test to verify my image placement logic. I
>> used Image.setAbsolutePosition to set the image when I initially
>> created the PDF. Now how do I get the position of that image when I
>> reopen the PDF? I know I can get the height and width of
>> images with something like this:
>>
>> PdfReader pdfReader = new PdfReader("mytestdoc.pdf");
>>
>> for (int i = 0; i < reader.getXrefSize(); i++)
>> {
>> PdfObject pdfobj = reader.getPdfObject(i);
>>
>> if (pdfobj != null && pdfobj.isStream())
>> {
>> PdfStream stream = (PdfStream) pdfobj;
>> PdfObject pdfsubtype = stream.get(PdfName.SUBTYPE);
>> if (pdfsubtype != null &&
>> PdfName.IMAGE.toString().equals(pdfsubtype.toString()))
>> {
>> int height = ((PdfNumber)
>> stream.get(PdfName.HEIGHT)).intValue();
>> int width = ((PdfNumber)
>> stream.get(PdfName.WIDTH)).intValue();
>>
>> System.err.println("image width/height: " +
>> width + ","+ height);
>> }
>>
>> }
>>
>> }
>>
>>
>> But how do I find the "x" and "y" of the image?
>>
>>
>> Thanks.............. Larry




Note: hotmail is now unusable for TEXT, I am moving to marchy...@gmail.com or 
also use
marchy...@yahoo.com. Thanks. NEVER USE HOTMAIL, EVER

Mike Marchywka
586 Saint James Walk
Marietta GA 30067-7165
415-264-8477 (w)<- use this
404-788-1216 (C)<- leave message
989-348-4796 (P)<- emergency only
marchy...@hotmail.com
Note: If I am asking for free stuff, I normally use for hobby/non-profit
information but may use in investment forums, public and private.
Please indicate any concerns if applicable.


                                          
_________________________________________________________________
Hotmail: Trusted email with powerful SPAM protection.
http://clk.atdmt.com/GBL/go/177141665/direct/01/
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
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/

Reply via email to