AndroidPdfViewer icon indicating copy to clipboard operation
AndroidPdfViewer copied to clipboard

How can I save the last page I was reading before exiting the application?

Open kingdoom0 opened this issue 5 years ago • 3 comments

A very great effort that deserves our appreciation and thanks

I wanted to know how to save the pages that I was reading before exiting the application, so that it does not start again after opening the application, but I want it to open the last page I was reading automatically

kingdoom0 avatar Oct 05 '20 15:10 kingdoom0

Duplicate of #533 Duplicate of #498

AhmerAfzal1 avatar Oct 06 '20 05:10 AhmerAfzal1

thats my view code

import android.os.Bundle;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import com.github.barteksc.pdfviewer.PDFView;
import com.github.barteksc.pdfviewer.scroll.DefaultScrollHandle;
import com.github.barteksc.pdfviewer.util.FitPolicy;


import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class my_view extends AppCompatActivity {
    AdView mAdView ;
    private InterstitialAd mInterstitialAd;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.my_view);
        //PDF View
        PDFView pdfView = findViewById(R.id.general_v);
        pdfView.fromAsset(getIntent().getStringExtra("BOOK_PATH"))
                .enableSwipe(true) // allows to block changing pages using swipe
                .swipeHorizontal(false)
                .enableDoubletap(true)
                .defaultPage(0)
                .getCurrentPage()
                .enableAnnotationRendering(false) // render annotations (such as comments, colors or forms)
                .password(null)
                .enableAntialiasing(true) // improve rendering a little bit on low-res screens
                // spacing between pages in dp. To define spacing color, set view background
                .spacing(0)
                .pageFitPolicy(FitPolicy.WIDTH)
                .scrollHandle(new DefaultScrollHandle(this,false))
                .load();





}

I Cant do it , please help me

kingdoom0 avatar Nov 25 '20 21:11 kingdoom0

Create an on load() method Save the current reading page in shared preference. This will store the current reading page when a pdf is loaded.

Then call the on destroy () method. Pass the saved current reading page.

Lastly insert the saved page in the default page.

Ranspap23 avatar Apr 14 '22 02:04 Ranspap23