The problem is that you are doing two calculations with the pdf and by
default iText doesn't have that kind of precision by default. Call
ByteBuffer.HIGH_PRECISION=true.

Paulo

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Andrew Bligh
> Sent: Thursday, April 17, 2008 11:04 AM
> To: Post all your questions about iText here
> Subject: Re: [iText-questions] Image extracted from PDF file 
> and scaledis slightly bigger than expected.
> 
> Hi Paulo,
> 
> Thanks for your quick response. I've attached atest program 
> if you would like to take a look. If you rename the file to a 
> .zip extension andextract theit to the root of your C: drive 
> (I hope your using awindows machine). Then from the command line run:
> 
> java -cp PATH_TO_JRE_LIB_FOLDER;PATH_TO_ITEXT_JAR; PdfGeneration 
> 
> Two PDF files will be produced to the C:\test_app directory:
> 
> - testPdf.pdf
> - testJpg.pdf
> 
> I haveincluded these files for quick viewing. You will need 
> to zoom right into see the container borders. You will notice 
> the jpg image source file(yellow square) is exact but the pdf 
> image source file(green sqaure) isout to the top and left. I 
> can see where your idea that the documentsizes as Integers 
> could be a problem but I would have thought the scaleabsolute 
> method would neutralise this? Can I also mention that 
> sometimesthe pdf image sources are smaller to the top and 
> left of the containerby about the same amount as they are 
> over in this example?
> 
> Thanks & regards,
> 
> Andrew
> 
> > Date: Wed, 16 Apr 2008 17:35:17 +0100
> > From: [EMAIL PROTECTED]
> > To: [email protected]
> > Subject: Re: [iText-questions] Image extracted from PDF 
> file and scaled is slightly bigger than expected.
> > 
> > The page dimensions are usually integers and that limits 
> the precision
> > to 0.35 mm. Without being able to reproduce the problem 
> that's all I can
> > guess.
> > 
> > Paulo 
> > 
> > > -----Original Message-----
> > > From: [EMAIL PROTECTED] 
> > > [mailto:[EMAIL PROTECTED] On 
> > > Behalf Of Andrew Bligh
> > > Sent: Wednesday, April 16, 2008 4:48 PM
> > > To: [email protected]
> > > Subject: [iText-questions] Image extracted from PDF file and 
> > > scaled is slightly bigger than expected.
> > > 
> > > Hi,
> > > 
> > > I am drawing a 'container' as a rectangle with line thickness 
> > > 0.1f wthin a pdf and then scaling an image to fit the 
> > > container exactly (origian bottom left corner). If the image 
> > > source is a jpeg or gif the fit is exact i.e. you can 
> > > slightly see the contianer lines all the way around the 
> > > image. If the image source is a PDf file and I extract the 
> > > image from the first page like so:
> > > 
> > > PdfReader reader = new PdfReader( 
> > > location ) ; 
> > > PdfImportedPage page = 
> > > writer.getImportedPage( reader, 1 ) ;
> > > image = Image.getInstance( page ) ;
> > > 
> > > then the image slightly overlaps the container to the right 
> > > and top. The bottom and left sides of the container are ok 
> > > but the image seems to be slightly taller and wider than 
> > > expected. We are only talking about 0.2 of a mm here but this 
> > > accuracy is vital to my application.
> > > 
> > > Is this a known issue or am I doing something wrong?
> > > 
> > > Thanks in advance,
> > > 
> > > Andrew


Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter 
informação confidencial ou legalmente protegida. A incorrecta transmissão desta 
mensagem não significa a perca de confidencialidade. Se esta mensagem for 
recebida por engano, por favor envie-a de volta para o remetente e apague-a do 
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de 
usar, revelar ou distribuir qualquer parte desta mensagem. 

Disclaimer:
This message is destined exclusively to the intended receiver. It may contain 
confidential or legally protected information. The incorrect transmission of 
this message does not mean the loss of its confidentiality. If this message is 
received by mistake, please send it back to the sender and delete it from your 
system immediately. It is forbidden to any person who is not the intended 
receiver to use, distribute or copy any part of this message.


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Do you like iText?
Buy the iText book: http://www.1t3xt.com/docs/book.php
Or leave a tip: https://tipit.to/itexttipjar

Reply via email to