Zach
Zach

Reputation: 11

iTextSharp - PdfContentByte causing error on page

So I'm using PdfContentByte to draw a simple line in an itextsharp pdf document, but when using it i get an error that says "An error exists on this page. Acrobat may not display the page correctly". Does anyone have a solution to this? The error usually pops up after I have selected to print the document.

Here is my code:

`cb.BeginText();
                    cb.SetLineWidth(1.0f);
                    cb.MoveTo(37.0f, doc.PageSize.Height - 105.0f);
                    cb.LineTo(doc.PageSize.Width - 37.0f, doc.PageSize.Height - 105.0f);
                    cb.Stroke();
                    cb.EndText();`

thanks in advance

Upvotes: 1

Views: 1991

Answers (2)

Mark Storer
Mark Storer

Reputation: 15870

You may not have anything but text operators between a BeginText() and EndText() pair. Move your line art code outside them.

Upvotes: 1

Roja Buck
Roja Buck

Reputation: 2354

There is a fix on this site:

http://sajeevkumar.com/blog/?p=155

It is more specific to java but I believe the api's are very similar. My other thoughts are to do with there being a page object, sometimes pdf frameworks produce mangled output unless you explicitly create a page object within said pdf and then draw onto the page...

Upvotes: 0

Related Questions