A: Most of the folks on the list lean toward Java. B: If no one knows the answer, no one answers.
Perhaps you could post one of your corrupted PDFs? --Mark Storer Senior Software Engineer Cardiff.com #include <disclaimer> typedef std::Disclaimer<Cardiff> DisCard; > -----Original Message----- > From: subrah [mailto:subnibh...@gmail.com] > Sent: Monday, November 16, 2009 8:50 AM > To: itext-questions@lists.sourceforge.net > Subject: Re: [iText-questions] Root Object is invalid or missing after > PDF is manipulated with iTextSharp > > > > Hi All, > > I am wondering why nobody is interested in responding to my > question? I seem > to have found a fix but just wanted to confirm with experts > on this forum. > So any help is greatly appreciated. > > Thanks > Subrah > > > > subrah wrote: > > > > Hi > > Sorry resending this post as i was not registered user earlier. > > > > i am using latest iTextSharp library to edit the pdf > documents to put the > > water marking digitallly (hidden). So when i researched i > found that i can > > add a annotation to the pdf document and then set the flags to > > annotation.Flags = PdfAnnotation.FLAGS_NOVIEW | > > PdfAnnotation.FLAGS_INVISIBLE | PdfAnnotation.FLAGS_HIDDEN; > to make it > > invisible. > > > > so this is working fine as expected 90% of the time. > Remaning 10 % of the > > time i get an error when i open the document after adding > the annotation > > it says "Root object is invalid or missing" > > > > so looks like it corrupted the file trying to add the > annoation. do you > > have any suggestion? i can share the code i am using to add > the annotation > > if that helps. > > > > Full code > > public static byte[] EditPdf(string sourceFile, string > visibleWaterMark, > > string digitalWaterMark) > > { > > PdfReader reader = new PdfReader(sourceFile); > > using (MemoryStream memoryStream = new MemoryStream()) > > { > > PdfStamper pdfStamper = new PdfStamper(reader, > > memoryStream); > > // process every page in the pdf file > > for (int i = 1; i <= reader.NumberOfPages; i++) > > { > > Rectangle pageSize = > > reader.GetPageSizeWithRotation(i); > > PdfContentByte pdfPageContents = > > pdfStamper.GetUnderContent(i); > > PdfAnnotation annotation = > > PdfAnnotation.CreateText(pdfStamper.Writer, new > Rectangle(200f, 400f, > > 300f, 500f), digitalWaterMark, > > "Street Events > Digital Watermark", > > false, "Key"); > > //digital water marking > > annotation.Flags = PdfAnnotation.FLAGS_NOVIEW | > > PdfAnnotation.FLAGS_INVISIBLE | PdfAnnotation.FLAGS_HIDDEN; > > pdfStamper.AddAnnotation(annotation, i); > > pdfPageContents.BeginText(); > > BaseFont baseFont = > > BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, > Encoding.ASCII.EncodingName, > > BaseFont.NOT_EMBEDDED); > > pdfPageContents.SetFontAndSize(baseFont, 10); > > pdfPageContents.SetRGBColorFill(225, 224, 223); > > // visible water marking > > > > pdfPageContents.ShowTextAligned(PdfContentByte.ALIGN_RIGHT, > > visibleWaterMark, > > > pageSize.Width - 50, > > > pageSize.Height - 15, > > 0); > > pdfPageContents.EndText(); > > pdfStamper.FormFlattening = true; > > > > } > > > > pdfStamper.Close(); > > return memoryStream.ToArray(); > > } > > > > > > > > public static void SaveFile(string fileHandle, byte[] fileBytes) > > { > > using(FileStream fs = new FileStream(fileHandle, > > FileMode.Create)) > > { > > fs.Write(fileBytes, 0, fileBytes.Length); > > fs.Flush(); > > fs.Close(); > > } > > > > } > > > > //call > > FileInfo pdfFileInfo = new FileInfo(newFilePath); > > byte[] fileBytes = PdfWaterMarker.EditPdf(pdfFileInfo, > > string.Format("Client Id: {0}", clientSite.ClientId)); > > PdfWaterMarker.SaveFile(newFilePath, fileBytes); > > > > please let me know > > Thanks > > Subrah > > > > > > -- > View this message in context: > http://old.nabble.com/Root-Object-is-invalid-or-missing-after- PDF-is-manipulated-with-iTextSharp-tp26305073p26375297.html Sent from the iText - General mailing list archive at Nabble.com. ------------------------------------------------------------------------------ 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/ ------------------------------------------------------------------------------ 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/