We are using Acrobat plug-in to save PDF from our application. For one particular scenario we are trying to save a non-english filename (like Chinese, Japanese, Korean, etc) to PDF. We are using AFExecuteThisScript to call the saveAs method to actually save the PDF file.
As per documentation we found here:
ASBool AFExecuteThisScript (PDDoc pdd, const char * cScript, char ** pRetValue)
pdd The PDDoc in which the script is to be executed.
cScript A string containing the text of the script to be executed. If Unicode, the string must begin with
0xFEFF and end with 2 null bytes. If this is not the case, it is assumed to be in the application's language
encoding, as returned by AVAppGetLanguageEncoding.
pRetValue To get a return value from the execution of the script, pass a non-NULL value for this
parameter. If on return - pRetVal is non-NULL, the caller should dispose of the string by calling ASFree. If
present, the value will be in host encoding. NOTE: The script sets this value by assigning it to event.value.
We tried passing the UTF-8 string from our application and have added to start with 0xFEFF and end with 2 null bytes, but still we are getting the ANSI name PDF filename.
It would be great if an example can be provided for the usage of AFExecuteThisScript() method for non-english characters to be passed to this function.
It needs to be platform Unicode/WCHAR. That is a form of UTF-16 or UCS2. Not UTF-8. This is standard Unicode programming EXCEPT for adding the extra BOM (FEFF), so no Acrobat specific example is likely.
Tip: in Windows you can use MultiByteToWideChar. MultiByteToWideChar function | Microsoft Docs
Tip 2: you will probably have a WCHAR array with the Unicode text, and must typecast it for the AFExecuteThisScript method.
Thanks for providing quick tips. Will try it out and will share the findings.
Did you have any luck getting this to work. I'm facing the same issue now.