question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Export calendar to PDF

See original GitHub issue

Originally reported on Google Code with ID 2036

Hi,

I don't know where is the place to post this tip so i use a new issue.

For my website, I want to export my calendar to pdf. Ther is the way to obtain that
:)

Hope That Help You !

----
1 : download external files

JSPDF : use to generate a PDF file (http://parall.ax/products/jspdf)
html2canvas : use to generate a JPEG file of your #div calendar (http://html2canvas.hertzen.com/)

----
2 : install only the files needed
html2canvas.min.js
jspdf.js
jspdf.plugin.addimage.js

---
3 : now the code :)

3.1 : the pdf button

We add a new button in the header 

$("td.fc-header-left").append('<span id="AE_btn_pdf" class="cal-button"><input type="hidden"
id="zz_pdf" value="" />' + AEFC.translate("Pdf") + '</span>');

3.2 : the code to have a ui like button

   $("#AE_btn_pdf").button({
      icons: {
         primary: "ui-icon-image"
      },
      text: false
   }); // $("#AE_btn_pdf").button(

3.3 : the code to have the pdf... Yes it's very simple but usefull code :)

   $("#AE_btn_pdf").click(function () {
      //#AEFC is my div for FullCalendar
      html2canvas($('#AEFC'), {
         logging: true,
         useCORS: true,
         onrendered: function (canvas) {
            var imgData = canvas.toDataURL("image/jpeg");
            var doc = new jsPDF();      
            doc.addImage(imgData, 'JPEG', 15, 40, 180, 160);
            download(doc.output(), "AEFC.pdf", "text/pdf");                       

         }
      }) ;      
   }); // $("#AE_btn_pdf").click(function ()

--
4 JS : download function

function download(strData, strFileName, strMimeType) {
    var D = document,
        A = arguments,
        a = D.createElement("a"),
        d = A[0],
        n = A[1],
        t = A[2] || "text/plain";

    //build download link:
    a.href = "data:" + strMimeType + "," + escape(strData);

    if (window.MSBlobBuilder) {
        var bb = new MSBlobBuilder();
        bb.append(strData);
        return navigator.msSaveBlob(bb, strFileName);
    } /* end if(window.MSBlobBuilder) */

    if ('download' in a) {
        a.setAttribute("download", n);
        a.innerHTML = "downloading...";
        D.body.appendChild(a);
        setTimeout(function() {
            var e = D.createEvent("MouseEvents");
            e.initMouseEvent("click", true, false, window, 0, 0, 0, 0, 0, false, false,
false, false, 0, null);
            a.dispatchEvent(e);
            D.body.removeChild(a);
        }, 66);
        return true;
    } /* end if('download' in a) */    

    //do iframe dataURL download:
    var f = D.createElement("iframe");
    D.body.appendChild(f);
    f.src = "data:" + (A[2] ? A[2] : "application/octet-stream") + (window.btoa ? ";base64"
: "") + "," + (window.btoa ? window.btoa : escape)(strData);
    setTimeout(function() {
        D.body.removeChild(f);
    }, 333);
    return true;
} /* end download() */

Reported by elecoest on 2013-11-17 17:13:34

Imported with 5 stars.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
arshawcommented, Jun 12, 2016

I declare that this feature is out of the scope of the FullCalendar project. It’s tech stack is sufficiently different from FullCalendar’s where I feel it should be a separate project.

0reactions
Khawer-31commented, May 23, 2022
Hi thanks you for your work, but do you have a solution to convert as a pdf a calendar
but with a scrollbar, because when i use you method it converts only what is display
on the browser screen and not what is hide

Reported by test.logograph on 2014-05-21 12:40:34

Were you able to achieve it? I am facing the same problem with a calendar that has scrollbar

Hi thanks you for your work, but do you have a solution to convert as a pdf a calendar
but with a scrollbar, because when i use you method it converts only what is display
on the browser screen and not what is hide

Reported by test.logograph on 2014-05-21 12:40:34

Were you able to achieve it? I am facing the same problem with a calendar that has scrollbar

Facing the same problem, any luck?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to save Outlook calendar as PDF file? - ExtendOffice
Save a calendar as PDF file in Outlook 2016 · 2. Go ahead to (1) select Microsoft Print to PDF from the Printer...
Read more >
How to Save or Print an Outlook Calendar as PDF - WAMS Inc
3.) From the Printer dropdown list, select the printer in which you want to print the Calendar or select Microsoft Print to PDF...
Read more >
How to Save Outlook Calendar as PDF Document? - SysTools
Manual Approach to Export Outlook Calendar to PDF · Click the drop-down list of Printer option, and then choose Adobe PDF · Select...
Read more >
How to save an Outlook Calendar as PDF or print it
1. If you use several Calendars in you Outlook, open the Calendar view and select the calendar you want to print: ; 2....
Read more >
2 Quick Methods to Export Outlook Calendar to a PDF File
Method 1: Export the Screenshot of Calendar to PDF · Next, you need to select a Windows folder to save the exported PDF...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found