PDFView shows garbage or blank screen
See original GitHub issueI am creating a file object and pass it to PDFView using the following code:
try {
URL url = new URL(urls[0]);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.connect();
if(conn.getResponseCode() != HttpURLConnection.HTTP_OK) {
return "Server returned HTTP " + conn.getResponseCode() + " "
+ conn.getResponseMessage();
}
//Useful to display progress
int fileLength = conn.getContentLength();
//Download the file
InputStream input = new BufferedInputStream(conn.getInputStream());
File dir = new File(getFilesDir(), "/temp");
dir.mkdir();
file = new File(dir, "temp.pdf");
OutputStream output = new FileOutputStream(file);
byte[] data = new byte[1024];
long total = 0;
int count;
while ((count = input.read(data)) != -1) {
if(isCancelled()) {
input.close();
return null;
}
total += count;
output.write(data);
}
output.flush();
output.close();
input.close();
} catch (IOException e) {
Log.e(LOG_TAG, "IOException: " + e.getMessage());
}
PDFView pdfView = findViewById(R.id.pdfView);
pdfView.fromFile(file).load();
The resulting pdf view is blank or shows garbage characters for most pages (I am going to load mostly PDF files containing Persian and Arabic script). How can this be solved?
Issue Analytics
- State:
- Created 6 years ago
- Comments:12
Top Results From Across the Web
objective c - Printing Off-screen PDFViews - Stack Overflow
When the test program is compiled without the USE_PDF_VIEW preprocessor macro defined, the blank view displays fine. If USE_PDF_VIEW is defined, the document ......
Read more >Safari - PDF Black Screen... Can't view e… - Apple Community
Using Safari when I go to a website with an embedded PDF it comes up blank (black screen). I've tried with Firefox and...
Read more >Solved: PDF viewer not working - Power Platform Community
Solved: I have used this tutorial to convert a file into PDF online and then try to show that PDF in my app....
Read more >Trouble Viewing PDF's in Safari? Blank PDF's ... - Staff Websites
Now in the list that pops up simply delete or drag to Trash any file that shows up that has npapi and the...
Read more >Fix Display of Linked PDF Files on the Web
A blank (or gray) page in the web browser; PDF files open and then ... control how pop-ups and links from other programs...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
maybe,you didn’t put PDFView in a RelativeLayout
@djnotes I tried writing
fos.write(buffer, 0, count);
but still, it was showing invalid characters like İ, ş. Does anyone knows how to fix this issue?