I have been creating PDFs with keirS (2014) cPDF class.
It has worked very well and I have been able to open the PDF it created with several different intents.
Its only when I try to open it locally with an Intent using DonManfred's PDFium library that I encounter errors.
Yes I'm probably doing something fundamentally wrong, but I haven't been able to figure it out.
I have included a test project that contains my problem.
The premise of the app is simple
Add some of your own text
Click the create button
Click the Intent Open button to open the created file using whatever intent you like for PDFs
If you entered some text you will see it in the created PDF, so its proof a new PDF is being created each time
The if you click the Open Local button you will encounter this error (in debug mode)
java.io.IOException: cannot create document: File not in PDF format or corrupted.
at com.shockwave.pdfium.PdfiumCore.nativeOpenDocument(Native Method)
at com.shockwave.pdfium.PdfiumCore.newDocument(PdfiumCore.java:135)
at com.github.barteksc.pdfviewer.source.UriSource.createDocument(UriSource.java:38)
at com.github.barteksc.pdfviewer.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:49)
at com.github.barteksc.pdfviewer.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:25)
at android.os.AsyncTask$3.call(AsyncTask.java:394)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:920)
It may be obvious to those that know java inside out, but like I say, I cant figure out what's wrong.
What's in the project
[B4X] PDF Generator - B4X Cross Platform - Class 100% B4X Code
DonManfred's PDFium
Any suggestions are welcome.
Even if those comments are along the line of, why are you using that library?
It has worked very well and I have been able to open the PDF it created with several different intents.
Its only when I try to open it locally with an Intent using DonManfred's PDFium library that I encounter errors.
Yes I'm probably doing something fundamentally wrong, but I haven't been able to figure it out.
Problem Sub:
Private Sub Button3_Click
' read and display the PDF that was created
Dim PDF As PdfiumCore
Dim folder2 As String = xui.DefaultFolder & "/temp"
Try
PDF.Initialize("PDFium")
Dim cfg As Configurator = PDFView1.fromUri(folder2, "test.pdf")
cfg.SetEventname("PDFium")
cfg.autoSpacing(True).enableSwipe(True).pageSnap(True).swipeHorizontal(False).addOnErrorListener.addOnLoadCompleteListener.addOnPageChangeListener.addOnPageErrorListener.addOnTapListener
cfg.load
Catch
MsgboxAsync(LastException, "What?")
End Try
End Sub
I have included a test project that contains my problem.
The premise of the app is simple
Add some of your own text
Click the create button
Click the Intent Open button to open the created file using whatever intent you like for PDFs
If you entered some text you will see it in the created PDF, so its proof a new PDF is being created each time
The if you click the Open Local button you will encounter this error (in debug mode)
java.io.IOException: cannot create document: File not in PDF format or corrupted.
at com.shockwave.pdfium.PdfiumCore.nativeOpenDocument(Native Method)
at com.shockwave.pdfium.PdfiumCore.newDocument(PdfiumCore.java:135)
at com.github.barteksc.pdfviewer.source.UriSource.createDocument(UriSource.java:38)
at com.github.barteksc.pdfviewer.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:49)
at com.github.barteksc.pdfviewer.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:25)
at android.os.AsyncTask$3.call(AsyncTask.java:394)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:920)
It may be obvious to those that know java inside out, but like I say, I cant figure out what's wrong.
What's in the project
[B4X] PDF Generator - B4X Cross Platform - Class 100% B4X Code
DonManfred's PDFium
Any suggestions are welcome.
Even if those comments are along the line of, why are you using that library?