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

How to render(View) pdf file

More
IP: 192.168.0.71 11 years 5 months ago #7372 by asliyanage
Can you provide simple example?Demo project contains the large number of files?I need to view pdf file in my app?
More
IP: 192.168.0.156 11 years 5 months ago - 11 years 5 months ago #7373 by Davide
Replied by Davide on topic How to render(View) pdf file
Hi,
please check in the demo project the PDFReader and PDFReaderAct class.
This will help you!
Last edit: 11 years 5 months ago by poudel.
More
IP: 192.168.0.71 11 years 5 months ago #7378 by asliyanage
can you provide a simple code to load pdf file from a given path ?
More
IP: 192.168.0.156 11 years 5 months ago #7380 by Davide
Replied by Davide on topic How to render(View) pdf file
Hi,

try to add this in the InitView() void in PDFReaderAct class..

Code:
m_doc = new Document(); m_doc.Open( your_pdf_path, your_pdf_password ); m_reader.PDFOpen(m_doc, false, this);
More
IP: 192.168.0.71 11 years 4 months ago - 11 years 4 months ago #7586 by asliyanage
How to call this in a fragment as last argument is PDFReader.PDFReaderListener ?.In a activity we can implement this listener.I need to view pdf five in a viewpager which has several fragments.


Below is my fragments code.

Code:
package com.sph.pdf; import java.io.File; import java.io.InputStream; import com.radaee.pdf.Document; import com.radaee.pdf.Global; import com.radaee.pdf.Page.Annotation; import com.radaee.reader.PDFReader; import com.radaee.reader.PDFReader.PDFReaderListener; import com.radaee.util.PDFThumbView; import com.radaee.view.PDFVPage; import android.content.Intent; import android.content.res.AssetManager; import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.support.v4.app.Fragment; import android.support.v4.view.ViewPager; import android.util.Log; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.widget.ImageView; import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.Toast; public class MyFragment extends Fragment implements PDFReaderListener { public static final String EXTRA_MESSAGE = "EXTRA_MESSAGE"; public static int count = 1; static String file; TextView txt; private PDFThumbView m_thumb = null; private Document m_doc = new Document(); private RelativeLayout m_layout; private PDFReader m_reader = null; private RelativeLayout mContentView; public static final MyFragment newInstance(String message) { MyFragment f = new MyFragment(); Bundle bdl = new Bundle(1); bdl.putString(EXTRA_MESSAGE, message); f.setArguments(bdl); file = message; return f; } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mContentView = new RelativeLayout(getActivity()); mContentView.setLayoutParams(new LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); openDoc("/mnt/sdcard/pdf/1.pdf"); return mContentView; } public void openDoc(String path) { try { File sdCard = Environment.getExternalStorageDirectory(); File imageFolder = new File(sdCard.getAbsolutePath()); String rootPaperFolder = imageFolder.toString(); // View v = inflater.inflate(R.layout.pdf_fragment, container, // false); Global.Init(getActivity()); m_layout = (RelativeLayout) LayoutInflater.from(getActivity()).inflate(R.layout.reader, null); m_reader = (PDFReader) m_layout.findViewById(R.id.view); Log.e("m_reader.PDFOpen", ""+m_reader); m_doc.Close(); int ret = m_doc.Open(path, null); if (ret == 0) { // m_doc.SetCache( Global.tmp_path + "/temp.dat" ); m_reader.PDFOpen(m_doc, false, this); } } catch (Exception e) { e.printStackTrace(); Log.e("m_reader.PDFOpen", ""+m_reader); } } @Override public void onDestroyView() { super.onDestroyView(); // Log.d("PDFVIEW", "onDestroyView"); try { if (m_thumb != null) { m_thumb.thumbClose(); m_thumb = null; } if (m_reader != null) m_reader.PDFClose(); if (m_doc != null) m_doc.Close(); Global.RemoveTmp(); super.onDestroy(); } catch (Exception e) { e.printStackTrace(); } } @Override public void OnPageModified(int pageno) { // TODO Auto-generated method stub } @Override public void OnPageChanged(int pageno) { // TODO Auto-generated method stub } @Override public void OnAnnotClicked(PDFVPage vpage, Annotation annot) { // TODO Auto-generated method stub } @Override public void OnSelectEnd(String text) { // TODO Auto-generated method stub } @Override public void OnOpenURI(String uri) { // TODO Auto-generated method stub } @Override public void OnOpenJS(String js) { // TODO Auto-generated method stub } @Override public void OnOpenMovie(String path) { // TODO Auto-generated method stub } @Override public void OnOpenSound(int[] paras, String path) { // TODO Auto-generated method stub } @Override public void OnOpenAttachment(String path) { // TODO Auto-generated method stub } @Override public void OnOpen3D(String path) { // TODO Auto-generated method stub } }
it gives me 10 for ret value.But if i put the same code in activity it gives me 0 for ret varible.

int ret = m_doc.Open(path, null);
Last edit: 11 years 4 months ago by Docrishav.
More
IP: 192.168.0.156 11 years 4 months ago #7695 by Davide
Replied by Davide on topic How to render(View) pdf file
Hi,
ret = 10 means access denied or invalid file path.
Please check the path.
Time to create page: 0.394 seconds
Powered by Kunena Forum