Pointer pointerValue = new Memory(textSizeValue);
PointerByReference outputText = new PointerByReference(pointerValue);
LOGGER.debug("textSizeValue:{}", textSizeValue);
returnCode = conversionInterface.fblGetPageText(pdfPage, outputText);
String pageText = outputText.getPointer().getWideString(0);
long nativeValue = Pointer.nativeValue(pointerValue);
Native.free(nativeValue);String pageText = outputText.getValue().getWideString(0);
public String getPageText(Pointer pdfPage)
{
String pageText = null;
IntByReference textSizePtr = new IntByReference();
Pointer outputValuePtr = null;
int returnCode = conversionInterface.fblGetPageText(pdfPage, outputValuePtr, textSizePtr);
int textSizeValue = textSizePtr.getValue();
outputValuePtr = new Memory(textSizeValue);
returnCode = conversionInterface.fblGetPageText(pdfPage, outputValuePtr, textSizePtr);
pageText = outputValuePtr.getWideString(0);
outputValuePtr = null;
LOGGER.debug("Exiting getPageText - pageText: {}", pageText);
return pageText;
}Just wondering am I correctly creating the pointer in my code?
On Tuesday, September 12, 2017 at 10:51:25 AM UTC+1, Damien Gallagher wrote:
I had a chat with the developer of the library and he has updated the header fileHe informs me that it is up to me to manage the memoryHere is a minimal sample of the codepublic String getPageText(Pointer pdfPage)
{
String pageText = null;
IntByReference textSizePtr = new IntByReference();
Pointer outputValuePtr = null;
int returnCode = conversionInterface.fblGetPageText(pdfPage, outputValuePtr, textSizePtr);
int textSizeValue = textSizePtr.getValue();
outputValuePtr = new Memory(textSizeValue);
returnCode = conversionInterface.fblGetPageText(pdfPage, outputValuePtr, textSizePtr);
pageText = outputValuePtr.getWideString(0);
outputValuePtr = null;
LOGGER.debug("Exiting getPageText - pageText: {}", pageText);
return pageText;
}The first call to fblGetPageText expects a null pointer and returns the size of the pointer to createThen based on the value of the textSizePtr - I create the pointer for the second call to fblGetPageTextDo you see anything wrong with what I am trying to do here?
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x76fd14ae, pid=8592, tid=0x00005c54
#
# JRE version: Java(TM) SE Runtime Environment (8.0_144-b01) (build 1.8.0_144-b01)
# Java VM: Java HotSpot(TM) Client VM (25.144-b01 mixed mode windows-x86 )
# Problematic frame:
# C [ntdll.dll+0x414ae]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\development\sourceControl\3dissue\3d-issue-canvas\JavaProject\3DIssueCanvas\hs_err_pid8592.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
#
Greetings
Matthias
--
You received this message because you are subscribed to a topic in the Google Groups "Java Native Access" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jna-users/qM9Y1478cbA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jna-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Can I put this code on google drive or somewhere and send you a link?
public String getPageText(Pointer pdfPage) { String pageText = null; IntByReference textSizePtr = new IntByReference(); Pointer outputValuePtr = null; int returnCode = conversionInterface.fblGetPageText(pdfPage, null, textSizePtr);
int textSizeValue = textSizePtr.getValue(); CharBuffer outputValuePtr = CharBuffer.allocate(textSizeValue); returnCode = conversionInterface.fblGetPageText(pdfPage, outputValuePtr, textSizePtr);
pageText = charBufferTextOutputValue.toString();
LOGGER.debug("Exiting getPageText - pageText: {}", pageText); return pageText; }--
You received this message because you are subscribed to the Google Groups "Java Native Access" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jna-users+unsubscribe@googlegroups.com.