PDFiumCore icon indicating copy to clipboard operation
PDFiumCore copied to clipboard

FS_POINTF_ is a struct in Pdfium but a class in this library

Open torfluor opened this issue 1 year ago • 2 comments

I'm trying to add ink annotations using FPDFAnnotAddInkStroke, and it takes a pointer to an array of FS_POINTF_. When sending in a C# array of points like this fpdf_annot.FPDFAnnotAddInkStroke(annot, fs_points[0], (ulong)fs_points.Length); I get strange results, leading me to think that there is an issue in the conversion between the class objects and the struct. I think if would be better if FS_POINTF_ was a struct instead.

torfluor avatar Oct 10 '24 09:10 torfluor

After reading up on helper-defines in CppSharp I added CS_VALUE_TYPE to the FS_POINTF struct in fpdfview.h. I also had to define CS_VALUE_TYPE, so the code ended up like this:

#define CS_VALUE_TYPE
// 2D Point. Coordinate system agnostic.
typedef struct CS_VALUE_TYPE FS_POINTF_ {
  float x;
  float y;
} * FS_LPPOINTF, FS_POINTF;

FS_POINTF_ is then generated as a struct in the C# code. This hard coding works, but I'm not sure how to best add this to the generator program. Please advice on how to add this change and I'll create a pull request

torfluor avatar Oct 11 '24 13:10 torfluor