Interop syntax for array of Strings

I am using Embarcadero C++ Builder using interop. I am trying to call Aspose.Pdf.Kit.PdfFileEditor method Concatenate, using the String array version of the method:

public bool Concatenate(
string[] inputFiles,
string outputFile
);

I was able to get the non-string array version of the method working as follows:

AnsiString filename0 = "c:\\test\\file1.pdf";
AnsiString filename1 = "c:\\test\\file2.pdf";
AnsiString filenameout = "c:\\test\\fileAsposeOutConcat.pdf";;

Variant vPdfFileEditor;

PdfFileEditor = Variant::CreateObject("Aspose.Pdf.Kit.PdfFileEditor");

Variant vRet = vPdfFileEditor.OleFunction("Concatenate", filename1.c_str(), filename2.c_str(), filenameout.c_str());


I'm just not sure of the syntax to use to for the string[] version. Can you give me some guidance on that?

Thanks!

Hi Mary,

I’m afraid, we never used the OleFunction with string[] parameter before; we’ll look into this in detail at our end and update you accordingly.

Moreover, if you are a registered member or a customer of Embarcadero C++ Builder, you may post the query regarding the syntax at http://support.embarcadero.com/.

We’re sorry for the inconvenience.
Regards,

Hi,

Have you had any luck researching this? I posted to the Embarcadero forum. They suggested this, but it did not work:

https://forums.embarcadero.com/thread.jspa?threadID=48690&tstart=0

In case you can’t get to the link, here’s what they said:

Try using VarArrayCreate() with the varOleStr type, and then use
VarArrayPut() to put your string values into the array.

I tried that and I got an EOleSysError exception with message “No such interface supported”.

Any help would be most appreciated.

Thanks,

Mary

Hi Mary,

Please share whether this error is occurring while calling the Concatenate method or somewhere else. Also, please provide complete modified code snippet.

We’re sorry for the inconvenience.
Regards,

The error is in the Concatenate method. I tried several things. I am attaching a small C++ Builder test project. The project has a form with several buttons that test several scenarios, none of which work. Good luck!

Hi Mary,

Thank you very much for sharing the sample project with us. We’ll investigate the issue in detail at our end and you’ll be updated with the results accordingly. Please spare us some time, so we could properly understand the issue.

We’re sorry for the inconvenience.
Regards,

OK.

FYI - for a temporary workaround, I am just calling your function that concatenates 2 files in a loop. So thru each iteration of the loop I append one new file in the list to the file from the previous iterationg, creating temporary files as I go.

Still, I would like to know how to call this so I will be able to call some of your other API calls.

Thanks!

Hi Mary,

We’re looking into this requirement at our end and you’ll be updated with the results accordingly.

Regards,

Hi Mary,

I have been working with this issue and modified the code as suggested; the code is shown below:

First, the code which creates the array of string variables:


AnsiString filename0 = “c:\test\file1.pdf”;

AnsiString filename1 = “c:\test\file2.pdf”;

AnsiString filename2 = “c:\test\file3.pdf”;

AnsiString filenameout = “c:\test\fileAsposeOutConcatenateFilesCharArray3.pdf”;;


Variant array;

int bounds[2] = {0, 3};

array = VarArrayCreate(bounds, 1, varOleStr);


int i = 0;

VarArrayPut(array,filename0, &i, 0);

i = 1;

VarArrayPut(array,filename1, &i, 0);

i = 2;

VarArrayPut(array,filename2, &i, 0);


sesPdf.ConcatenateFilesTStringList2(array, filenameout);

Then, the method to call the Concatenate method in turn:


bool TSESPdf::ConcatenateFilesTStringList2(Variant array, AnsiString filenameout)

{

bool ret = false;


Variant vRet = m_vPdfFileEditor.OleFunction(“Concatenate”, array, filenameout.c_str());


return ret;

}

However, I'm getting the following exception when I execute the above code:
Project raised exception class EOleSysError with message 'No such interface supported'.

It looks like the syntax is not correct for the string array parameter. As you know, Concatenate method takes string[] as first parameter. I have created Variant "array" as string array, but it is not correct. Could you please share your thoughts or confirm from Embarcadero about the syntax for the OleFunction where we have to pass a parameter like string[]?

The code works fine when we pass individual file names as string. So, I believe once we figure out the correct syntax for the other overload Concatenate(string[] , string), it'll be working fine as well.

We're sorry for the inconvenience and looking forward to help you out.
Regards,

I have posted your question to the Embarcadero forum:

https://forums.embarcadero.com/thread.jspa?messageID=324550#324550

Hi Mary,

Please do let me know when you receive a response regarding the syntax, so I could further look into this issue in detail.

We’re sorry for the inconvenience and looking forward to help you out.
Regards,

They responded in the forum:

https://forums.embarcadero.com/thread.jspa?messageID=324550#324550

This is the text of the response:

“They told you the same thing I said - to use VarArrayCreate(varOleStr).
That is the correct way to create a COM/Automation-compatible array of
strings. The error you are seeing has nothing to do with the array itself.
Something else is failing inside of OleFunction() before the array is used.
My guess is that your m_vPdfFileEditor Variant has not been initialized
correctly yet before calling ConcatenateFilesTStringList2().”

I believe that m_vPdfFileEditor is initialized correctly, so it may have to do with the way I am using VarArrayCreate. If you could come up with a sample code snippet for me that does work properly I am sure I could incorporate it into my code.

Thanks!

Hi Mary,

I have again tried to test the sample with different scenarios, but couldn’t execute the Concatenate(string[], string) method successfully. I’m afraid, we’ll have to investigate this issue in detail at our end; I have logged this issue as PDFKITNET-24857 in our issue tracking system. Please spare us some time and we’ll update you with the results accordingly.

We’re sorry for the inconvenience.
Regards,