{"id":18332917,"url":"https://github.com/anychart/export-server","last_synced_at":"2025-04-06T03:34:00.548Z","repository":{"id":34750916,"uuid":"38731512","full_name":"AnyChart/export-server","owner":"AnyChart","description":"Export Server is a Java based server intended for exporting charts in .pdf, .jpg, .png, .svg, .csv, .xslx, .json and .xml formats","archived":false,"fork":false,"pushed_at":"2024-09-24T06:00:26.000Z","size":18147,"stargazers_count":20,"open_issues_count":3,"forks_count":6,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-03-21T16:22:13.567Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://export.anychart.com/status","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AnyChart.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2015-07-08T04:18:40.000Z","updated_at":"2024-09-24T06:00:30.000Z","dependencies_parsed_at":"2024-04-10T08:30:00.552Z","dependency_job_id":"85ef9627-293c-439e-89d1-c5ec4f56380f","html_url":"https://github.com/AnyChart/export-server","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnyChart%2Fexport-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnyChart%2Fexport-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnyChart%2Fexport-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnyChart%2Fexport-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AnyChart","download_url":"https://codeload.github.com/AnyChart/export-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247430838,"owners_count":20937873,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T19:40:37.747Z","updated_at":"2025-04-06T03:33:55.538Z","avatar_url":"https://github.com/AnyChart.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"[\u003cimg src=\"https://cdn.anychart.com/images/logo-transparent-segoe.png?2\" width=\"234px\" alt=\"AnyChart - Robust JavaScript/HTML5 Chart library for any project\"\u003e](https://anychart.com)\n# AnyChart Export Server\n\nAnyChart Export Server is a tool that is helps to export charts to PNG, JPG, PDF, SVG, CSV, Excel, JSON, and XML.\nYou can read the full description in [AnyChart Export Server Documentation](//docs.anychart.com/Common_Settings/Server-side_Rendering).\n\n## Setup \nExport server can use PhantomJS, headless Firefox or headless Chrome/Chromium.\n```\n# use -e or --engine flag to specify browser engine\njava -jar anychart-export.jar cmd -e firefox --script \"var chart = anychart.line([1,2,5]); chart.container('container'); chart.draw();\"\n```\nDefault browser engine is PhantomJS.\n\nIf you need to take a screenshot of a page on the Internet or of a local HTML file, you can just use\nChrome or Firefox in headless mode without AnyChart Export Server. You can read about that\n[headless Chrome documentation](https://developers.google.com/web/updates/2017/04/headless-chrome), for Chrome and in\n[headless Firefox documentation](https://developer.mozilla.org/en-US/Firefox/Headless_mode), for Firefox.\nDon't forget to use `file:///` prefix for rendering local HTML files.\n\n### PhantomJS install\nDownload and install PhantomJS to you PC from the [PhantomJS official site](http://phantomjs.org/download.html).\n\nAdd PhantomJS binary to the [PATH](https://stackoverflow.com/a/14638025).\n\nCheck if it works properly:\n```\n$ phantomjs -v\n2.1.1\n```\n\n### Firefox install\nInstall Firefox browser (version 56.0 and above).\n\nFor Debian-based Linux distros:\n```\n$ sudo apt-get update \u0026\u0026 sudo apt-get install firefox -y\n```\nTo check Firefox version:\n```\n$ firefox -v\nMozilla Firefox 60.0.1\n```\nTo check if the browser works properly:\n```\n$ firefox -headless -screenshot https://developer.mozilla.com\n```\nA screenshot of Mozilla site must appear in your working directory.\n\nInstall `geckodriver`.\nFor Mac, use:\n```\n$ brew install geckodriver\n``` \nIf you use Linux or Windows, you can download it from the [geckodriver official site](https://github.com/mozilla/geckodriver/releases) \n\nAdd it to the [PATH](https://stackoverflow.com/a/14638025).\n\nTo check if it is installed properly, use the next command:\n```\n$ geckodriver --version\ngeckodriver 0.19.1\n```\n\nNow you are ready to lauch the AnyChart Export Server.\n\n### Chrome/Chromium install\nInstall Chrome or Chromium browser (version 60.0 and above).\n\nFor Debian-based Linux distros we suggest to install Chromium:\n```\n$ sudo apt-get update \u0026\u0026 sudo apt-get install chromium-browser -y\n``` \nTo check Chromium version, type:\n```\n$ chromium-browser --version\nChromium 66.0.3359.181 Built on Ubuntu , running on Ubuntu 16.04\n```\nTo check the browser works properly, use:\n```\n$ chromium-browser --headless --no-sandbox --disable-gpu http://google.com   \n```\nA screenshot of the Google site must appear in your working directory.\n\nInstall `chromedriver`.\nFor Mac, use:\n```\n$ brew install chromedriver\n``` \nIf you use Linux or Windows, download it from the [chromedriver official site](https://sites.google.com/a/chromium.org/chromedriver/downloads).\n\nAdd the binary to the [PATH](https://stackoverflow.com/a/14638025).\n\nTo check if it is installed properly, use:\n```\n$ chromedriver -v\nChromeDriver 2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb)\n```\n\nNow you are ready to launch the AnyChart Export Server.\n\n## Requests\nAnyChart Export Server supports the following requests:\n\n| URL       | Type          | Description  |\n| ------------- |:-------------:|------|\n| /status       | GET or POST   | Server status |\n| /png          | POST      |   Export to PNG |\n| /jpg          | POST       |   Export to JPG |\n| /svg          | POST      |    Export to SVG |\n| /pdf | POST      |    Export to PDF|\n| /xml | POST     |    Export to XML |\n| /json |POST     |    Export to JSON |\n| /csv |POST     |    Export to CSV |\n| /xlsx | POST     |    Export to XLSX |\n| /sharing/twitter | POST     |  Twitter Sharing request   |\n| /sharing/twitter_oauth | GET     |    Twitter Sharing OAuth callback |\n| /sharing/twitter_confirm | POST     |    Twitter Sharing posting confirmation |\n\n\nTypical Export and Twitter Sharing request contains the parameters listed below:\n\n| Parameter      | Type         | Default| Description  |\n| ------------- |:-------------:|--|------|\n| data        | **required**   | - |script or SVG that should be transformed into a picture |\n| data-type   | **required**   | - | a field that contains the information about the data, it might be \"script\" or \"svg\"|\n| response-type | **required**  | - | a field that tells how to export the result (file or as base64) |\n| file-name    | optional | anychart |    file name |\n| save       | optional   | - |if it presents, request returns URL of a saved image|\n| container-id     | optional |container| div container id|\n| container-width  | optional |100%| div container width|\n| container-height | optional |100%| div container height|\n| width | optional      | 1024|   image width|\n| height | optional      | 800|   image height|\n| quality | optional      |  1|   picture quality|\n| force-transparent-white | optional   | false | make the background white or leave it transparent|\n| pdf-size | optional | - | the *.pdf-document sheet size|\n| pdf-x | optional | 0| x of the chart in the *.pdf document|\n| pdf-y | optional | 0| y of the chart in the *.pdf document|\n| pdf-width | optional | 595| pdf width|\n| pdf-height | optional |842| pdf height|\n| landscape | optional | false |the document orientation|\n\n## Config file format\nAnyChart Export Server provides an ability to pass all parameters in a config file using [TOML](https://github.com/toml-lang/toml) format:\n\n```\n# can be \"server\" or \"cmd\"\nmode = \"server\"\nengine = \"firefox\"\n\n[server]\nport = 80\nhost = \"0.0.0.0\"\nallow-scripts-executing = false\nlog = \"/path/to/log/file\"\n\n[server.images]\n# folder to save images\nfolder = \"/export-server/shared\"\n# prefix which will be returned when saving image\nprefix = \"http://static.example.com/shared/\"\n\n[server.sharing]\n# MySQL settings\nport = 3306\ndb = \"shared_db\"\nuser = \"export_server_user\"\npassword = \"export_server_password\"\n\n[server.sharing.twitter]\n# settings from twitter app settings for sharing in Twitter\nkey = \"key\"\nsecret = \"secret\"\ncallback = \"http://example.com/sharing/twitter_oauth\"\n\n[cmd] \n# here you can pass cmd options for mode = \"cmd\"\nscript = \"var chart = anychart.line([1,2,5]); chart.container('container'); chart.draw();\" \noutput-file = \"anychart\"\noutput-path = \"\"\ncontainer-width = \"1024px\"\ncontainer-height = \"800px\"\ncontainer-id = \"container\"\ninput-file = \"file.name\"\ntype = \"png\"\nimage-width = 1024\nimage-height = 800\nforce-transparent-white = false\npdf-size = \"a4\"\npdf-x = 0\npdf-y = 0\npdf-width  = 500\npdf-height = 500\njpg-quality = 1\n```\n\nYou can pass a config file with `-C` option, like this:\n\n```\njava -jar export-server.jar -C settings.toml\n ```\n\n## Sharing\nThe AnyChart Export Server provides an ability to share chart images in social networks, such as Facebook,\nLinkedIn, Pinterest and Twitter.\nWhen you use the Export Server on your own server and you want the sharing to work properly, you should set up `--saving-folder` and `--saving-prefix`. The first parameter is the path to the folder where images will be stored. The second parameter is the URL prefix which will be concatenated with a shared image name and returned to a user. You should provide the access to shared image through that URL by setting up Nginx, for example.\n\n### Sharing on Facebook, LinkedIn, and Pinterest\nSharing on Facebook, LinkedIn, and Pinterest is implemented with the help of the commands for saving images. These social networks get the prepared picture via the link and just allow the user to post it on the page.\n\n### Sharing on Twitter\nSharing images on Twitter is implemented with the AnyChart Twitter app. It requires MySQL database to be set up and uses three types of requests.\n\n#### `/sharing/twitter` \nFirst of all, the user sends a request to `/sharing/twitter` that contains SVG or script  from which the image will be generated and posted on the page - the request should contain the same parameters as a request to `/png` URL does.\n\nThere are two options here: the user is authorized in the AnyChart Twitter application or not.\n\nIf the user isn't authorized, the Twitter Authorization dialog will be displayed. The user should confirm that he gives the app the rights to post the image. After that, the user will be redirected to the `/sharing/twitter_oauth` callback.\n\n#### `/sharing/twitter_oauth`\nThis request accepts `oauth_token` and `oauth_verifier` parameters, you can read about [OAuth here](https://en.wikipedia.org/wiki/OAuth).\nIn the handler of /sharing/twitter_oauth request, the Export Server gets such params as oauth_token, oauth_token_secret, user_id, screen_name, image_url (user picture) and user_name and saves them to the MySQL database. After that, the dialog window of posting images will be displayed.\n\nIf the user is already authorized in the app, the posting dialog will be displayed immediately. When the user confirms to post the image and clicks the TWEET button, there will be a request to `/sharing/twitter_confirm `.\n\n#### `/sharing/twitter_confirm`\nThis request should contain Twitter `message` parameter only - a string of no more than 140 characters. In the handler of `/sharing/twitter_confirm` request, the Export Server uploads the shared image with Twitter API and posts a new tweet with that image.\n\nNote: the `/sharing/twitter_oauth` and `/sharing/twitter_confirm` requests are used inside Export server, which means you don't need to send anything by yourself there.\n\nIf you want Twitter sharing to work through your server, you should:\n1. create your own Twitter App and provide `twitter_key`, `twitter_secret` and `twitter_callback` \n(last path of which is always `/sharing/twitter_oauth`) to the Export Server. \n2. setup a MySQL database for Twitter sharing using [SQL scheme](https://github.com/AnyChart/export-server/blob/master/src/sql/scheme.sql).\n3. setup a Twitter sharing URL separately when setting the `anychart.export.server()` URL:\n```javascript\nanychart.exports.twitter(\n    \"http://your.export.server.url/sharing/twitter\", \n    \"1000\",    \n    \"500\"\n);\n```\nFor more details check out [AnyChart Sharing API](http://api.anychart.com/anychart.exports).\n\n## License\n[© AnyChart.com - JavaScript charts](http://www.anychart.com). Export Server released under the [Apache 2.0 License](https://github.com/AnyChart/export-server/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanychart%2Fexport-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanychart%2Fexport-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanychart%2Fexport-server/lists"}