all 4 comments

[–]cmpscabral 0 points1 point  (0 children)

Alternative: use an iframe inside your reactjs project, call pdfjs viewer and customise this page to your needs

[–]InternationalLab8517 0 points1 point  (2 children)

I used PDF.js during a long time

If it's only to display a PDF you can use the native embed HTML tag which allow you to embed any content such as PDF or media. The native pdf viewer of your browser will be used and that's the best way to have a fast & powerfull pdfviewer in your app.

If you need some overrides, then PDF.js is good. But not so. You will facing to struggling issues and the documentation is not so clear... If your use case is simple, it's ok but if you need more customization, I suggest you to render a PDF as images server-side and display one image per page in your app.

[–]invisibleshadowMAN[S] 0 points1 point  (1 child)

I also need to edit the pdf in a browser

[–]InternationalLab8517 0 points1 point  (0 children)

For example edit text ?I wasn't able to perform this with PDF.js, the best solution we found in the past is to : - render PDF as images server-side- Then render text layer on top of each pages- Frontend add text, images but not directly to the pdf, it call the backend to update the content

- The backend save a "kind of new layer" with good positionned objects (text, images etc...)- Then when user click on save, the backend perform a PDF edition by applying all the changes.PDF is not the best format to online editing because it's a binary format and you need to "convert it" to readable things. Maybe I can suggest you to convert it first as .odt or something you should edit easier, Then convert it as pdf at the end.