> -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of Ignacio Ruiz-de-Conejo > Sent: Wednesday, July 11, 2007 4:55 PM > To: [email protected] > Subject: [iText-questions] Modifying image contrast and > saturation inside aPDF > > Hi all! > > Given a PDF with gray images, I have found that an easy way > to adjust its colors is to modify its Image objects. The > dictionary associated with this type of object contains a > key, /ColorSpace whose value is usually assigned to > "/DeviceGray". What I have done (manually) has been to > substitute this value with the colorspace > "[ /CalGray << /WhitePoint [0.9505 1.0000 1.0890] /Gamma 2.9 >>]" > and varying the value of the gamma parameter I can tweak the > image to the desired density. Deleting the cross-reference > table(s) and "startxref" is enough for the PDF to work > properly, with better looking images. Acrobat will rebuild > those tables the first time it opens the document. > > Now, with iText: > I am trying to use iText low level functions to apply the > change described above (even though I´ve read iText is better > suited for generation rather than modification of PDF files). > So far, I am able to traverse the cross-reference table and > locate all the gray Image objects contained in the PDF. > > reader = new PdfReader(args[0]); > for (int i = 0; i < reader.XrefSize; i++) > { > PdfObject pdfobj = reader.GetPdfObject(i); > if (pdfobj != null) > { > if (pdfobj.IsStream()) { > PdfStream pdfdict = (PdfStream) pdfobj; > PdfObject pdfsubtype = pdfdict.Get(PdfName.SUBTYPE); > if (pdfsubtype == null) { > continue; > } > if (!pdfsubtype.ToString().Equals( > PdfName.IMAGE.ToString())) { > continue; > } > PdfObject pdfcolorspace = pdfdict.Get(PdfName.COLORSPACE); > if > (pdfcolorspace.ToString().Equals(PdfName.DEVICEGRAY.ToString ())) { > > // Act here! > // PdfArray GrayObj; > // ... > // pdfdict.Put(PdfName.COLORSPACE, GrayObj); > > } > } > } > > > My next step will be building the GrayObj object, that > defines the new color space; it does not look difficult to > do. But what I am not sure how to do is the writer part of > the document. I mean, how to copy or stamp the new file so > that the original file, obtained through the reader, is > maintained, except for the Image objects, that I want to > modify as explained above. I am assuming this is feasible > with iTextSharp, isn´t it? >
PdfStamper stp = new PdfStamper(reader, new FileStream(...)); stp.Close(); > Any help? > Thanks, > Ignacio > > > PS: > I have not seen in iTextSharp the tools that exist in the > Java version of iText. I´m particulary interested in the PDF > Analyser / Treeviewer. Hints? > You won't see those tools in iTextSharp unless someone volunteers to write one. Paulo 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 DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ 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/
