Welcome Guest Search | Active Topics | Sign In | Register

Problem using EO::Pdf::Drawing::PdfMatrix object in C++/CLI Options
KAR
Posted: Monday, November 18, 2013 6:21:58 PM
Rank: Newbie
Groups: Member

Joined: 11/18/2013
Posts: 4
I am attempting to convert the following function for use in C++. It works great in C#. I am using Visual Studio 2008.

bool AddImagePage(PdfDocument^ doc, Image^ imageIn)
{
bool bOK = true;

if (bOK)
{
//Add a new page
PdfPage^ page = doc->Pages->Add();

//Create a new text layer object
PdfImage^ image = gcnew PdfImage(imageIn);

PdfImageContent^ content = gcnew PdfImageContent();
content->Image = image;

PdfRectangle^ rect = page->CropBox;

// position the image

content->GfxMatrix->Translate(0, rect->Height - (72 * image->Image->Height / image->Image->VerticalResolution));

//Add the text layer to the page
page->Contents->Add(content);
}

return bOK;
}


Everything compiles fine until I attempt to use the translate function on content->GfxMatrix.

With further testing I discovered that any access in C++ to an object derived from EO::Pdf::Drawing::PdfMatrix (like GfxMatrix) gives an error at compile time as follows:

1>.\PDFTestCPP.cpp(38) : error C2365: 'EO::Pdf::Drawing::PdfMatrix::b' : redefinition; previous definition was 'property'
1> .\PDFTestCPP.cpp(38) : see declaration of 'EO::Pdf::Drawing::PdfMatrix::b'
1> This diagnostic occurred while importing type 'EO::Pdf::Drawing::PdfMatrix ' from assembly 'EO.Pdf, Version=5.0.50.2, Culture=neutral, PublicKeyToken=e92353a6bf73fffc'.

This may or may not be because there are a couple of different definitions of member b that are seen as similar by the C++ compiler:

a protected member:
protected System.Void b(System.Single[] A_0)
Member of EO.Pdf.Drawing.PdfFloatArray

and

a public property:
public System.Single b { get; set; }
Member of EO.Pdf.Drawing.PdfMatrix

which derives from PdfFloatArray

I am not sure what the issue really is, but I would like to get this working in C++ without COM. I am open to compiler option setting changes and work-arounds. I haven't actually tried the function shown above in C++, so it may have other issues that I haven't caught yet.

Thanks
eo_support
Posted: Monday, November 18, 2013 7:37:11 PM
Rank: Administration
Groups: Administration

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

It will probably be better for you to write a small .NET dll that wraps around the feature you want and then call that .DLL with C++/CLI instead. The reason that you run into problems when calling our DLL directly is probably because of obfuscation. Because of obfuscation, our objects have property/members with the same name but different types. For example:

class X
{
public int a;
public string a;
}

This is allowed on CLR level but is not allowed on any higher level language. That's why when you try to call them in C++ you get "redefinition" problem. To avoid this problem, you can write a small .NET dll around our class with a native .NET language such as C#, then call your C# object from your C++/CLI code. Since your .NET dll is not obfuscated, you should not run into this problem.

Thanks!
KAR
Posted: Tuesday, November 19, 2013 3:12:58 PM
Rank: Newbie
Groups: Member

Joined: 11/18/2013
Posts: 4
I can do that!

Thanks


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.