shinyscreenshot icon indicating copy to clipboard operation
shinyscreenshot copied to clipboard

discussion: addition of jsPDF to download PDF

Open r2evans opened this issue 2 years ago • 4 comments

Hello, Dean! Have you considered adding the capability to download PDFs in addition to PNGs? The jsPDF javascript library supports this and works with html2canvas.

Links:

  • https://stackoverflow.com/questions/36213275/html2canvas-does-not-render-full-div-only-what-is-visible-on-screen
  • https://phppot.com/javascript/jspdf-html-example/
  • https://stackoverflow.com/questions/26481645/how-to-use-html2canvas-and-jspdf-to-export-to-pdf-in-a-proper-and-simple-way

r2evans avatar Sep 28 '23 13:09 r2evans

I have not considered PDFs before, but I did initially consider allowing choosing different file formats, and I decided against it. The main goal of shinyscreenshot is to allow a way to capture the contents in a saveable format, and I came to the conclusion that the exact format is not as important, because once you have it exported to one format, it's very easy to convert to any other format you want. I did not want shinyscreenshot to get overly complex (both feature bloat-wise and from a code maintenance point of view), which is why I decided to not give an option.

That said, PDF is different enough from image formats so if there is very minimal (and clean) code that can be added which will seamlessly support exporting to PDF instead of PNG, I'd be happy to include it. If it's not simple, I would prefer not to, because I want the focus of this package to remain taking screenshots, not dealing with file formats across devices.

daattali avatar Oct 14 '23 05:10 daattali

@r2evans have you tried to see how much work it would be to create a PDF instead of PNG?

daattali avatar Nov 22 '23 04:11 daattali

Not yet. My initial look determined that it would take a bit more focused effort to see how best to fit it in (both your code base and seeing how the other links worked through it), so I got distracted on other things. I recognize it would be far simpler to you if I came up with PR, I don't know if that's going to happen quickly.

r2evans avatar Nov 29 '23 15:11 r2evans

No rush! I have enough work on other packages to keep busy (and of course, on paid clients too :) ) so if you ever find time to look into it, let me know! It is a nice idea so it would be useful for many people if an elegant solution is found.

daattali avatar Dec 02 '23 07:12 daattali