Hi All,

I'm looking into adding stamp annotations to my pdf documents.  The
source for the stamps will be a bitmap file.  I've read the relevant
section of the spec, and below is the code I've come up with.  The pdf
that comes out does have an annotation in the specified location - you
can tell because the cursor changes - but visually, there's nothing to
see.  I've never used a PdfAppearance before, so I may be doing
something wrong with that.
Does anyone know what I'm missing?

Thanks,
Brian

--------------------------------------------

private static void StampTest(Stream outStream)
{
    Document document = new Document();
    PdfWriter writer = PdfWriter.GetInstance(document, outStream);
    document.Open();
    document.Add(new Paragraph("This is a simple PDF"));
    iTextSharp.text.pdf.PdfAnnotation pdfStamp = MakeStamp(writer, 300, 700);
    writer.AddAnnotation(pdfStamp);
    document.Close();
}

private static iTextSharp.text.pdf.PdfAnnotation MakeStamp(PdfWriter
writer, int xpos, int ypos)
{
    Rectangle location = new Rectangle(xpos, ypos);
    iTextSharp.text.pdf.PdfAnnotation pdfStamp =
iTextSharp.text.pdf.PdfAnnotation.CreateStamp(writer, location, null,
Guid.NewGuid().ToString());
    Image stampImg = Image.GetInstance(@"d:\temp\stamp.bmp");
    stampImg.SetAbsolutePosition(xpos, ypos);
    PdfAppearance app =
writer.DirectContent.CreateAppearance(stampImg.Width,
stampImg.Height);
    app.AddImage(stampImg);
    pdfStamp.SetAppearance(PdfName.N, app);
    return pdfStamp;
}

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to