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

The pdf page display is not clear when using PdfDocumentViewBuilder.file() #287

Open
paladinghub opened this issue Jan 3, 2025 · 5 comments

Comments

@paladinghub
Copy link

using PdfDocumentViewBuilder.file() to open a pdf file,the pdf page display is not clear.but when i open the same pdf file with PdfViewer.file(),it is very clear.And I found PdfPageView can set maximumDpi,but no matter how this parameter is set ,it does not work.
So what should i do to Improve the display clarity of PDF pages using PdfDocumentViewBuilder.file?

@paladinghub
Copy link
Author

another inforamtion

Flutter 3.27.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 8495dee1fd (3 weeks ago) • 2024-12-10 14:23:39 -0800
Engine • revision 83bacfc525
Tools • Dart 3.6.0 • DevTools 2.40.2

windows version Windows 11 pro 23H2

@paladinghub
Copy link
Author

import 'package:flutter/material.dart';
import 'package:pdfrx/pdfrx.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'Pdfrx example',
      home: MainPage(),
    );
  }
}

class MainPage extends StatefulWidget {
  const MainPage({super.key});

  @override
  State<MainPage> createState() => _MainPageState();
}

class _MainPageState extends State<MainPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          leading: IconButton(
            icon: const Icon(Icons.menu),
            onPressed: () {},
          ),
          title: const Text('Pdfrx example'),
        ),
        body: PdfDocumentViewBuilder.file(
          'D:/c.pdf',
          builder: (context, document) => ListView.builder(
            padding: const EdgeInsets.all(5),
            itemExtent: document?.pages.first.height ?? 800,
            itemCount: document?.pages.length ?? 0,
            // cacheExtent: 500,
            itemBuilder: (context, index) {
              return Container(
                height: document?.pages.first.height,
                width: document?.pages.first.width,
                child: PdfPageView(
                  document: document,
                  pageNumber: index + 1,
                  alignment: Alignment.center,
                ),
              );
            },
          ),
        )
        // PdfViewer.file(
        //   'D:/c.pdf',
        //   passwordProvider: () => 'test',
        // ),
        );
  }
}

c.pdf

@espresso3389
Copy link
Owner

Please note that the width/height returned by PdfPage.width/PdfPage.width, is points (height in pixels at 72 dpi), not in pixel.

And, if you want to calculate the PDF resolution by yourself, you can use PdfPageView.pageSizeCallback.

@espresso3389 espresso3389 added question Further information is requested and removed question Further information is requested labels Jan 3, 2025
@paladinghub
Copy link
Author

@espresso3389 Thanks for your generosity reminder . I noticed biggestSize and pageSize have a fixed proportional relationship and the calculation logic of PageSize in pdf_widgets.dart ,it helps me

@paladinghub
Copy link
Author

close

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

No branches or pull requests

2 participants