Hey Mark,

great point, sorry i missed. Yes it's a heavily multi threaded environement.

Paulo said i should check out the code in SVN? I will ask him about the
respository url to get the code from SVN? i am thankful for any more
suggestions you have.


Thanks
Subrah




Mark Storer-2 wrote:
> 
> That file is horrifically mangled all right.  The cross reference (xref)
> table at the end doesn't list all the objects in the file, not by a long
> shot.
> 
> The root object, 69, is among those AWOL from the xref... leading to the
> error you're getting.
> 
> WHY is it missing?  I'm not sure.  The xref looks like one you'd find as a
> result of a stamper in "append" mode, tacked onto the original PDF, but
> the rest of the file looks like it should have a single xref.  The trailer
> makes no mention of a previous xref or xref stream.
> 
> You're not explicitly setting the stamper to use append mode, so it will
> only go into that mode, IIRC, if forced by a signature.  (And I don't see
> anything in the source that backs that up either, so now I'm Really
> Confused)
> 
> Is this a single threaded environment?  (he asked, grasping at straws)
> 
> --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 12:12 PM
>> To: itext-questions@lists.sourceforge.net
>> Subject: Re: [iText-questions] Root Object is invalid or missing after
>> PDF is manipulated with iTextSharp
>> 
>> 
>> 
>> Attached is the corrupt file.
>>  if i try to read the corrupted file using pdfreader i get 
>> the error message
>> saying "start ref not found". But the issue is that problem is not
>> consistant. I am able to water mark the same original file 
>> 2nd time using
>> the same code. So it's like randomly some file is not fully written.
>> 
>> i am gussing this is because the pdfstamper is closing the 
>> memory stream
>> earlier than it should for some reason. However what i want 
>> to confirm is
>> that my understanding that the probelm is infact the memory 
>> stream is right
>> or not?. Because i have implmented alternative technique to 
>> compltely avoid
>> memory stream and pdf stamper but use pdfwriter and file 
>> stream which seem
>> to have fixed the issue in dev. But still need to get 
>> response from a heavy
>> testing team. Any light thrwon on this subject will be of 
>> great help to me.
>> 
>> Thanks
>> Subrah
>> 
>> 
>> 
>> Mark Storer-2 wrote:
>> > 
>> > 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/
>> > 
>> > 
>> http://old.nabble.com/file/p26378678/2461223_B.pdf 2461223_B.pdf 
>> -- 
>> View this message in context: 
>> http://old.nabble.com/Root-Object-is-invalid-or-missing-after-
> PDF-is-manipulated-with-iTextSharp-tp26305073p26378678.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/
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Root-Object-is-invalid-or-missing-after-PDF-is-manipulated-with-iTextSharp-tp26305073p26392980.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/

Reply via email to