Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about Android development and PDF
  • Page:
  • 1
  • 2

TOPIC:

Set cache fails and succeeds randomly 9 years 10 months ago #6448

  • manderin87
  • manderin87's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 21
  • Thank you received: 1
SetCache is still failing. I need to find out why. I made sure each document is using a different cache file and the document is getting closed when no longer needed.
Does it require the premium code? If so, why, I'm not creating a pdf, just saving a annotation to it. At the same time, setcache does work with the professional license, why should it only work occasionally?

thanks

Please Log in or Create an account to join the conversation.

Last edit: by jstampe.

Set cache fails and succeeds randomly 9 years 9 months ago #6449

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 1123
  • Thank you received: 73
professional license is OK.
plz to sure:
--cache file in directory already exists.
--cache file has access right, if on sdcard, you need write extern storage access right.
--you can using java codes to create the file by path, if you not sure you has access write.

Please Log in or Create an account to join the conversation.

Set cache fails and succeeds randomly 9 years 9 months ago #6455

  • manderin87
  • manderin87's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 21
  • Thank you received: 1
This is the code I am using to open the pdf and set the cache
mPDF = (PDFReader) rootView.findViewById(R.id.reader_pdf);

mPDFDocument = new Document();
		
mPDFDocument.Close();

mPDFStream = new PDFFileStream();
	    
if(!mFilePath.isEmpty()) {
		    
mPDFStream.open(mFilePath);
	        
int ret = mPDFDocument.OpenStream(mPDFStream, null);
	        
boolean cache = mPDFDocument.SetCache(Global.tmp_path + "/" + mBook.id() + String.valueOf(mPageNumber) + "temp.dat");
	        
if(Settings.DEBUG && !cache) {
Utilities.displayToast(mApp, "SetCache: failed");
}
	        
switch( ret ) {
	case -1://need input password
		getActivity().finish();
		break;
	case -2://unknown encryption
		getActivity().finish();
		break;
	case -3://damaged or invalid format
		getActivity().finish();
		break;
	case -10://access denied or invalid file path
		getActivity().finish();
		break;
	case 0://succeeded, and continue
		break;
	default://unknown error
		getActivity().finish();
		break;
	}
}
	    
mPDF.PDFOpen(mPDFDocument, false, this);

Please Log in or Create an account to join the conversation.

Set cache fails and succeeds randomly 9 years 9 months ago #6456

  • manderin87
  • manderin87's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 21
  • Thank you received: 1
I think the problem is the cache file... how can I open multiple pdfs with seperate cache files? It seems to open once and then not again. Is there anyway for the document to handle its own cache?

I have no idea if the cache is even being created. The file is not in global temp. Im assuming if the cache cannot be created then setcache would return false. Why would it not be able to be created? I have the external permissions set.

I checked the temp directory and found that the cache is indeed not there on the occasions where setcache succeeded. So if I call setcache again with the same temp filename. Why would it fail?

Would it be possible to see the code for setcache?

Please Log in or Create an account to join the conversation.

Last edit: by jstampe.

Set cache fails and succeeds randomly 9 years 1 month ago #8536

  • clavarreda
  • clavarreda's Avatar
  • Offline
  • New Member
  • New Member
  • Posts: 4
  • Thank you received: 0
A bit late, but I had a similar problem with an app that I was checking. The first time I opened a document bitmaps were just fine, but when I had closed that document and opened another one the bitmaps didn't work. The problem was that when the user closed the document the developer invoked Global.RemoveTmp(); but that deletes the tmp directory created when initializing the library and that was causing me some headaches

I hope this could help

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
  • 2
Powered by Kunena Forum