Giter VIP home page Giter VIP logo

Comments (9)

Jdogzz avatar Jdogzz commented on August 24, 2024 1

The PyMuPDF author corrected my understanding of the issue, that it was related to handling non-integer sizes of the boxes, and solved that half of the problem in pymupdf/PyMuPDF#1616 The other half seems to be related to an unnecessary transformation which I believe I have addressed in #65.

from eaf-pdf-viewer.

manateelazycat avatar manateelazycat commented on August 24, 2024

@luhuaei Can you help fix this ?

from eaf-pdf-viewer.

luhuaei avatar luhuaei commented on August 24, 2024

@luhuaei Can you help fix this ?

👌 I assign myself.

from eaf-pdf-viewer.

luhuaei avatar luhuaei commented on August 24, 2024

Previously both of these PDFs successfully loaded in eaf-pdf-viewer. However, in the process of trying out the latest pymupdf wheel (related to #62)

@Jdogzz That is to say you install pre-version pymupdf(1.19.6 wheel) cause above error, but previously pymupdf can successfully loaded both PDFs?

But I use pymupdf-1.19.4 open the mwb_E_202201.pdf can reproduce above problem.

>>> import fitz
>>> fitz.__doc__
'\nPyMuPDF 1.19.4: Python bindings for the MuPDF 1.19.0 library.\nVersion date: 2022-01-01 00:00:01.\nBuilt for Python 3.9 on linux (64-bit).\n'
>>> 

Maybe it's not a version issue.

from eaf-pdf-viewer.

Jdogzz avatar Jdogzz commented on August 24, 2024

Thanks for taking a look at this.

That's correct, both PDFs worked in a previous version, and sadly I no longer know which version I had installed before.

With some testing I've been able to include more information. For posterity, repeating your python output I get this for fitz on my end after having installed the preview wheel:

Python 3.7.3 (default, Jan 22 2021, 20:04:44) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import fitz
>>> fitz.__doc__
'\nPyMuPDF 1.19.6: Python bindings for the MuPDF 1.19.0 library.\nVersion date: 2022-03-01 00:00:01.\nBuilt for Python 3.7 on linux (64-bit).\n'

I am able to reproduce the error I originally reported with the first PDF in a clean test environment, an Ubuntu 21.10 VM, with a freshly compiled copy of emacs from git and following the bare bones setup from the eaf README. This has occurred with the stable version of pymupdf. Here's the relevant info:

python3-pyqt5 5.15.4+dfsg-3
python3-dbus 1.2.16-5
python3-pyqt5.qtwebengine 5.15.4-1

GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.30, cairo version 1.16.0) of 2022-02-23

