Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make an option to print the entire gantt #206

Open
leCheveuCodeur opened this issue Feb 9, 2024 · 3 comments
Open

Make an option to print the entire gantt #206

leCheveuCodeur opened this issue Feb 9, 2024 · 3 comments
Labels
question Further information is requested

Comments

@leCheveuCodeur
Copy link

Hello,

Do you have a solution that would allow complete printing of the gantt?

Best regards.

@Moxemka
Copy link

Moxemka commented Feb 29, 2024

Hi, You can use html-to-image package.

In case of using React:

  <IconButton //mui button
       color="secondary"
       disabled={isPrintLoading}       
       onClick={() => {
              setIsPrintLoading(true);
              htmlToImage.toPng(contextToPrint.current.current //useRef to div with id gantt-table
                     ).then((dataUrl) =>
                               {                               
                                  download(dataUrl, `${document.title.replace(/ /g, '_')}.jpeg`) //used downloadjs package because im lazy
                               }).then(() => {
                                     setIsPrintLoading(false);
                               }).catch((e) => {
                                       console.error(e);
                                               //handle any errors
                                       setIsPrintLoading(false);
                               })

                              }}>
                                {isPrintLoading ? <Autorenew className="Spin"/> : <Print />} //icons for button
 </IconButton>

@Moxemka
Copy link

Moxemka commented Feb 29, 2024

Forgot to mention to change body overflow to auto and .sg-table-body, .sg-timeline height to 100%

@ANovokmet
Copy link
Owner

@Moxemka thanks for the solution.

I am not sure how should the gantt look printed out completely, you can always render it on a page, set the start, end times, display the rows and print the page itself, but I don't know how would a very long one be printed. Over multiple pages? With row headers appearing on every page? What if there is a lot of rows? I guess you can repeat the render with different parameters on several pages and print each of them.

@ANovokmet ANovokmet added the question Further information is requested label Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants