Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pdf open from the half of the first page in iOS using latest version 1.2.5 #207

Closed
harshrastogi-1 opened this issue Oct 3, 2022 · 5 comments · Fixed by #227
Closed

Pdf open from the half of the first page in iOS using latest version 1.2.5 #207

harshrastogi-1 opened this issue Oct 3, 2022 · 5 comments · Fixed by #227

Comments

@harshrastogi-1
Copy link

when you open the pdf in a iOS using the latest version i.e 1.2.5 the pdf open from the half of the first page and it doesn't even update the default page to always open it from the half of the first page..

@wmatusiak
Copy link
Contributor

Could You provide any example project with this issue ?
Cannot reproduce this on my projects.

@vscmaster
Copy link

Hello,
the same for me, after updating to the 1.2.5 PDFs start scroll  a little bit of the first page.
It was fine on 1.2.3 but we were facing some scroll issue on iOS when doc fits width and height of screen.

IMG_0822.MP4

@Krisbo
Copy link

Krisbo commented Feb 23, 2023

I have the same issue.

Snippet from the code:

class _PDFViewerState extends State<PDFViewer> {
  var firebaseStorageService = FirebaseStorageService();
  final Completer<PDFViewController> _controller =
      Completer<PDFViewController>();
  int? pages = 0;
  bool isReady = false;
  String errorMessage = '';
  File? pdfFile;

  getPattern() async {
    var pdfUrl = await firebaseStorageService.getPatternDownloadUrl(
        filePath: widget.pdfFileMetadata?.path ?? "");

    var result = await DefaultCacheManager().getSingleFile(pdfUrl);
    setState(() {
      pdfFile = result;
    });
  }

  @override
  void initState() {
    super.initState();
    getPattern();
  }

  @override
  Widget build(BuildContext context) {
    var theme = ThemeData(
      useMaterial3: true,
      colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepOrange),
    );
    return Scaffold(
      appBar: AppBar(
        backgroundColor: theme.colorScheme.onInverseSurface,
        title: Text(widget.pdfFileMetadata?.name ?? "undefined",
            style: GoogleFonts.dancingScript(
                textStyle: new TextStyle(fontSize: 35.0))),
      ),
      body: pdfFile == null
          ? Text(errorMessage)
          : Container(
              child: PDFView(
                filePath: pdfFile?.path,
                enableSwipe: true,
                //swipeHorizontal: true,
                defaultPage: 1,
                autoSpacing: true,
                pageFling: false,
                onRender: (_pages) {
                  setState(() {
                    pages = _pages;
                    isReady = true;
                  });
                },
                onError: (error) {
                  setState(() {
                    errorMessage = error.toString();
                  });
                  print(error.toString());
                },
                onPageError: (page, error) {
                  setState(() {
                    errorMessage = '$page: ${error.toString()}';
                  });
                  print('$page: ${error.toString()}');
                },
                onViewCreated: (PDFViewController pdfViewController) {
                  _controller.complete(pdfViewController);
                },
              ),
            ),
    );
  }
}

When opening the file I end up with this:
image

But expect this:
image

@juliuskopp
Copy link

Hi, I have the same problem with the version 1.2.5.
When downgrading to 1.2.4, it works.
The problem only exists on IOS.
On Android mobile, there is no problem.

@wmatusiak
Copy link
Contributor

Finally found time to debug this.
Pleas check if #227 fixes Your problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants