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

Add PDF hyperlink support #113

Merged
merged 11 commits into from Dec 5, 2018
Merged

Add PDF hyperlink support #113

merged 11 commits into from Dec 5, 2018

Conversation

matsud224
Copy link
Contributor

This PR adds a PDF hyperlink support to SATySFi. I think page navigation features are essential particularly to read a large document like a SATySFi book.

I think the APIs described below are highly controversial.

For example, some features not provided by primitives are not available (e.g. annotation border style, mouse down highlighting mode, ...).
One possible solution is to pass PDF objects(e.g. dictionary, array, stream) as argument of primitive. pdfTeX takes this approach. (c.f. pdfTeX users manual).

Added primitives

  • register-destination : string -> point -> unit
    Register given destination key with given coordinates.

  • register-link-to-uri : string -> point -> length -> length -> length -> length -> color option -> unit
    Add a link to given URI with given rectangle, border width and border color.

  • register-link-to-location : string -> point -> length -> length -> length -> length -> color option -> unit
    Add a link to given destination key with given rectangle, border width and border color.

Package

annot.satyh provides a PDF annotation related commands and functions (now, link annotation only). I used deco-set feature to get a region of link or get a coordinates of link destination.

  • \href : [length?; color?; string; inline-text] inline-cmd
    This command makes a link to a designated URI.

This PR modifies stdjabook.satyh to add a link of :

  • each table-of-contents element
  • \ref
  • \ref-page
  • \figure

@matsud224 matsud224 closed this Oct 17, 2018
@matsud224 matsud224 reopened this Oct 17, 2018
@gfngfn
Copy link
Owner

gfngfn commented Oct 25, 2018

I have just checked that it works as you had intended. Thank you for now for sending such a brilliant PR! I will read closely the code that realizes the operation of adding hyperlinks, so I would appreciate it if you could wait for a while (and possibly discuss further in detail).

@gfngfn
Copy link
Owner

gfngfn commented Nov 28, 2018

I’m super sorry to make a very late response… I took a close look into your implementation and found it quite well-written basically. Although I’m ready to merge this PR, I have a small question about it:

Is there any rationale for providing register-link-to-uri as a primitive of type

string -> point -> length -> length -> length -> length -> color option -> unit

instead of that of type

string -> point -> length -> length -> length -> (length * color) option -> unit?

IMHO the latter would be more natural as an API, since it seems awkward that one can designate non-zero length for the border width and None for the border color at the same time and that the non-zero length will be ignored in such a case. The same situation holds for register-link-to-location.

I would appreciate it if you could give some comment about this.

(It is off topic, but I have tried to extend your implementation for supporting screen annotations and rendition actions so that users can embed movies into PDFs. It currently fails, however, due to the mismatch of what I wanted to write and what camlpdf provides as its high-level interface.)

@matsud224
Copy link
Contributor Author

I totally agree with your suggestion.

due to the mismatch of what I wanted to write and what camlpdf provides as its high-level interface.

Camlpdf 's API is sometimes insufficient, so it may be better to extend camlpdf instead of adding modules to SATySFi. (I actually had to extend camlpdf to implement PDF bookmark support.)

@gfngfn
Copy link
Owner

gfngfn commented Nov 30, 2018

I came upon another question:

Since the evaluation of function applications of the newly introduced primitives (i.e. register-destination, register-link-to-uri, or register-link-to-location) makes sense only during page breaking, it may be desirable to emit some (run-time) error if such applications are evaluated before page breaking starts. Is this kind of modification acceptable to you?

@matsud224
Copy link
Contributor Author

Is this kind of modification acceptable to you?

Yes. It looks good.

I fixed stdja and stdjareport to use hyperlink features.

@gfngfn gfngfn merged commit c5a7adf into gfngfn:master Dec 5, 2018
@gfngfn
Copy link
Owner

gfngfn commented Dec 5, 2018

Finally I merged the PR. Thank you very much for having discussions! (and sorry for letting you patiently wait my response 😢)

@matsud224 matsud224 deleted the dev-hyperlink branch December 5, 2018 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants