### Quickstart: Generate a Report Source: https://carbone.io/documentation/developer/api-sdks/javascript.html A quick example demonstrating how to initialize the SDK, load a template and data, and render a report. ```APIDOC import carboneSDK from "carbone-sdk-js"; const _carboneService = carboneSDK("YOUR_API_KEY"); const _template = document.getElementById("inputFile").files[0]; let _data = JSON.parse(document.getElementById("inputData").value); _carboneService.render(_template, _data).then(({ content, name }) => { // content is a Blob, name is a string }); ``` -------------------------------- ### Quickstart: Generate a Report with Javascript SDK Source: https://carbone.io/documentation/developer/api-sdks/javascript.html A quickstart example demonstrating how to generate a report using the Carbone Javascript SDK. It requires an API key, a template, and stringified JSON data. ```javascript import carboneSDK from "carbone-sdk-js"; // SDK constructor, the access token have to be passed as an argument to carboneRenderSDK const _carboneService = carboneSDK("eyJhbGc..."); // same as window.carboneSDK("eyJhbGc..."); // Template from a file input OR template ID const _template = document.getElementById("inputFile").files[0]; // Data from an input, for example: {"data" :{"firstname":"John","lastname":"Wick"},"convertTo":"pdf"} let _data = JSON.parse(document.getElementById("inputData").value); // Render the report from an DOCX template and a JSON Data _carboneService.render(_template, _data).then(({ content, name }) => { // name == report name as a String // content == report content as a Blob, it can be used to download the file }); ``` -------------------------------- ### Install Go SDK Source: https://carbone.io/documentation/developer/api-sdks/go.html Install the Carbone Go SDK using the go get command. ```bash go get github.com/carboneio/carbone-sdk-go ``` -------------------------------- ### Generate Report with Python SDK Source: https://carbone.io/documentation/developer/api-sdks/python.html Quickstart example demonstrating how to generate a report. Requires an API key, template path, and JSON data. The report is returned as bytes and a unique name. ```python import carbone_sdk csdk = carbone_sdk.CarboneSDK("ACCESS-TOKEN") template_path = "./path/to/template.odt" json_data = { # Add the data here "data": {} } # Render and return the report as bytes and a unique report name (for example "01EEYYHV0ENQE07JCKW8BD2QRP.odt") report_bytes, unique_report_name = csdk.render(template_path, json_data) # Create the file fd = open(unique_report_name, "wb") fd.write(report_bytes) fd.close() ``` -------------------------------- ### Generate Report with NodeJS SDK Source: https://carbone.io/documentation/developer/api-sdks/nodejs.html Quickstart example to generate a report. Requires your API key, a template file, and data provided as a stringified JSON. The report is streamed to a file. ```javascript const carboneSDK = require('carbone-sdk')('YOUR-API-KEY'); const data = { data: { // Add your data here }, convertTo: 'pdf' } // Create a write stream with the report name as parameter. const writeStream = fs.createWriteStream(path.join(__dirname, 'report.odt')) // Pass the template path as first parameter, in this example 'test.odt' is the template. // Pass the data object as second parameter. const carboneStream = carboneSDK.render(path.join(__dirname, 'test', 'datasets', 'test.odt'), data) carboneStream.on('error', (err) => { console.error(err) }) writeStream.on('close', () => { console.log('File rendered') }) carboneStream.pipe(writeStream) ``` -------------------------------- ### Curl Example for Listing Templates Source: https://carbone.io/documentation/developer/http-api/manage-templates.html A command-line example using curl to make a GET request to the Carbone API to list deployed templates. ```bash __curl --location --request GET 'https://api.carbone.io/templates' \ --header 'carbone-version: 5' \ --header 'Authorization: Bearer API_TOKEN' ``` -------------------------------- ### Generate Report with Java SDK Source: https://carbone.io/documentation/developer/api-sdks/java.html Quickstart example to generate a report using the Carbone Java SDK. Requires API key, template path, and JSON data. Handles potential Carbone and IO exceptions. ```java ICarboneServices carboneServices = CarboneServicesFactory.CARBONE_SERVICES_FACTORY_INSTANCE.create(API_KEY); String json = "{ \"data\": { \"id\": \"AF128\",\"firstname\": \"John\", \"lastname\": \"wick\"},\"reportName\": \"invoice-{d.id}\",\"convertTo\": \"pdf\"}"; /** Generate the document */ try{ CarboneDocument report = carboneServices.render(json ,"/path/to/template.docx"); } catch(CarboneException e) { // handle error System.out.println("Error message : " + e.getMessage() + "Status code : " + e.getHttpStatus()); } // Get the name of the document with the `getName()`. For instance the name of the document, based on the JSON, is: "invoice-AF128.pdf" try (FileOutputStream outputStream = new FileOutputStream(report.getName())) { /** Save the generated document */ outputStream.write(report.getFileContent()); } catch (IOException ioe) { // handle error } ``` -------------------------------- ### Install Carbone Skill for Gemini (CLI) Source: https://carbone.io/documentation/developer/ai/skills.html Install the Carbone skill using the Gemini CLI, either from a local file or directly from GitHub. Use the --scope workspace flag to limit installation to the current project. ```bash __gemini skills install carbone.skill ``` ```bash __gemini skills install https://github.com/carboneio/carbone-skill.git ``` ```bash __gemini skills install carbone.skill --scope workspace ``` -------------------------------- ### Install NodeJS SDK Source: https://carbone.io/documentation/developer/api-sdks/nodejs.html Install the Carbone NodeJS SDK using npm or yarn. ```bash __$ npm i --save carbone-sdk // OR $ yarn add carbone-sdk ``` -------------------------------- ### Constructor Source: https://carbone.io/documentation/developer/api-sdks/php.html Start creating a new instance of the Carbone class and provide your private API key. You can also specify a custom URL for on-premise installations. ```APIDOC ## Constructor Start creating a new instance of the Carbone class and provide your private API key. Get your API key on your Carbone account: https://account.carbone.io/. ```php use Carboneio\SDK\Carbone; $carbone = new Carbone('YOUR_API_KEY'); ``` To use this SDK with Carbone on premise : ```php use Carboneio\SDK\Carbone; $carbone = new Carbone('YOUR_API_KEY', 'https://your_carbone_URL'); ``` ``` -------------------------------- ### Start Docker Compose Stack Source: https://carbone.io/documentation/developer/self-hosted-deployment/deploy-with-docker.html Command to start the services defined in a Docker Compose file. ```bash docker-compose up ``` -------------------------------- ### Install Javascript SDK Source: https://carbone.io/documentation/developer/api-sdks/javascript.html Install the Carbone SDK for Javascript using npm or yarn. ```APIDOC npm install --save carbone-sdk-js yarn add carbone-sdk-js ``` -------------------------------- ### Start Carbone Service Source: https://carbone.io/documentation/developer/self-hosted-deployment/deploy-on-aws.html Use this command to start the Carbone service after completing an upgrade or maintenance on a new instance. ```bash __sudo systemctl start carbone-ee ``` -------------------------------- ### Initialize On-Premise Installation Source: https://carbone.io/documentation/developer/on-premise-installation/plugins.html Steps to set up a new directory for Carbone On-Premise and initialize an npm repository. ```bash # Create a separate folder mkdir carbone-on-premise # Initialize a node repository npm init # Move the carbone binary inside this folder mv /path/to/carbone/binary ./carbone-on-premise ``` -------------------------------- ### Start Carbone Web Server Source: https://carbone.io/documentation/developer/on-premise-installation/install-on-linux.html Starts the Carbone web server with studio mode enabled and specifies the port. Ensure your license is valid and CLI options are correct. ```bash ./carbone-ee webserver --studio -p 4000 ``` -------------------------------- ### List Template Categories Curl Example Source: https://carbone.io/documentation/developer/http-api/manage-templates.html Command-line example using curl to list template categories. Includes necessary headers for authentication and versioning. ```bash __curl --location --request GET 'https://api.carbone.io/templates/categories' \ --header 'carbone-version: 5' \ --header 'Authorization: Bearer API_TOKEN' ``` -------------------------------- ### Install Carbone SDK with npm Source: https://carbone.io/documentation/developer/api-sdks/javascript.html Install the Carbone SDK using npm. This is the first step to integrate Carbone into your Javascript project. ```bash npm install --save carbone-sdk-js ``` -------------------------------- ### Install LibreOffice on Ubuntu/Debian Source: https://carbone.io/documentation/developer/on-premise-installation/install-on-linux.html Installs LibreOffice, a dependency for PDF conversion, on Ubuntu/Debian systems. This includes removing old versions, downloading the correct package, installing dependencies, and optionally installing Microsoft and Chinese fonts. ```bash # remove all old version of LibreOffice sudo apt remove --purge libreoffice* sudo apt autoremove --purge # Download LibreOffice debian package. Select the right one (64-bit or 32-bit) for your OS. # Get the latest from http://download.documentfoundation.org/libreoffice/stable # or download the version currently "carbone-tested": wget https://downloadarchive.documentfoundation.org/libreoffice/old/25.2.6.2/deb/x86_64/LibreOffice_25.2.6.2_Linux_x86-64_deb.tar.gz # Install required dependencies on ubuntu server for LibreOffice 7.0+ sudo apt update sudo apt install libxinerama1 libfontconfig1 libdbus-glib-1-2 libcairo2 libcups2 libglu1-mesa libsm6 libnss3 # Uncompress package tar -zxvf LibreOffice_25.2.6.2_Linux_x86-64_deb.tar.gz cd LibreOffice_25.2.6.2_Linux_x86-64_deb/DEBS # Install LibreOffice sudo dpkg -i *.deb # If you want to use Microsoft fonts in reports, you must install the fonts # Andale Mono, Arial Black, Arial, Comic Sans MS, Courier New, Georgia, Impact, # Times New Roman, Trebuchet, Verdana,Webdings) sudo apt install ttf-mscorefonts-installer # If you want to use special characters, such as chinese ideograms, you must install a font that support them # For example: sudo apt install fonts-wqy-zenhei ``` -------------------------------- ### Configuration File Example Source: https://carbone.io/documentation/developer/on-premise-installation/configuration.html Example JSON structure for the Carbone configuration file (`config.json`). Ensure this file is located in the `config` folder. The `studioUser` format is `login:password` if authentication is enabled. ```json { "port": 4001, "bind": "127.0.0.1", "factories": 4, "attempts": 2, "authentication": true, "studio" : true, "studioUser" : "admin:pass" // login:password if authentication is active } ``` -------------------------------- ### Install Carbone Skill for Vibe (CLI) Source: https://carbone.io/documentation/developer/ai/skills.html Install the Carbone skill by unzipping the skill file into the Vibe skills directory for project-wide or project-specific access. ```bash __unzip carbone.skill -d ~/.vibe/skills/carbone ``` ```bash __unzip carbone.skill -d .vibe/skills/carbone ``` -------------------------------- ### List Template Tags Curl Example Source: https://carbone.io/documentation/developer/http-api/manage-templates.html Command-line example using curl to list template tags. Ensure to include the Authorization and Carbone-Version headers. ```bash __curl --location --request GET 'https://api.carbone.io/templates/tags' \ --header 'Authorization: Bearer API_TOKEN' \ --header 'carbone-version: 5' ``` -------------------------------- ### Install Carbone SDK with yarn Source: https://carbone.io/documentation/developer/api-sdks/javascript.html Install the Carbone SDK using yarn. This provides an alternative package management option for your project. ```bash yarn add carbone-sdk-js ``` -------------------------------- ### Install Carbone Skill for Cursor (CLI) Source: https://carbone.io/documentation/developer/ai/skills.html Install the Carbone skill by unzipping the skill file into the Cursor skills directory for project-wide or project-specific access. ```bash __unzip carbone.skill -d ~/.cursor/skills/carbone ``` ```bash __unzip carbone.skill -d .cursor/skills/carbone ``` -------------------------------- ### Install Carbone CLI Globally Source: https://carbone.io/documentation/developer/embedding/embedding-in-node.html Install the Carbone CLI globally using npm for convenient access to command-line tools. ```bash __ npm install carbone -g ``` -------------------------------- ### Start Carbone On-Premise Webserver on macOS Source: https://carbone.io/documentation/developer/on-premise-installation/install-on-macos.html Start the Carbone web server on macOS. Optionally, set the license environment variable and specify the port. The studio can be accessed via a browser. ```bash __# By default, the program runs with free Community features. export CARBONE_EE_LICENSE="xxxxxxx" ./carbone-ee webserver --studio -p 4000 ``` -------------------------------- ### Install Carbone Skill for OpenAI Codex (CLI) Source: https://carbone.io/documentation/developer/ai/skills.html Install the Carbone skill by unzipping the skill file into the agents skills directory. ```bash __unzip carbone.skill -d ~/.agents/skills/carbone ``` -------------------------------- ### DOCX Barcode Scaling Example Source: https://carbone.io/documentation/design/advanced-features/barcode.html Example of chaining the ':imageFit' formatter to control barcode scaling within a DOCX template. ```text {d.urlQrCode:barcode(qrcode):imageFit(contain)} ``` -------------------------------- ### Install Carbone PHP SDK Source: https://carbone.io/documentation/developer/api-sdks/php.html Install the Carbone PHP SDK using Composer. This is the first step to integrate Carbone into your PHP project. ```bash __composer require carboneio/carbone-sdk-php ``` -------------------------------- ### Install Carbone Python SDK Source: https://carbone.io/documentation/developer/api-sdks/python.html Install the Carbone SDK using pip. This command is used to add the SDK to your project's dependencies. ```bash pip install carbone-sdk ``` -------------------------------- ### Simple Example with bindColor Source: https://carbone.io/documentation/design/advanced-features/colors.html Shows how to use the bindColor tag to replace specific color references in a template with colors defined in the JSON data. This example covers text and background color replacements. ```json { "color": "#FF0000", "color2": "#00FF00", "color3": "#0000FF" } ``` -------------------------------- ### Pass Options via CLI Source: https://carbone.io/documentation/developer/on-premise-installation/configuration.html Example of passing configuration options directly to the Carbone webserver service via the command line. ```bash ./carbone webserver --port 4001 --factories 4 --workdir /var/www/carbone --attempts 2 --authentication --studio ``` -------------------------------- ### Batch Processing API Request Example Source: https://carbone.io/documentation/developer/http-api/generate-reports.html Initiate batch processing by sending a JSON payload to the /render/:templateId endpoint. This example demonstrates setting up data, output format, batch splitting, and output type for generating multiple reports. ```json { "data" : { "letters" : [ { "id" : 1, "name" : "John" }, { "id" : 2, "name" : "David" }, { "id" : 2, "name" : "Steeve" } ] }, // The result will be a ZIP file of multiple PDFs "convertTo" : "pdf", // Batch processing option. "batchSplitBy" : "d.letters", // From v5+, can be "zip" (default), or "pdf" "batchOutput" : "zip" } ``` -------------------------------- ### Run Carbone On-Premise Source: https://carbone.io/documentation/developer/embedding/studio-web-component.html Start the Carbone On-Premise instance with Studio enabled. The API will listen on http://localhost:4000 by default. ```docker docker run -t -i --rm -p 4000:4000 -e CARBONE_STUDIO=true -e CARBONE_DATABASE_NAME="database.sqlite" carbone/carbone-ee:full-5.1.1 ``` -------------------------------- ### Install Carbone Skill for Copilot (CLI) Source: https://carbone.io/documentation/developer/ai/skills.html Install the Carbone skill by unzipping the skill file into the Copilot skills directory for project-wide or project-specific access within VS Code. ```bash __unzip carbone.skill -d ~/.copilot/skills/carbone ``` ```bash __unzip carbone.skill -d .github/skills/carbone ``` -------------------------------- ### Install Carbone Skill for Claude Code (CLI) Source: https://carbone.io/documentation/developer/ai/skills.html Install the Carbone skill using the plugin marketplace or manually by unzipping the skill file into the Claude Code skills directory. ```bash __/plugin marketplace add carboneio/carbone-skill /plugin install carbone@carbone-skill ``` ```bash __unzip carbone.skill -d ~/.claude/skills/carbone ``` ```bash __unzip carbone.skill -d .claude/skills/carbone ``` -------------------------------- ### Carbone Template Tag Example Source: https://carbone.io/documentation/quickstart/getting-started/generate-a-document.html This example shows how to use Carbone tags within a template to insert dynamic data. Ensure your template supports these tags for data merging. ```text Name: {d.firstname} {d.lastname} ``` -------------------------------- ### Install Rust SDK Source: https://carbone.io/documentation/developer/api-sdks/rust.html Add the carbone-sdk-rust dependency to your Cargo.toml file. ```toml [dependencies] carbone-sdk-rust = "1.0.0" ``` -------------------------------- ### Request Header Example Source: https://carbone.io/documentation/developer/http-api/manage-templates.html Include your API token for authorization and optionally specify the Carbone API version. ```json { // Required Your API token (string) "authorization" : "Bearer API_TOKEN", // OPTIONAL Carbone-Version (string) "carbone-version" : "5" } ``` -------------------------------- ### Install Carbone with npm Source: https://carbone.io/documentation/developer/embedding/embedding-in-node.html Add the Carbone package to your Node.js application using npm. ```bash npm install carbone ``` -------------------------------- ### Quickstart: Generate Report with Go SDK Source: https://carbone.io/documentation/developer/api-sdks/go.html Generate a report by providing an API key, template path, and stringified JSON data. The generated report is saved as 'Report.pdf'. ```go package main import ( "io/ioutil" "log" "github.com/carboneio/carbone-sdk-go/carbone" ) func main() { csdk, err := carbone.NewCarboneSDK("YOUR-ACCESS-TOKEN") if err != nil { log.Fatal(err) } // Path to your template templateID := "./folder/template.odt" // Add your data here jsonData := `{"data":{},"convertTo":"pdf"}` reportBuffer, err := csdk.Render(templateID, jsonData) if err != nil { log.Fatal(err) } err = ioutil.WriteFile("Report.pdf", reportBuffer, 0644) if err != nil { log.Fatal(err) } } ``` -------------------------------- ### Verify Carbone MCP Installation Source: https://carbone.io/documentation/developer/ai/mcp.html After configuration, ask your AI tool this question to verify the Carbone MCP server is connected and available. ```text __What Carbone MCP tools are available? ``` -------------------------------- ### Quickstart: Generate Report with Rust SDK Source: https://carbone.io/documentation/developer/api-sdks/rust.html Use this code to render a report by providing your API key, template ID, and JSON data. Ensure you have your API key from your Carbone account. ```rust use std::env; use carbone_sdk_rust::config::Config; use carbone_sdk_rust::carbone::Carbone; use carbone_sdk_rust::types::{ApiJsonToken, JsonData}; use carbone_sdk_rust::template::TemplateId; use carbone_sdk_rust::errors::CarboneError; use std::fs::File; use std::io::Write #[tokio::main] async fn main() -> Result<(), CarboneError> { let token = "Token"; let config: Config = Default::default(); let api_token = ApiJsonToken::new(token.to_string())?; let json_data_value = String::from(r#" { "data" : { "firstname" : "John", "lastname" : "Wick" }, "convertTo" : "odt" } "#); let json_data = JsonData::new(json_data_value)?; let template_id = TemplateId::new("YourTemplateId".to_string())?; let carbone = Carbone::new(&config, Some(&api_token))?; let report_content = match carbone.generate_report_with_template_id(template_id, json_data).await { Ok(v) => v, Err(e) => panic!("{}", e.to_string()) }; let mut output_file = File::create("report.pdf").expect("Failed to create file"); if let Err(e) = output_file.write_all(&report_content) { eprintln!("Failed to write to file: {:?}", e); } Ok(()) } ``` -------------------------------- ### List Available CLI Options Source: https://carbone.io/documentation/developer/on-premise-installation/configuration.html Run the help command to see all available command-line options for the Carbone webserver. ```bash ./carbone webserver --help ``` -------------------------------- ### Carbone SDK Constructor Examples Source: https://carbone.io/documentation/developer/api-sdks/go.html Instantiate the Carbone SDK, either by passing the access token directly or by using the 'CARBONE_TOKEN' environment variable. ```go // Carbone access token passed as parameter csdk, err := carbone.NewCarboneSDK("YOUR-ACCESS-TOKEN") ``` ```go // Carbone access token passed as environment variable "Carbone TOKEN" csdk, err := carbone.NewCarboneSDK() ``` -------------------------------- ### Open Sample Template from URL Source: https://carbone.io/documentation/developer/embedding/studio-web-component.html Quickly open a sample template and its data from a URL for testing purposes. This is useful for quick demonstrations or initial setup. ```javascript studio.openTemplateURL( 'https://carbone.io/examples/awards-simple/template.docx', 'https://carbone.io/examples/awards-simple/data.json' ); ``` -------------------------------- ### Initialize Carbone SDK for On-Premise/AWS Source: https://carbone.io/documentation/developer/api-sdks/java.html Instantiate the Carbone SDK for Carbone On-premise or Carbone On-AWS. First, set the Carbone server URL, then create an instance with an empty string. ```java CarboneServicesFactory.CARBONE_SERVICES_FACTORY_INSTANCE.SetCarboneUrl("ON_PREMISE_URL"); ICarboneServices carboneServices = CarboneServicesFactory.CARBONE_SERVICES_FACTORY_INSTANCE.create(""); ``` -------------------------------- ### Initialize Carbone SDK for On-Premise Source: https://carbone.io/documentation/developer/api-sdks/php.html When using Carbone on-premise, provide your Carbone URL along with your API key during instantiation. ```php use Carboneio\SDK\Carbone; $carbone = new Carbone('YOUR_API_KEY', 'https://your_carbone_URL'); ``` -------------------------------- ### Run Carbone Enterprise Edition with Docker Source: https://carbone.io/documentation/developer/self-hosted-deployment/deploy-with-docker.html Starts a Carbone Enterprise Edition instance with a license and enables the Studio. Ensure you have exported your CARBONE_EE_LICENSE environment variable. ```bash export CARBONE_EE_LICENSE=`MY_CARBONE_LICENSE` docker run -t -i --rm -p 4000:4000 -e CARBONE_EE_LICENSE -e CARBONE_EE_STUDIO=true carbone/carbone-ee ``` -------------------------------- ### Example JWT Token Source: https://carbone.io/documentation/developer/self-hosted-deployment/deploy-on-gcp.html This is an example of a successfully generated JWT token. This token is used in the Authorization header to authenticate API requests. ```text __JWT token successfully generated: eyJhbGciOiJFUzUxMiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJjYXJib25lLXVzZXIiLCJhdWQiOiJjYXJib25lLWVlIiwiZXhwIjozMDA3MDMwMDI3LCJkYXRhIjp7fX0.APGGFckrEy2an51UkAsngpp98lno5c_hMD54ZtnxjXQaM6ScMSCuOZZUT7Z_iGaHh2pM-3ki86wkglWV6NxS1JDEAfVE8EYdMp5qEUt9GQP1RAoLfmYCBdqR7bLTZiqAKfyWZREB6NHWajltwtoqelH7kitPa7kq7jhNW3xqcr-siRjF ``` -------------------------------- ### Initialize Carbone SDK for Cloud Source: https://carbone.io/documentation/developer/api-sdks/java.html Instantiate the Carbone SDK for Carbone Cloud by providing your API Access Token. ```java ICarboneServices carboneServices = CarboneServicesFactory.CARBONE_SERVICES_FACTORY_INSTANCE.create("API_TOKEN"); ``` -------------------------------- ### Example JWT ES512 Key Pair Source: https://carbone.io/documentation/developer/self-hosted-deployment/deploy-on-gcp.html This is an example of the JWT ES512 key pair generated by the `generate-keys` command, shown in PEM format. ```text __JWT ES512 Key pair successfully generated (PEM format): -----BEGIN PRIVATE KEY----- MIHuAgEAMBAGByqGSM49AgEGBSuBBAAjBIHWMIHTAgEBBEIA0T65bCLNUerJEuiy 2rQzp7o9U/RYz6OOj4XhlKJKYUtdiPsARUhkzEwdbEWrZgZrFzXeET15topVwJJx 4QTvPRihgYkDgYYABAEQXmamk+cSkvll4ap3O2qxvIsWfw4ZwcK3f7N2LDG/KvZ0 AInWnQQk/Dl3iA+vHTxTpWqrFb3K6k0I/CW0n2FFrAGgdt/92NfW7K3ywZRsBgBa AmcRqFaHVyjwTIvSFfzBpwWd2oXdAued9WioSV5apRSoRfTsEK87LVO0CpM3ajr/ nA== -----END PRIVATE KEY----- -----BEGIN PUBLIC KEY----- MIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQBEF5mppPnEpL5ZeGqdztqsbyLFn8O GcHCt3+zdiwxvyr2dACJ1p0EJPw5d4gPrx08U6VqqxW9yupNCPwltJ9hRawBoHbf /djX1uyt8sGUbAYAWgJnEahWh1co8EyL0hX8wacFndqF3QLnnfVoqEleWqUUqEX0 7BCvOy1TtAqTN2o6/5w= -----END PUBLIC KEY----- ``` -------------------------------- ### Initialize Carbone SDK with API Key Source: https://carbone.io/documentation/developer/api-sdks/php.html Instantiate the Carbone class with your private API key. Obtain your API key from your Carbone account settings. ```php use Carboneio\SDK\Carbone; $carbone = new Carbone('YOUR_API_KEY'); ``` -------------------------------- ### Open Template from URL with Sample Data Source: https://carbone.io/documentation/developer/embedding/studio-web-component.html Open a template from a specified URL and optionally include a sample data URL. This is useful for loading examples from external sources like the Carbone.io website or other origins. The sample data must be in a specific JSON structure. ```javascript /** * Open a template from a template URL and a sample data URL. * * Useful for opening examples from the Carbone.io website or from any other source. * * @param {String} templateURL External template URL * @param {String} [sampleDataURL] Optional sample data URL (ignored if null). * Must be a JSON file with this structure * [{ * data: object|array, * complement: object|array, * enum: object, * translations: object * }] * @param {Object} [defaultTemplateAttributes] Optional default template attributes * { * name : String, * comment : String, Visible in UI ('Template file' by default) * createdAt : Number (Unix timestamp), Visible in UI (default: now) * tags : Array of strings, * category : String, * origin : Number (0: API, 1: studio) * } */ function openTemplateURL(templateURL, sampleDataURL, defaultTemplateAttributes = { comment: 'Template file' }) ``` -------------------------------- ### Alias Preprocessing Example Source: https://carbone.io/documentation/design/substitutions/aliases.html Aliases act as a preprocessor. Carbone replaces the alias with its definition before processing the template. This example shows a supported use case. ```plaintext Alias | Template | What Carbone Sees | Result ---|---|---|--- `d.obj` | `{d.val:mul($alias.qty)}` | `{d.val:mul(d.obj.qty)}` | OK ``` -------------------------------- ### Current Iterator Lookup Example Source: https://carbone.io/documentation/design/repetitions/lookup.html This example retrieves a `name` from `otherTable` using the current loop's index, ensuring data is matched based on position. ```template {d.movies[i].id:print(..otherTable[.i].name)} ``` -------------------------------- ### Generate and Install Systemd Service Source: https://carbone.io/documentation/developer/on-premise-installation/install-on-linux.html Generates and installs systemd service scripts for Carbone On-Premise on Ubuntu or Debian systems. This allows the service to run automatically at startup. ```bash # Generate installation scripts ./carbone install # Execute installation scripts and follow instructions sudo ./install.sh ``` -------------------------------- ### Initialize CarboneSDK with Access Token Source: https://carbone.io/documentation/developer/api-sdks/python.html Instantiate the CarboneSDK by passing the access token directly to the constructor. ```python import carbone_sdk # Carbone access token passed as parameter csdk = carbone_sdk.CarboneSDK("ACCESS-TOKEN") ``` -------------------------------- ### Install Specific LibreOffice Version in Carbone Docker Image Source: https://carbone.io/documentation/developer/on-premise-installation/container-customization.html Dockerfile to install a specific LibreOffice version (e.g., 7.6.7.2) into a Carbone container based on the slim image. ```docker FROM debian:stable-slim AS downloader ADD https://downloadarchive.documentfoundation.org/libreoffice/old/7.6.7.2/deb/x86_64/LibreOffice_7.6.7.2_Linux_x86-64_deb.tar.gz /libreoffice.tar.gz FROM carbone/carbone-ee:slim USER root RUN apt update && apt install -y libnss3 libxinerama1 libdbus-glib-1-2 cairo2 libcups2 openssl RUN --mount=type=bind,from=downloader,target=/tmp/libreoffice.tar.gz,source=libreoffice.tar.gz tar -zxf /tmp/libreoffice.tar.gz && dpkg -i LibreOffice*_Linux_*_deb/DEBS/*.deb && rm -r LibreOffice* USER carbone ENTRYPOINT ["./docker-entrypoint.sh"] CMD ["webserver"] ``` -------------------------------- ### Initialize CarboneSDK with Environment Variable Source: https://carbone.io/documentation/developer/api-sdks/python.html Instantiate the CarboneSDK without arguments, using the CARBONE_TOKEN environment variable. ```python import carbone_sdk # Carbone access token passed as environment variable "CARBONE_TOKEN" csdk = carbone_sdk.CarboneSDK() ``` -------------------------------- ### Carbone Conditional Section - Hide Example Source: https://carbone.io/documentation/design/template-formats/markdown.html Use :hideBegin/:hideEnd to conditionally remove entire sections of content. This example hides a welcome message if the 'name' field is empty. ```markdown ## Dashboard{d.name:ifEM:hideBegin} Welcome, **{d.name}**! {d.name:ifEM:hideEnd} ``` -------------------------------- ### Carbone Conditional Section - Show Example Source: https://carbone.io/documentation/design/template-formats/markdown.html Use :showBegin/:showEnd to conditionally display entire sections of content. This example hides a details section unless 'showDetails' is true. ```markdown Product: {d.product}{d.showDetails:ifEQ(true):showBegin} ## Details- Feature 1 - Feature 2{d.showDetails:ifEQ(true):showEnd} Thank you for using Carbone! ``` -------------------------------- ### Carbone Implicit Loop Example Source: https://carbone.io/documentation/design/template-formats/markdown.html Carbone uses implicit tags for loops, eliminating the need for keywords like 'for' or 'foreach'. This example shows iterating over a user list. ```markdown # User List| ID | Name | Role | | -- | ---- | ---- | | {d.users[i].id} | {d.users[i].name} | {d.users[i].role} | | {d.users[i+1]} | | | ``` ```markdown # User List| ID | Name | Role | | -- | ---- | ---- | | 1 | Alice | Admin | | 2 | Bob | Editor | | 3 | Charlie | Viewer | ``` -------------------------------- ### Distinct Items Example Source: https://carbone.io/documentation/design/repetitions/distinct.html Use a custom iterator to select distinct rows based on attribute values. This example demonstrates filtering for distinct 'brand' values within 'type'. ```json [ { "type": "car" , "brand": "Hyundai" }, { "type": "plane", "brand": "Airbus" }, { "type": "plane", "brand": "Boeing" }, { "type": "car" , "brand": "Toyota" } ] ``` ```template Vehicles{d[type].brand}{d[type+1].brand} ``` ```result VehiclesHyundaiAirbus ``` -------------------------------- ### Initialize SDK with API Key Source: https://carbone.io/documentation/developer/api-sdks/nodejs.html Initialize the Carbone SDK by providing your API key. This key can be found in your Carbone Account under the API access menu. ```javascript const carboneSDK = require('carbone-sdk')('YOUR-API-KEY') ``` -------------------------------- ### Run Single Carbone Instance with Docker Source: https://carbone.io/documentation/developer/self-hosted-deployment/deploy-with-docker.html Starts a single Carbone Enterprise Edition container, mapping ports, setting environment variables, and binding the local './template' folder to the container's '/app/template' for persistence. ```bash __docker run -t -i --rm -p 4000:4000 -e CARBONE_EE_LICENSE -e CARBONE_EE_STUDIO=true -volume ./template:/app/template carbone/carbone-ee ``` -------------------------------- ### Curl Example for Downloading a Template Source: https://carbone.io/documentation/developer/http-api/manage-templates.html Use this curl command to download a specific template by its ID. Ensure you replace `TEMPLATE_ID`, `API_TOKEN`, and `FILENAME.docx` with your actual values. The `-o` flag specifies the output filename. ```bash __curl --location --request GET 'https://api.carbone.io/template/TEMPLATE_ID' \ --header 'carbone-version: 5' \ --header 'Authorization: Bearer API_TOKEN' \ -o 'FILENAME.docx' ``` -------------------------------- ### Serve HTML Page Locally Source: https://carbone.io/documentation/developer/embedding/studio-web-component.html Start a simple Python HTTP server to serve the HTML page. This is required to access the Carbone Studio Web Component in your browser. ```shell # On Linux or MacOS python3 -m http.server 8000 # Or on Windows (Command Prompt or PowerShell) py -m http.server 8000 ``` -------------------------------- ### Drop Paragraph Example in HTML Source: https://carbone.io/documentation/design/template-formats/html.html Conditionally drop HTML paragraphs using the ':drop(p)' formatter. This example demonstrates dropping paragraphs if a text field is empty, affecting subsequent paragraphs as well. ```html
{d.text}{d.text:ifEM:drop(p, 2)}This paragraph and the next one will be dropped if 'text' is empty.
This paragraph will also be dropped.
This paragraph will remain.
``` -------------------------------- ### Carbone SDK Constructor Source: https://carbone.io/documentation/developer/api-sdks/java.html Initializes the Carbone SDK. For Carbone Cloud, provide your API token. For on-premise or AWS deployments, set the Carbone URL and then create an instance with an empty string. ```APIDOC ## Carbone SDK Constructor **Definition** ```java public CarboneServicesFactory.CARBONE_SERVICES_FACTORY_INSTANCE.create(String... config); ``` **Example** Example of a new SDK instance for Carbone Cloud: Get your API key on your Carbone account: https://account.carbone.io/. ```java // For Carbone Cloud, provide your API Access Token as first argument: ICarboneServices carboneServices = CarboneServicesFactory.CARBONE_SERVICES_FACTORY_INSTANCE.create("API_TOKEN"); ``` Example of a new SDK instance for Carbone On-premise or Carbone On-AWS: ```java // Define the URL of your Carbone On-premise Server or AWS EC2 URL: CarboneServicesFactory.CARBONE_SERVICES_FACTORY_INSTANCE.SetCarboneUrl("ON_PREMISE_URL"); // Then get a new instance by providing an empty string to the "create" function: ICarboneServices carboneServices = CarboneServicesFactory.CARBONE_SERVICES_FACTORY_INSTANCE.create(""); ``` ``` -------------------------------- ### HTML Nospace Example Source: https://carbone.io/documentation/design/advanced-features/html.html Demonstrates the 'nospace' option for the HTML formatter, which removes extra spacing after injected HTML content. This example shows how descriptions with HTML tags are rendered without additional paragraph breaks. ```data { "name" : 'Banana', "description" : 'is an elongated, edible fruit
' } ``` ```template The famous fruit {d.name} {d.description:html(nospace)}, botanically a berry. ``` -------------------------------- ### Lookup Example: Movie and Actor Data Source: https://carbone.io/documentation/design/repetitions/lookup.html This example demonstrates joining movie data with actor data to display the actor's first name for each movie. It uses an equality lookup to match `actorId` from movies with `id` from actors. ```json { "movies": [ { "actorId" : 10, "name" : "Matrix" }, { "actorId" : 20, "name" : "Babylon" }, { "actorId" : 10, "name" : "John Wick" } ], "actors": [ { "id" : 10, "firstName" : "Keanu" }, { "id" : 20, "firstName" : "Margot" } ] } ``` ```template Movie NameMain Actor {o.preReleaseFeatureIn=5002000}{d.movies[i].name}{d.movies[i].actorId:print(..actors[id=.actorId].firstName)}{d.movies[i+1].name} ``` ```template Movie NameMain Actor MatrixKeanuBabylonMargotJohn WickKeanu ``` -------------------------------- ### Deploy Carbone Sample Deployment Source: https://carbone.io/documentation/developer/self-hosted-deployment/deploy-on-kubernetes.html Apply the Carbone deployment configuration to your Kubernetes cluster. ```bash kubectl apply -f carbone-simple-deployment.yaml ``` -------------------------------- ### Get API Status Source: https://carbone.io/documentation/developer/api-sdks/php.html Retrieve the current status of the Carbone API. ```APIDOC ## Get API Status ```php $response = $carbone->getStatus(); $json = $response->json(); echo "Status : " . $response->status() . "\n"; echo "Success: " . $json['success'] . "\n"; echo "Version: " . $json['version'] . "\n"; echo "Message: " . $json['message'] . "\n"; ``` ```