- Posts: 21
- Thank you received: 1
Microsoft Windows Phone 8.1 support ends (13 Jul 2017)
Microsoft has ended support for Windows Phone 8.1
Questions about Android development and PDF
Set cache fails and succeeds randomly
- manderin87
- Topic Author
- Offline
- Junior Member
-
Less
More
IP: 192.168.0.71
12 years 3 months ago - 12 years 3 months ago #6448
by manderin87
Replied by manderin87 on topic Set cache fails and succeeds randomly
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
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
Last edit: 12 years 3 months ago by jstampe.
IP: 192.168.0.71
12 years 3 months ago #6449
by radaee
Replied by radaee on topic Set cache fails and succeeds randomly
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.
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.
- manderin87
- Topic Author
- Offline
- Junior Member
-
Less
More
- Posts: 21
- Thank you received: 1
IP: 192.168.0.71
12 years 3 months ago #6455
by manderin87
Replied by manderin87 on topic Set cache fails and succeeds randomly
This is the code I am using to open the pdf and set the cache
Code:
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);
- manderin87
- Topic Author
- Offline
- Junior Member
-
Less
More
- Posts: 21
- Thank you received: 1
IP: 192.168.0.71
12 years 3 months ago - 12 years 3 months ago #6456
by manderin87
Replied by manderin87 on topic Set cache fails and succeeds randomly
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?
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?
Last edit: 12 years 3 months ago by jstampe.
- clavarreda
- Offline
- New Member
-
Less
More
- Posts: 4
- Thank you received: 0
11 years 7 months ago #8536
by clavarreda
Replied by clavarreda on topic Set cache fails and succeeds randomly
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
I hope this could help
Time to create page: 0.381 seconds