zsviczian / obsidian-excalidraw-plugin

A plugin to edit and view Excalidraw drawings in Obsidian
4.08k stars 221 forks source link

BUG: PDF++ cropping cannot render properly when the PDF is rotated #2036

Open RyotaUshio opened 2 weeks ago

RyotaUshio commented 2 weeks ago

Have you searched for existing issues (including closed ones)?

Does this bug persist in a new vault with only Excalidraw installed?

I can't fill in this checkbox because I must keep PDF++ enabled.

Your environment

SYSTEM INFO: Obsidian version: v1.7.2 Installer version: v1.6.3 Operating system: Darwin Kernel Version 22.6.0: Mon Feb 19 19:43:41 PST 2024; root:xnu-8796.141.3.704.6~1/RELEASE_ARM64_T8103 22.6.0 Login status: logged in Language: en Catalyst license: insider Insider build toggle: on Live preview: on Base theme: adapt to system Community theme: none Snippets enabled: 0 Restricted mode: off Plugins installed: 2 Plugins enabled: 2 1: Excalidraw v2.5.0 2: PDF++ v0.40.9

RECOMMENDATIONS: Community plugins: for bugs, please first try updating all your plugins to latest. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community plugins.

Describe the bug

Hi, I'm the developer of the PDF++ plugin. Thank you again for the cool feature for rendering PDF++ rectangular cropping!

It works almost perfectly, but I noticed that if the PDF page is rotated, Excalidraw misunderstands the coordinates of the crop area. Please see this video for an example:

https://github.com/user-attachments/assets/ba0047ad-d84f-456d-a1e8-49d5178c2e36

Steps to reproduce

  1. With PDF++ installed, import this PDF file to a vault and open it.
  2. Copy a link to a rectangular area using PDF++'s feature. You will want to use somewhere far from the page's center to make the bug more noticeable.
  3. Open an Excalidraw file, and paste the link to it.
  4. Now, Excalidraw will render a different region from the intended.

Expected behavior

Excalidraw should render the same region as selected in the PDF viewer. In the video above, the PDF++.md pane shows this desired behavior.

Additional context

This bug seems to be happening because Excalidraw's current rendering algorithm does not take page rotation into account.

In fact, PDF++ also suffered from the same issue in the past (https://github.com/RyotaUshio/obsidian-pdf-plus/issues/84).

I will send a PR if I've got some time, but unfortunately I can't do it very soon since I'm pretty occupied recently. So just in case, let me share how I managed to fix this issue in PDF++:

https://github.com/RyotaUshio/obsidian-pdf-plus/blob/127ea5b94bb8f8fa0d4c66bcd77b3809caa50b21/src/lib/index.ts#L890-L899

Thank you!

LeonelRFF commented 3 days ago

Hello, I have a problem related to clipping. Is it normal that when opening the links to the embedded parts of a document, the content is not located and highlighted when opening it? When doing this with mardown notes, when opening the link, it redirects and highlights the rectangle in the document correctly. In excalidraw when doing this, a new tab opens every time 🤔 and does not highlight the content. It only works if I open excalidraw in markdown mode. If I do this with only the text of the PDF it works fine 👌(but it keeps opening it in another tab). The problem is with the links to the rectangular embedded parts. Regards.

https://github.com/user-attachments/assets/c6bca35e-da30-4db7-9075-222591861be8