cheese-fork icon indicating copy to clipboard operation
cheese-fork copied to clipboard

Pdf print

Open skilef opened this issue 4 years ago • 8 comments

Export to PDF

Solves Issue #8

Added the ability to export the calendar as a PDF file. The PDF file is being downloaded immediately.

Technical stuff

  • The PDF is created with jsPDF and jsPDF-AutoTable (plugin)
  • The PDF is textual and not an image
  • UTF and RTL support is limited
    • Special Javascript font files are also included for this purpose
    • Text direction was reversed several times
  • I also tried working with other libraries but they had their own problems
    • html2pdf.js actually worked well but it generated an image based PDF (using html2canvas) and the file was really heavy

Visual changes

Top navbar:

Not Logged-In

image image

Logged-In

image

PDF Calendar

image

skilef avatar Oct 17 '20 22:10 skilef

Very nice, thank you for the contribution! It looks good overall, but there are a couple of things to be taken care of before it gets merged.

  • Functionality: I tested it briefly, and the most noticeable issue is that the table is limited to the fixed times of 8:30-17:30 and days of Sunday-Thirsday. CheeseFork supports any time and any day of week. You can see that e.g. with the 394902 course which has several late courses, or by dragging a custom event to a different time or day.

  • User interface: I don't like merging "Share" and "Export" to a single menu. Let's keep "Share" ("שיתוף מערכת") as is, and have an "Export" ("ייצוא") item with two options.

  • Code: I'll leave a couple of minor comments in a moment.

michael-maltsev avatar Oct 21 '20 19:10 michael-maltsev

PDF feature with all fixes

I fixed the things you @michael-maltsev mentioned in the new commits

  • Also now the PDF looks more like the original calendar
  • And the code is better documented
image

skilef avatar Oct 24 '20 13:10 skilef

I forgot to set the column sizes, so please wait with merging

skilef avatar Oct 24 '20 17:10 skilef

All done, you can check it out image

skilef avatar Oct 25 '20 09:10 skilef

Thanks. Issues that I've seen from a quick glance:

  • Text of small events (1/2 hour) is not displayed: image

  • Also, text of larger events (1 hour) is not vertically aligned: image

  • The sharing button is gone, at least when not signed in: image

Also, could you rebase the code on the most resent commit?

michael-maltsev avatar Oct 27 '20 10:10 michael-maltsev

Rebased everything to a single commit and fixed the things you mentioned.

skilef avatar Oct 28 '20 22:10 skilef

I didn't mean squashing the commits, I meant rebasing to update to the recent changes of the repository. Not a big deal, I can do it myself later.

More importantly, there are still issues unfortunately:

  • Overlapping events aren't handled properly:

image

  • English text is reversed. You can see that in the image above as well.

  • A single large event screws up the PDF, example:

image

I didn't spend a lot of time testing it. Please, next time, if possible, play with the solution a bit to see if there are no other things to be done, to save on the ping-pong.

Also, the tooltip from a disabled sharing button is now gone:

image

michael-maltsev avatar Oct 28 '20 23:10 michael-maltsev

Ok, sorry for that, I'll test it properly and next time I hope there won't be problems at all. I will try to cover any possible scenario. Again sorry for the ping pong and for the bad tested code

skilef avatar Oct 28 '20 23:10 skilef