Thank you :) I didn't expect that it will be so soon :) Karol
Paulo Soares wrote: > It's fixed in the SVN. > > Paulo > > >> -----Original Message----- >> From: [EMAIL PROTECTED] >> [mailto:[EMAIL PROTECTED] On >> Behalf Of Paulo Soares >> Sent: Tuesday, September 18, 2007 5:53 PM >> To: Post all your questions about iText here >> Subject: Re: [iText-questions] RandomAccessFileOrArray and >> PdfStamper problem >> >> It's a bug. It will be fixed soon. >> >> Paulo >> >> >>> -----Original Message----- >>> From: [EMAIL PROTECTED] >>> [mailto:[EMAIL PROTECTED] On >>> Behalf Of Karol Bryd >>> Sent: Tuesday, September 18, 2007 1:13 PM >>> To: [email protected] >>> Subject: [iText-questions] RandomAccessFileOrArray and >>> PdfStamper problem >>> >>> Hello All >>> >>> I am wondering why following code doesn't work when I use >>> RandomAccessFileOrArray as an input and works when I create >>> >> PdfReader >> >>> passing a filename (String) directly. >>> >>> Difference is that the PDF created using >>> RandomAccessFileOrArray does not >>> contain watermarks. >>> >>> Any ideas? >>> >>> Best regards >>> Karol >>> >>> import java.io.File; >>> import java.io.FileOutputStream; >>> >>> import com.lowagie.text.Image; >>> import com.lowagie.text.pdf.PdfContentByte; >>> import com.lowagie.text.pdf.PdfGState; >>> import com.lowagie.text.pdf.PdfReader; >>> import com.lowagie.text.pdf.PdfStamper; >>> import com.lowagie.text.pdf.RandomAccessFileOrArray; >>> >>> >>> public class Test { >>> >>> private static void addWatermark(PdfReader reader, >>> PdfContentByte content, >>> Image watermark, int m_pageCurrent) throws Exception { >>> float pageWidth = >>> reader.getPageSizeWithRotation(m_pageCurrent).width(); >>> float pageHeight = >>> reader.getPageSizeWithRotation(m_pageCurrent).height(); >>> float watermarkWidth = watermark.width(); >>> float watermarkHeight = watermark.height(); >>> float x = (pageWidth - watermarkWidth) / 2; >>> float y = (pageHeight - watermarkHeight) / 2; >>> content.addImage(watermark, watermarkWidth, 0, >>> 0, watermarkHeight, x, y); >>> } >>> >>> public static void main(String[] args) throws Exception { >>> // PdfReader tmpReader = new PdfReader("c:\\file.pdf"); >>> >>> RandomAccessFileOrArray randomFile = new >>> RandomAccessFileOrArray("c:\\file.pdf"); >>> PdfReader tmpReader = new PdfReader(randomFile,null); >>> >>> File fileResult = new File("c:\\out.pdf"); >>> fileResult.createNewFile(); >>> PdfStamper stamper = new PdfStamper(tmpReader, new >>> FileOutputStream(fileResult)); >>> >>> Image imageWatermark = null; >>> File fileWatermark = new File("c:\\watermark.jpg"); >>> PdfGState gs = new PdfGState(); >>> gs.setFillOpacity(0.5f); >>> imageWatermark = >>> >> Image.getInstance(fileWatermark.toString()); >> >>> for (int m_pageCurrent = 1; m_pageCurrent <= >>> tmpReader.getNumberOfPages(); m_pageCurrent++) { >>> PdfContentByte overContent = >>> stamper.getOverContent(m_pageCurrent); >>> overContent.saveState(); >>> overContent.setGState(gs); >>> addWatermark(tmpReader, overContent, imageWatermark, >>> m_pageCurrent); >>> overContent.restoreState(); >>> } >>> stamper.close(); >>> } >>> } >>> > > > 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: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > ------------------------------------------------------------------------ > > _______________________________________________ > iText-questions mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/itext-questions > Buy the iText book: http://itext.ugent.be/itext-in-action/ > ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/
