farling42 / fvtt-pdf-pager

PDF Pager for Foundry
MIT License
6 stars 4 forks source link

@PDF does not open the specified page #111

Closed af-dpe closed 1 month ago

af-dpe commented 1 month ago

Using "(@PDF[RG|page=112]{see p. 112}" always opens the last opened page of the PDF (RG) but does not jump to page 112.

The error currently only exists in this one PDF. Cloning the PDF meant that it worked with a new parameter (RG2). After deleting the original and renaming the copy, the error was there again.

The jump always takes place to the last page that was opened in the PDF via the Item (see screenshot) button. grafik

For other PDFs the command works without any problems.

farling42 commented 1 month ago

Could you open the journal page that contains your PDF link, and check with the "<>" editor button that there is no hidden HTML formatting within the text of the link.

It appears that the page reference is not being detected on the string.

As a side-note, a user on github has the account name pdf, so prefers any reference to be inside the "back-tick" quotation marks, such as @pdf

Thogrim1984 commented 1 month ago

Hi,

I am the other SL in the campaign.

There are no HTML tags in the expression.

And strictly speaking, the link does not lead to the page indicated at the top of the item (sr5 ruleset), but simply to the last open page in the PDF or the title page.

Thogrim1984 commented 1 month ago

Oh, and the same string just with "RG2" and a copied PDF-Note works.

farling42 commented 1 month ago

Which version of foundry, game system (name + version), and version of the PDF Pager module?

Are these links in a normal journal page, or in a special place on the page which has special handling for PDF pages? (I only ask because in the above image the PDF icon is on the far left and the text of the label is on the far right of the page.)

farling42 commented 1 month ago

If you know how to use the Element Inspector in your browser, could you look at the element containing the PDF link, and see if it contains both data-hash and data-uuid as seen in the following image: image

Thogrim1984 commented 1 month ago

Hi,

Versions: Foundry: V11 Stable - Patch 13 (Build 315) Game System: Shadowrun 5th Edition 0.21.0 PDF-Pager: 1.2.1

"Are these links in a normal journal page, or in a special place on the page which has special handling for PDF pages?"

The link in the picture and the "problem link" are two different things.

The link in the image is the implementation of the PDF pager module directly as a dependency of the SR5 rulesets and is therefore directly anchored in the system.

The link in the item description is the one mentioned by "@pdf[RG|page=112]{see p. 112}". And here is the problem.

Here is another image of the entire item with both PDF links:

image

Here is the HTML-Element:

<a class="content-link" draggable="true" data-hash="page=112" data-uuid="JournalEntry.QfGvtyO4zz2zuTwD.JournalEntryPage.MTtRO9F7EPCH7O32" data-id="MTtRO9F7EPCH7O32" data-type="JournalEntryPage" data-tooltip="PDF Seite"><i class="fas fa-file-pdf"></i>siehe S. 112</a>

And here ist the entire paragraph:

<p>Die Verwendung einer Garotte setzt einen erfolgreichen Angriff voraus, um die Waffe in Position zu bringen, ähnlich einem Festhalteangriff. Der Angreifer verwendet seine Fertigkeit Exotische Nahkampfwaffe (Garrotte), um das Festhalten durchzuführen. Der Angriff muss mit dem Modifikator für die Trefferzone des angesagten Ziels (<a class="content-link" draggable="true" data-hash="page=112" data-uuid="JournalEntry.QfGvtyO4zz2zuTwD.JournalEntryPage.MTtRO9F7EPCH7O32" data-id="MTtRO9F7EPCH7O32" data-type="JournalEntryPage" data-tooltip="PDF Seite"><i class="fas fa-file-pdf"></i>siehe S. 112</a><span class="markedContent" id="page32901R_mcid6817">)</span> durchgeführt werden und mindestens einen Nettoerfolg erzielen. Sobald die Waffe in Position gebracht worden ist, kann der Angreifer in seiner nächsten Handlungsphase den Schaden der Waffe verursachen und gleichzeitig seinen Griff mit einer weiteren Angriffsprobe verbessern oder das Ziel niederschlagen.</p>

I don't know if the red span element around the closing parenthesis could have anything to do with it, it's definitely reinserted by Foundry after I explicitly deleted it, but it's also outside the PDF command ...

farling42 commented 1 month ago

Can I just check that you are using @PDF and not @pdf since the PDF Pager module only works with upper case.

The presence of the data-hash should be picked up when the PDF Pager module intercepts the link request. Is anything reported in the browser console (with debugging reports enabled) when clicking on the link? My browser shows the following:

image

I have your installation set up, and a link to a different rule book is opening at the correct page.

What value do you have in the "Page Offset" field for the journal page containing the PDF?

Thogrim1984 commented 1 month ago

Ok, I found the module that causes the error and I really didn't expect that in this context ... I had disabled all modules that do anything with the journals in advance, but after checking the console I just ran Find the Culprit again... The module, after deactivating it, works again:

https://foundryvtt.com/packages/touch-vtt

I don't know if this will help you with general bugfixing, for us it should work without Touch VTT. But I'm still happy to help with troubleshooting.

farling42 commented 1 month ago

Ah, it's good that you found the issue.

I suspect it is the "fake touch" that TouchVTT is doing which is ignoring the data-hash field of the link.

It would be interesting to see if linking to a heading within a normal text journal page also fails to be displayed to open the page at that heading when TouchVTT is used.

Thogrim1984 commented 1 month ago

Can you replicate the error in your system? Or is this a crazy ours problem?

Thogrim1984 commented 1 month ago

But in general:

We have never had any problems with linking to journals, whether to PDFs (which we use intensively) or to individual journal pages (which we also use, but not so often). Only this link to the PDF with this abbreviation causes problems.

Perhaps also relevant: We use Forge as a host.

farling42 commented 1 month ago

I wonder if "RG" is used anywhere else, such as an actual journal document name or as the PDF code for another page?

Thogrim1984 commented 1 month ago

I would say "no". But I'll look through everything again tomorrow. It's too late for that kind of detective work today :D

Thogrim1984 commented 1 month ago

I have now gone through all our journals. No, RG is only used once, no PDF and no journal page uses that except the PDF in question.

farling42 commented 1 month ago

I will be GMing for the evening. It seems strange that it only occurs on one particular PDF with a particular code.

farling42 commented 1 month ago

The page is ignored when I enable Touch VTT on my desktop:

With Touch VTT enabled on my desktop (which doesn't have a touch screen):

image

With Touch VTT module disabled:

image

farling42 commented 1 month ago

Breakpoint at foundry.js:5802

Call stack normally:

image

Call stack with Touch VTT:

image

farling42 commented 1 month ago

The callback on the "a" link has event.currentTarget pointing to the "a" element.

When the TouchVTT module is enabled, event.currentTarget is pointing to the "div" of the Journal window (not even the page).

farling42 commented 1 month ago

I've raised an issue on the touch-vtt module, since it is creating an event with the wrong information.

farling42 commented 1 month ago

Closing this issue now as it is a problem with touch-vtt.

farling42 commented 1 month ago

Issue has been fixed in Touch VTT version 2.2.2