Our state of the art Gantt chart


Post by shimnx »

I can successfully export to the local but there is no style in the PDF. How should I configure it

 pdfExport : {
                exportServer : 'https://dev.bryntum.com:8082',

            // Development config
            translateURLsToAbsolute: true,

            // For production replace with this one. See README.md for explanation
            // translateURLsToAbsolute : 'https://localhost:8080/resources/', // Trailing slash is important
            keepPathName : false
        },
Attachments
屏幕截图 2022-05-11 193055.png
屏幕截图 2022-05-11 193055.png (127.82 KiB) Viewed 1123 times

Post by mats »

You should not configure the pdf feature to point to our server, you should follow the instructions in that demo and setup a server in your own network.

# Export demo

This demo shows how to use export to PDF/PNG feature with Gantt.
It includes server which gets HTML from browser and makes PDF/PNG.

Setup

  1. Setup the server

    Server is located in examples/_shared/server

    Navigate to examples/_shared/server/README.md for instructions.
    Usually it should be enough to run:


        cd examples/_shared/server/ && npm i && node ./src/server.js -h 8080 -r /path/to/resources

    where /path/to/resources is the physical path to the root folder which contains styles.
    The path can be either absolute (/path/to/resources) or relative (path/to/resources),
    for example when you start the export server with the export demo locally.
    It is required to correctly load FontAwesome which is used to show icons.


    For example


        const gantt = new Gantt({
            features : {
                pdfExport : {
                    exportServer : 'https://export-host:8080',
                    translateURLsToAbsolute : 'https://export-host:8080/resources'
                }
            }
        })

    where /resources is a virtual path hardcoded in server/WebServer.js implementation.
    Running the server with -r maps the virtual path to the real style's location.
    Just need to copy all the styles and fonts from the https://application-host/ keeping the folder hierarchy.

        # url              : https://application-host/gantt-x.y.z-trial/examples/export
        # path             : /home/www/styles/gantt-x.y.z-trial/examples/export
        # resource path    : /home/www/styles/
        
        # Maps 'https://export-host:8080/resources' to /home/www/styles
        node ./src/server.js -h 8080 -r /home/www/styles

    1. Configure example to use your server

      By default, the example is configured to use localhost:8080 as export host.

    2. Open this example in the browser, press Export and check various export options

    Alternate setup (Docker)

    You can use our Docker image to run the export server. To start the container run:

    examples/_shared/server$ docker-compose up -d --build

    Feature config should be changed too:

    new Gantt({
        features : {
            pdfExport : {
                // Assuming Docker is running locally
                exportServer            : 'https://localhost:8080/',
                // Docker runs in own subnet, it should be able to access global address of the exported page
                translateURLsToAbsolute : 'https://external-address:80/',
                // This is required only if you do not choose to enable CORS on web server.
                // In case your web server provides `Access-Control-Allow-Origin: *` header, this can be omitted.
                clientURL               : 'https://external-address:80/'
            }
        }
    })

    See corresponding section in examples/_shared/server/README.md for more details.


Post by shimnx »

I copied the examples/_shared/server to my project and executed the following command, but failed. I am not good at node.js. What should I do next

Attachments
屏幕截图 2022-05-12 102551.png
屏幕截图 2022-05-12 102551.png (71.71 KiB) Viewed 1116 times
屏幕截图 2022-05-12 102403.png
屏幕截图 2022-05-12 102403.png (320.24 KiB) Viewed 1116 times

Post by alex.l »

In your console log I see "permission denied" error. Try to set up your environment to allow using port 8080, or check if something already uses that port, or try to change port to another one.

In _shared/server/README.md You will find detailed instructions about server setup.

Try to google error message you see in console, it's common problem not related to Bryntum that has a lot of solutions on StackOverflow.

All the best,
Alex


Post by shimnx »

I successfully ran server.js, but there was an error when exporting it

Attachments
屏幕截图 2022-05-12 142529.png
屏幕截图 2022-05-12 142529.png (36.64 KiB) Viewed 1107 times
屏幕截图 2022-05-12 142506.png
屏幕截图 2022-05-12 142506.png (50.94 KiB) Viewed 1107 times
屏幕截图 2022-05-12 142442.png
屏幕截图 2022-05-12 142442.png (15.42 KiB) Viewed 1107 times

Post by shimnx »

msg

Attachments
屏幕截图 2022-05-12 142546.png
屏幕截图 2022-05-12 142546.png (26.14 KiB) Viewed 1105 times

Post by alex.l »

This happens because you use https protocol. I am not sure about your local server setup. You could try to search how to fix "net::ERR_SSL_PROTOCOL_ERROR" error for your environment
or just don't use 'https'.
Here is a good guide about that error: https://aboutssl.org/fix-google-chrome-error-err_ssl_protocol_error/

All the best,
Alex


Post by shimnx »

Thank you I can successfully export now, but I have a question, I started the Node service locally, what if the project is published to the server then


Post by alex.l »

Glad to hear you did it. Then you'll be needed to run server remotely and set URLs accordingly.

All the best,
Alex


Post by shimnx »

Should I publish _shared/server to our own server


Post Reply