Skip to content

feat: view PDF files inline#31

Merged
sergioramos merged 23 commits into
mainfrom
view-pdf-files-inline
May 30, 2023
Merged

feat: view PDF files inline#31
sergioramos merged 23 commits into
mainfrom
view-pdf-files-inline

Conversation

@sehyod

@sehyod sehyod commented May 24, 2023

Copy link
Copy Markdown
Collaborator

This PR adds a PDF viewer component, as mentioned in #28

To make this PR, I explored https://github.com/allenai/pdf-component-library and the library it's built upon: https://github.com/wojtekmaj/react-pdf.

With pdf-component-library, I wasn't able to properly render a PDF: the best I was able to do was displaying the raw text of the pdf, but all styling would be gone. Moreover, there is no documentation for the library and it doesn't seem maintained anymore (latest commit was in December).

On the other hand, react-pdf's doc looks more exhaustive and the library is still maintained (latest commit is from yesterday). With this library, I was able to properly render PDF files:
image

For these reasons, I have decided to go with react-pdf, although pdf-component-library offers more possibilities, like thumbnails and annotations. I think it's fine to go with react-pdf for the MVP.

@hammer

hammer commented May 25, 2023

Copy link
Copy Markdown
Contributor

@sehyod very cool! This looks to share some commits with #29. In the future, could we break the PRs up so that the drag and drop zone is separate from the PDF viewer? That way PRs are more isolated and it's easier to collaborate and stack PRs from separate developers.

Could you say more about the implementation strategy here? Any issues with library selection or concerns about resource utilization or leakage? I got it running and it looks nice. I was a bit nervous about having this feature now as it's not high priority but it looks simple lightweight and useful so let's keep it!

@sehyod

sehyod commented May 25, 2023

Copy link
Copy Markdown
Collaborator Author

@hammer Thank you! I branched out from the upload-files branch because I thought we would merge it soon afterwards and it was making it easier to test the pdf viewer. I will avoid doing that in the future.

I will write a proper description with explanations about the choices before I mark the PR as ready for review. For now, I have put this PR on hold because I needed to fix the scrolling issue first (#35). Otherwise, only the first page of the pdf files was visible.

@sehyod sehyod marked this pull request as ready for review May 26, 2023 14:01
@sehyod sehyod requested a review from cguedes May 26, 2023 14:01
@cguedes

cguedes commented May 26, 2023

Copy link
Copy Markdown
Collaborator

My first notes about the PR are that:

  • by default the PDF view don't resize the loaded document
  • links inside the document open in the full Tauri view instead of the PDF (or externally in the system browser)

@hammer

hammer commented May 26, 2023

Copy link
Copy Markdown
Contributor

links inside the document

I think the right behavior would be to open a new tab within the application for the linked PDF.

@cguedes cguedes left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added notes as comment before.

Comment thread src/App.tsx Outdated
Comment thread src/App.tsx
Comment thread src/PdfViewer/index.tsx Outdated
Comment thread src/PdfViewer/index.tsx Outdated
Comment thread src/PdfViewer/index.tsx
Comment thread src/PdfViewer/index.tsx
Comment thread src/PdfViewer/index.tsx Outdated
Comment thread src/PdfViewer/index.tsx Outdated

@cguedes cguedes left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added notes as comment before.

@cguedes

cguedes commented May 26, 2023

Copy link
Copy Markdown
Collaborator

links inside the document

I think the right behavior would be to open a new tab within the application for the linked PDF.

Like with an <iframe ...? @hammer

@hammer

hammer commented May 26, 2023

Copy link
Copy Markdown
Contributor

@cguedes no, as in the comments at #1 (comment):

We can then open documents for writing or PDFs for reading in the center in a tabbed configuration

Screenshot from VS Code of 2 tabs:
Screenshot 2023-05-26 at 12 33 58 PM

@cguedes

cguedes commented May 26, 2023

Copy link
Copy Markdown
Collaborator

Sure, in a new tab (maybe in split view).
I mean using an IFrameTab component (implemented with an iframe) as opposed to use an EditorTab or PdfViewTab because the type of content to open is an URL.

@hammer

hammer commented May 26, 2023

Copy link
Copy Markdown
Contributor

Ah I see yeah not sure we want to grow a full web browser! Would it be better to send the user to their OS browser?

@cguedes

cguedes commented May 29, 2023

Copy link
Copy Markdown
Collaborator

@hammer yes, I like that option the most. @sehyod please check how we can have that.

@sehyod

sehyod commented May 30, 2023

Copy link
Copy Markdown
Collaborator Author

Thank you for your comments! I have tackled comments about the code. For the issue with links, I will investigate it but the library we are using simply creates hyperlinks and I'm not sure we can customize this.

Comment thread src/App.tsx
Comment thread src/PdfViewer/index.tsx
@cguedes cguedes self-requested a review May 30, 2023 10:06
@sergioramos sergioramos changed the title View pdf files inline feat: view PDF files inline May 30, 2023
@sergioramos sergioramos merged commit 87281ae into main May 30, 2023
@sergioramos sergioramos deleted the view-pdf-files-inline branch May 30, 2023 11:24
@cguedes cguedes mentioned this pull request Jun 1, 2023
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

Successfully merging this pull request may close these issues.

4 participants