iTextSharp pdfWriter is overwriting content of existing pdf - NEED HELP

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

iTextSharp pdfWriter is overwriting content of existing pdf - NEED HELP

LydiaMV
Hello to everybody:

I'm new with ITextSharp and I urgently need some help!

The task is quite simple: I have to draw some circles to an already existing pdf-file! That doas work - but the whole content of the pdf is gone with this and I just wanne add some new content, not deleting the old one! So, the old content is overwritten everytime!

Here's my code (I'm using MS C#Express Version 2010):

        PdfContentByte pdfContentByte           = null;
        Document anyDocument                     = new Document();
        private string sz_Global_PDFFileName    = Application.StartupPath + "\\HelloWorld.pdf";
        public Klebeplan()
        {
            InitializeComponent();
            try
            {
                PdfWriter pdfWriter = PdfWriter.GetInstance(anyDocument, new FileStream(sz_Global_PDFFileName,   FileMode.Open));
                anyDocument.Open();
                pdfContentByte = pdfWriter.DirectContent;
                pdfContentByte.SetLineDash(3, 3, 0);
                pdfContentByte.SetRGBColorStrokeF(0f, 240f, 0f);
                pdfContentByte.Circle(600f, 600f, 50f);
                pdfContentByte.Stroke();
                anyDocument.Close();
            }

What am I doing wring! Can somebody help?
Thank you - any held is appreciated!