{"id":16190127,"url":"https://github.com/luggage66/jsx-xsl-fo","last_synced_at":"2025-03-19T03:30:53.724Z","repository":{"id":57286606,"uuid":"57452082","full_name":"luggage66/jsx-xsl-fo","owner":"luggage66","description":"Build XSL-FO with a React-like API and JSX","archived":false,"fork":false,"pushed_at":"2023-09-09T00:24:24.000Z","size":443,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-07T13:42:28.705Z","etag":null,"topics":["fop","jsx","pdf-generation","react","xsl-fo"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luggage66.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2016-04-30T16:41:45.000Z","updated_at":"2023-12-20T18:40:04.000Z","dependencies_parsed_at":"2023-09-24T17:57:20.720Z","dependency_job_id":"4f40d179-e29d-449d-88b3-d336c111eccf","html_url":"https://github.com/luggage66/jsx-xsl-fo","commit_stats":{"total_commits":46,"total_committers":2,"mean_commits":23.0,"dds":"0.26086956521739135","last_synced_commit":"c6ee9e3095aa99d14f56736b79311238bb3230fb"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luggage66%2Fjsx-xsl-fo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luggage66%2Fjsx-xsl-fo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luggage66%2Fjsx-xsl-fo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luggage66%2Fjsx-xsl-fo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luggage66","download_url":"https://codeload.github.com/luggage66/jsx-xsl-fo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243965775,"owners_count":20375917,"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":["fop","jsx","pdf-generation","react","xsl-fo"],"created_at":"2024-10-10T07:38:43.079Z","updated_at":"2025-03-19T03:30:53.451Z","avatar_url":"https://github.com/luggage66.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Create your XSL-FO documents and reports in modern JavaScript (w/types)\n\n## Usage\n\nThis library produces XML output in the [XSL FO](https://www.w3.org/TR/xsl11/) format. You then need to pass that through an FO render (e.g. [Apache FOP](https://xmlgraphics.apache.org/fop/)) ([Github](https://github.com/apache/xmlgraphics-fop)) to generate a PDF.\n\nIn this example the .fo output from this library is fed into `fop` to generate a PDF:\n\n```sh\nnode ./my-report.js | fop -fo - -pdf output.pdf\n```\n\n### Minimal Example\n\nMore examples are available at [./packages/examples](./packages/examples/README.md)\n\n```jsx\nimport { renderToStream } from \"@jsx-xsl-fo/core\";\n\nrenderToStream(\n    \u003croot xmlns:fo=\"http://www.w3.org/1999/XSL/Format\"\u003e\n        \u003clayoutMasterSet\u003e\n            \u003csimplePageMaster masterName=\"my_page\"\u003e\n                \u003cregionBody /\u003e\n            \u003c/simplePageMaster\u003e\n        \u003c/layoutMasterSet\u003e\n        \u003cpageSequence masterReference=\"my_page\"\u003e\n            \u003cflow flowName=\"xsl-region-body\"\u003e\n                \u003cblock\u003eHello World!\u003c/block\u003e\n            \u003c/flow\u003e\n        \u003c/pageSequence\u003e\n    \u003c/root\u003e,\n    process.stdout\n);\n```\n\n### Using high level components\n\nThere are some helper components to handle basic page structure\n\n```jsx\nimport { renderToStream } from \"@jsx-xsl-fo/core\";\nimport { Report, PageSequence, PageContent, PageHeader, PageFooter } from 'jsx-xsl-fo/reporting';\n\nrenderToStream(\n    \u003cReport\u003e\n        \u003cPageSequence\u003e\n            \u003cPageHeader\u003e\n                \u003cblock\u003epage \u003cpageNumber /\u003e\u003c/block\u003e\n            \u003c/PageHeader\u003e\n            \u003cPageContent\u003e\n                \u003cblock\u003eHello World\u003c/block\u003e\n            \u003c/PageContent\u003e\n        \u003c/PageSequence\u003e\n    \u003c/Report\u003e,\n    process.stdout\n);\n```\n\n### Custom Components\n\nYou can make your own components similar to React and other JSX libraries.\n\n\n```jsx\n// function components\nfunction Greeting({ firstName, lastName }) {\n    return \u003cblock\u003eGreetings, {firstName} {lastName}!\u003c/block\u003e;\n}\n\n// class components\nclass GoodBye extends Component {\n    render() {\n        return \u003cblock\u003e\n            So long, \u003cinline font-weight=\"bold\"\u003e{this.props.children}\u003c/inline\u003e\n        \u003c/block\u003e;\n    }\n}\n\n// and build more complex documents with them\nlet myBlock = \u003cblock\u003e\n    \u003cGreeting firstName=\"Bob\" lastName=\"Smith\" /\u003e\n    \u003cGoodBye\u003eBob\u003c/GoodBye\u003e\n\u003c/block\u003e;\n```\n\n### API\n\n```jsx\nimport { renderToStream, renderToString } from \"@jsx-xsl-fo/core\";\n// as a string (probably not good for large documents)\nlet aString = renderToString(\u003cFoo /\u003e);\n\n// to a stream.\nrenderToStream(\u003cFoo /\u003e, process.stdout);\n```\n\n### dangerouslySetInnerXML\n\nIf you need to embed some other xml (e.g. SVG) use `dangerouslySetInnerXML`.\n\n```js\n\u003cinstream-foreign-object dangerouslySetInnerXML={{__xml: logoLarge}}\u003e\n\u003c/instream-foreign-object\u003e\n```\n\n## Configuration\n\nThis library works as a jsx runtime compatible with Babel's `jsxImportSource` and TypeScript's `jsxImportSource`\n\n### TypeScript `tsconfig.json`\n\n```json\n{\n    \"compilerOptions\": {\n        \"jsx\": \"react-jsx\",\n        \"jsxImportSource\": \"@jsx-xsl-fo/core\",\n    }\n}\n```\n\n### Babel/TypeScript Comments:\n\n```js\n/** @jsxImportSource custom-jsx-library */\n\nconst foo = \u003cblock\u003eHello\u003c/block\u003e;\n```\n\n## Development\n\n### Prerequisites:\n\n* Node.js 18+ (earlier may work but untested)\n* pnpm\n\n### Building:\n\n```sh\npnpm install\npnpm run -r build\n\n# run tests\npnpm run -r test\n```\n\n### Project Organization\n\n* `packages/core` - The main library. This gets published to NPM\n* `packages/cli` - A CLI tool for converting older files to the current version of jxs-xsl-fo\n* `packages/examples` - Example uses of the main library\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluggage66%2Fjsx-xsl-fo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluggage66%2Fjsx-xsl-fo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluggage66%2Fjsx-xsl-fo/lists"}