A question on embedding an image in PDF.

Q: I'm currently using PDFnet SDK and I have to say its extremely
robust and easy to use.

I'm encountering a problem when embedding a .png image into an
existing PDF. Although its embedding the image correctly it is
duplicating the page. The PDF is only one page in length but ends up
as two identical pages.

Here is the code:

PDFNet.Initialize();
            PDFDoc doc = new PDFDoc(DIRtextBox.Text + "\\" +
"RBS_1.pdf");
            ElementBuilder bld = new ElementBuilder();
            ElementWriter writer = new ElementWriter();
            try
            {
                Page page = doc.GetPage(1);
                writer.Begin(page);
                string input_path = DIRtextBox.Text + "\\";

                Image img = Image.Create(doc, input_path +
"Picture1.png");
                Element element = bld.CreateImage(img, new
Matrix2D(img.GetImageWidth() / 4, 0, 0, img.GetImageHeight() / 4, 0,
img.GetImageHeight() / 4));
                writer.WritePlacedElement(element);

                writer.End(); // Finish writing to the page
                doc.PagePushBack(page);

                doc.Save(input_path + "addimage.pdf",
SDFDoc.SaveOptions.e_linearized);
            }
            finally
            {
                bld.Dispose();
                writer.Dispose();
                doc.Close();
            }
        }
------
A: The problem is that you are replicating the page using
doc.PagePushBack(page);
To remove the extra page simply comment out this line.