Page 1 of 1

Invalid argument using PXCp_ET_GetElement

Posted: Fri Jan 15, 2016 4:07 pm
by Max SAG
Hi,

I'm using the PDF-Tools SDK and I encounter an issue with the XCPro40 library (4.0.311.0) in a WPF project (C#/XAML) in Visual Studio 2012.

Using the "ExtractTextToOtherPDFDocument" sample of the PXCp_ET_AnalyzePageContent documentation page, the PXCp_ET_GetElement method always returns the code -2113404927 ("Invalid argument").

I first call PXCp_ET_Prepare, then PXCp_ET_AnalyzePageContent, then the PXCp_ET_GetElementCount (which returns a positive number of elements) and then PXCp_ET_GetElement:

Code: Select all

XCPro40.PXP_TextElement element;
var result = XCPro40.PXCp_ET_GetElement(_pdfId, i, out element, 1);

Code: Select all

[DllImport("xcpro40")]
public static extern int PXCp_ET_GetElement(int pDocument, int index, out PXP_TextElement pElement, int flags);

Code: Select all

[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct PXP_TextElement
{
    public int cbSize;
    public int mask;
    public short[] Characters;
    public double[] Offsets;
    public int Count;
    public int FontIndex;
    public double FontSize;
    public PXC_Matrix Matrix;
    public double CharSpace;
    public double WordSpace;
    public double Th;
    public double Leading;
    public double Rise;
    public int FillColor;
    public int StrokeColor;
    public PXC_TextRenderingMode RenderingMode;
};
The _pdfId is the right one, i is always inferior to the GetElementCount, I tried 0, 1, 2 and 4 for the flag parameter. The last thing which could be problematic is my declaration of PXP_TextElement.
Am I missing something?

EDIT: I've just found that PXCp_ET_AnalyzePageContent returns the warning code 1108289444 ("End of data while parsing") for all the pdf files I've tried, maybe it's not a good thing.

Regards,

Max

Re: Invalid argument using PXCp_ET_GetElement

Posted: Thu Jan 21, 2016 9:01 am
by Sasha - Tracker Dev Team
Hello Max SAG,

We are updating the sample for C# and will post it for you when we'll finish.

Cheers,
Alex

Re: Invalid argument using PXCp_ET_GetElement

Posted: Thu Jan 21, 2016 11:19 am
by Max SAG
Hi,

Ok, thanks for your time, I'll wait for your sample.

Regards,

Max

Re: Invalid argument using PXCp_ET_GetElement

Posted: Tue Jan 26, 2016 3:43 pm
by Sasha - Tracker Dev Team
Hello Max SAG,

We updated the sample. Here you go :wink:

Re: Invalid argument using PXCp_ET_GetElement

Posted: Wed Jan 27, 2016 3:21 pm
by Max SAG
Hi,

Awesome, works like a charm, thanks a lot.
It's very similar to the C++ example after all...
My PXCp_ET_GetElement and PXP_TextElement declarations were wrong, my bad.

Regards,

Max

Re: Invalid argument using PXCp_ET_GetElement

Posted: Wed Jan 27, 2016 4:06 pm
by Tracker Supp-Stefan
Glad to hear it's working properly for you Max!

Cheers,
Stefan