Python 3.9.7 (default, Sep 10 2021, 14:59:43) 
[GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import fitz
>>> fitz.__doc__
'\nPyMuPDF 1.19.5: Python bindings for the MuPDF 1.19.0 library.\nVersion date: 2022-02-01 00:00:01.\nBuilt for Python 3.9 on linux (64-bit).\n'

Here is the debug log from the *eaf* buffer when I attempted to load the first PDF:

Traceback (most recent call last):
  File "/home/etest/emacs-application-framework/app/pdf-viewer/buffer.py", line 1158, in paintEvent
    qpixmap = self.get_page_pixmap(index, self.scale * hidpi_scale_factor, self.rotation)
  File "/home/etest/emacs-application-framework/app/pdf-viewer/buffer.py", line 1079, in get_page_pixmap
    page = self.document[index]
  File "/home/etest/emacs-application-framework/app/pdf-viewer/buffer.py", line 475, in __getitem__
    page = PdfPage(self.document[index], index, self.document.isPDF)
  File "/home/etest/emacs-application-framework/app/pdf-viewer/buffer.py", line 584, in __init__
    self._page_rawdict = self._init_page_rawdict()
  File "/home/etest/emacs-application-framework/app/pdf-viewer/buffer.py", line 599, in _init_page_rawdict
    set_page_crop_box(self.page)(self.clip)
  File "/home/etest/.local/lib/python3.9/site-packages/fitz/fitz.py", line 6414, in set_cropbox
    return self._set_pagebox("CropBox", rect)
  File "/home/etest/.local/lib/python3.9/site-packages/fitz/fitz.py", line 6409, in _set_pagebox
    raise ValueError("rect not in mediabox")
ValueError: rect not in mediabox
QBackingStore::endPaint() called with active painter; did you forget to destroy it or call QPainter::end() on it?
QPainter::end: Painter ended with 2 saved states
Traceback (most recent call last):
  File "/home/etest/emacs-application-framework/app/pdf-viewer/buffer.py", line 1158, in paintEvent
    qpixmap = self.get_page_pixmap(index, self.scale * hidpi_scale_factor, self.rotation)
  File "/home/etest/emacs-application-framework/app/pdf-viewer/buffer.py", line 1079, in get_page_pixmap
    page = self.document[index]
  File "/home/etest/emacs-application-framework/app/pdf-viewer/buffer.py", line 475, in __getitem__
    page = PdfPage(self.document[index], index, self.document.isPDF)
  File "/home/etest/emacs-application-framework/app/pdf-viewer/buffer.py", line 584, in __init__
    self._page_rawdict = self._init_page_rawdict()
  File "/home/etest/emacs-application-framework/app/pdf-viewer/buffer.py", line 599, in _init_page_rawdict
    set_page_crop_box(self.page)(self.clip)
  File "/home/etest/.local/lib/python3.9/site-packages/fitz/fitz.py", line 6414, in set_cropbox
    return self._set_pagebox("CropBox", rect)
  File "/home/etest/.local/lib/python3.9/site-packages/fitz/fitz.py", line 6409, in _set_pagebox
    raise ValueError("rect not in mediabox")
ValueError: rect not in mediabox
QBackingStore::endPaint() called with active painter; did you forget to destroy it or call QPainter::end() on it?
QPainter::end: Painter ended with 2 saved states
Traceback (most recent call last):
  File "/home/etest/emacs-application-framework/app/pdf-viewer/buffer.py", line 2031, in eventFilter
    self.check_annot()
  File "/home/etest/emacs-application-framework/app/pdf-viewer/buffer.py", line 1856, in check_annot
    page = self.document[page_index]
  File "/home/etest/emacs-application-framework/app/pdf-viewer/buffer.py", line 475, in __getitem__
    page = PdfPage(self.document[index], index, self.document.isPDF)
  File "/home/etest/emacs-application-framework/app/pdf-viewer/buffer.py", line 584, in __init__
    self._page_rawdict = self._init_page_rawdict()
  File "/home/etest/emacs-application-framework/app/pdf-viewer/buffer.py", line 599, in _init_page_rawdict
    set_page_crop_box(self.page)(self.clip)
  File "/home/etest/.local/lib/python3.9/site-packages/fitz/fitz.py", line 6414, in set_cropbox
    return self._set_pagebox("CropBox", rect)
  File "/home/etest/.local/lib/python3.9/site-packages/fitz/fitz.py", line 6409, in _set_pagebox
    raise ValueError("rect not in mediabox")
ValueError: rect not in mediabox
Saved session:  /home/etest/emacs-application-framework/app/pdf-viewer/buffer.py /home/etest/Downloads/mwb_E_202201.pdf 2087.6365062761474:1.4781746031746033:fit_to_width:True:0

As before, the first PDF does not render in the emacs buffer.

from eaf-pdf-viewer.

Jdogzz avatar Jdogzz commented on August 24, 2024

As a small update, with some further testing I have found there was a regression in going from pymupdf 1.19.3 and 1.19.4. When using pymupdf 1.19.3 I am able to successfully open the first PDF in eaf-pdf-viewer, and when using pymupdf 1.19.4 and later versions I get the above error.

from eaf-pdf-viewer.

Jdogzz avatar Jdogzz commented on August 24, 2024

With some more testing I was able to pinpoint the bug as an apparent mismatch of cropbox and mediabox used by pymupdf, I have opened a bug report here: pymupdf/PyMuPDF#1615

from eaf-pdf-viewer.

luhuaei avatar luhuaei commented on August 24, 2024

The PyMuPDF author corrected my understanding of the issue, that it was related to handling non-integer sizes of the boxes, and solved that half of the problem in pymupdf/PyMuPDF#1616 The other half seems to be related to an unnecessary transformation which I believe I have addressed in #65.

Thanks!

from eaf-pdf-viewer.

luhuaei avatar luhuaei commented on August 24, 2024

On my testing, This problem already fixed. I close this issue.

from eaf-pdf-viewer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.