通过网址使用PDF查看器显示PDF

时间:2019-03-10 01:41:25

标签: java android pdf-viewer

我有此代码:

 public class ViewBookActivity extends AppCompatActivity {

     PDFView pdfbook;

     @Override
     protected void onCreate(Bundle savedInstanceState) {

         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_view_book);
         Intent intent = getIntent();

         Uri PDF_URL = Uri.parse(intent.getStringExtra("PDF_URL")) ;
         /*url looks like this http://192.168.8.124/Book/One-1.pdf*/
         Toast.makeText(this, "", Toast.LENGTH_SHORT).show();
         pdfbook = (PDFView) (findViewById(R.id.pdfbook));
         pdfbook.fromUri(PDF_URL).load();
         Log.v("PDFVIEW",PDF_URL.toString());

     }
  }

所以我有了该代码,我的URL看起来像这样http://192.168.8.124/Book/One-1.pdf 因此,当我将其粘贴到浏览器中时,我可以看到pdf,但无法在设备中查看它,它仅显示空白活动

我正在使用此API https://github.com/barteksc/AndroidPdfViewerV2

2 个答案:

答案 0 :(得分:0)

只需使用此代码 sentence2 = "Previous study: 03/03/2018 (other hospital) Findings: Lung parenchyma: The study reveals evidence of apicoposterior segmentectomy of LUL showing soft tissue thickening adjacent surgical bed at LUL, possibly post operation." blob_sentence = TextBlob(sentence2) noun = blob_sentence.noun_phrases df1 = pd.DataFrame(noun) comorbidity_keywords = ["segmentectomy","lobectomy"] matches =[] for comorbidity_keywords[0] in df1: if comorbidity_keywords[0] in df1 and comorbidity_keywords[0] not in matches: matches.append(comorbidity_keywords)

import worker from './worker.js'; import WebWorker from './WebWorker'; const useSetInterval = ({ prayerTime }) => { // SET THE STATE OF SECONDS, MINUTES AND HOURS const [seconds, setSeconds] = useState(60 - Number(moment().format('ss'))); const [minutes, setMinutes] = useState(prayerTime.minutes); const [hours, setHours] = useState(prayerTime.hours); useEffect(() => { const w = new WebWorker(worker); w.postMessage({ seconds, minutes, hours }); w.addEventListener('message', e => { const { newSeconds, newMinutes, newHours } = e.data; setSeconds((newSeconds < 0) ? 59 : newSeconds); if (newSeconds < 0) { setMinutes((newMinutes < 0) ? 59 : newMinutes); if (newMinutes < 0) setHours((newHours < 0) ? "Refresh" : newHours); } }); return () => w.terminate(); }, [seconds, minutes, hours]); return { seconds, minutes, hours }; }; // Webworker.js export default class WebWorker { constructor(worker) { const code = worker.toString(); const blob = new Blob(['('+code+')()']); return new Worker(URL.createObjectURL(blob)); } } // worker.js export default () => { self.addEventListener( "message", (e) => { if (!e) return; const { seconds, minutes, hours } = e.data; setTimeout(() => { const newSeconds = seconds - 1; const newMinutes = (newSeconds < 0) ? minutes - 1 : minutes; const newHours = (newMinutes < 0) ? hours - 1 : hours; postMessage({ newSeconds, newMinutes, newHours }); }, 1000); }); };

http://docs.google.com/gview?embedded=true&url="+yourURL

答案 1 :(得分:0)

我能够解决很长的一段代码,但这是它的github和其上的youtube教程 请注意youtube教程不是我的,只是代码是

https://www.youtube.com/watch?v=rcE4zUiwwbo

https://github.com/kunz398/android_openPdf