Welcome Guest Search | Active Topics | Sign In | Register

PdfPage add content in version Options
g3orge
Posted: Monday, October 21, 2013 8:05:43 AM
Rank: Member
Groups: Member

Joined: 8/2/2012
Posts: 24
Hi,

I have been using EO PDF version 5.0.32.2 and older versions, and after updating to version 5.0.48.2, I've got an exception in a piece of code that always worked.

Code: C#
var page = new PdfPage();
                var imagePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Content\app\images\pdf-cover.jpg");
                var image = new PdfImage(imagePath);
                var content = new PdfImageContent(image);
                page.Contents.Add(content);


Exception
Message Object reference not set to an instance of an object.

StackTrace
at EO.Pdf.Contents.PdfContentContainer.h()
at EO.Pdf.Internal.d2.a(List`1 A_0)
at EO.Pdf.Internal.d2.b()
at EO.Pdf.Contents.PdfContentContainer.get_Contents()

TargetSite EO.Pdf.Internal.hi h()

The exception is raised in the last line
Code: C#
page.Contents.Add(content);
eo_support
Posted: Monday, October 21, 2013 9:47:29 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
Hi,

Please make sure PdfPage belongs to a PdfDocument first before you add any contents into it. For example, instead of:

Code: C#
var page = new PdfPage();


Try:

Code: C#
var doc = new PdfDocument();
var page = doc.Pages.Add();


Thanks!
g3orge
Posted: Monday, October 21, 2013 11:25:49 AM
Rank: Member
Groups: Member

Joined: 8/2/2012
Posts: 24
Hi,

That solved my problem.

Thanks,
George


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.