Achieving Title Alignment in PDF Export with Balkan OrgChartJS

function preview() {
    /*centerElement();*/
    let fileNameWithTitle = MyTitle.replace(/\s+/g, '_');
    let PdfTitle = "<center>" + MyTitle + "</center>";
    OrgChart.pdfPrevUI.show(chart, {
        format: 'A4',
        landscape: true,
        padding: 50,
        header: PdfTitle,
        filename: fileNameWithTitle += "_OrgChart.pdf"
    });
}

Here is the code snippet used to preview the PDF before exporting. An attempt was made to center the element by embedding the <center> tag within the title itself, but this did not yield the desired result due to the actual placement of the header inside a <h3> tag as shown below:

<div id="boc-header" style="color: rgb(117, 117, 117); position: absolute; left: 40px; top: -15px;"><h3 style="display: flex; justify-content: center; align-item: center;">Division Organization Chart</h3></div>

Attempts to target the <div> with id boc-header were unsuccessful as it only centered on the website display, whereas during export (which occurs on the Balkan server), the title remained positioned at the left side.

If you're curious about how the id boc-header was targeted, see the CSS styles below:

<style id="myStyles">
    @import url("https://fonts.googleapis.com/css?family=Gochi+Hand");

    .node {
        font-family: Arial;
    }

    boc-header {
        color: rgb(117, 117, 117) !important;
        position: absolute !important;
        left: 50% !important;
        top: 15px !important;
        transform: translateX(-50%) !important;
    }

    .node.HR rect {
        fill: #E99113;
    }
    .node.HR line {
        stroke: #E99113;
    }
</style>

chart.on('exportstart', function (sender, args) {
    args.styles += document.getElementById('myStyles').outerHTML;
});

It seems unlikely that centering the title using CSS will reflect in the exported result. Manipulating the title itself may be the only viable option for achieving the desired alignment in the output.

Thank you for considering these details.

All relevant information has been provided above.

Answer №1

Take a look at this code snippet:

<!--HTML-->
<script src="https://balkan.app/js/OrgChart.js"></script>
<style id="myStyles">#boc-header, #bg-header {text-align: center;}</style>
<div id="tree"/>
 

See the outcome here: https://i.sstatic.net/XIbee7Dc.png

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The charts created using chartjs-vue display no data

After following some examples to create a test chart, I am facing an issue where the chart renders blank with dummy data. https://i.sstatic.net/RD77S.png My initial suspicion is that maybe the options are not being passed for the lines, but it seems like ...

Incorporate a PHP-generated array into JavaScript

I'm currently working on implementing a JavaScript slideshow on my index page. Rather than having a static array, I'd like to dynamically build the array using PHP and then include it in the script. However, I'm not sure how to go about this ...

Any suggestions on how to secure my socket connection following user authentication in redux?

After onSubmit, userAction.login is called which then dispatches "SUCCESS_AUTHENTICATE" to set the token of the user and socket state in their respective reducers. How can I proceed to trigger socket.emit("authenticate", {token})? ...

Discover the art of concurrently listening to both an event and a timer in JavaScript

Upon loading the page, a timer with an unpredictable duration initiates. I aim to activate certain actions when the countdown ends and the user presses a button. Note: The action will only commence if both conditions are met simultaneously. Note 2: To cl ...

"Encountering a mysterious internal server error 500 in Express JS without any apparent issues in

My express.js routes keep giving me an internal server error 500, and I have tried to console log the variables but nothing is showing up. Here are the express routes: submitStar() { this.app.post("/submitstar", async (req, res) => { ...

Symfony 4 Forms: Enhancing User Experience with Prototypes

Recently, I've delved into Symfony 4 and encountered an issue with rendering a form featuring a ChoiceType Field with numeric choices. The goal is to allow the user to select a specific number of tags. Here's a snippet from my controller: class ...

Ensuring Uniform Column Height in Bootstrap 4 - Preventing Buttons from Being Forced to the Bottom of

Using the Bootstrap 4 class 'h-100' to ensure equal height for all three columns, I encountered an issue where the buttons that were initially aligned to the bottom of each div are no longer in correct alignment. How can I maintain button alignme ...

Images stored locally are not appearing in React JS applications

I'm currently exploring React JS and Material UI to develop a dynamic web application. I'm attempting to link a local image using 'url(${process.env.PUBLIC_URL})' but unfortunately, the image is not showing up for some unknown reason. ...

In JavaScript, when all values are false in an object, the object's value should be set to False

My task involves working with a JSON data object that contains multiple key-value pairs. I need to determine whether at least one value is false and set another variable to "false" accordingly. Here is the JSON data that I am handling: var objectVal = re ...

Tips for utilizing vulnerable web scripts on SSL-enabled pages

After implementing SSL to secure my pages, I encountered an issue where one of my scripts no longer functions properly. Specifically, I had a script on my page that was used to display the visit count from this website. Previously, it was functioning fla ...

What steps can be taken to fix the recurring node error "EADDRINUSE"?

Having trouble running an http server through node as I keep encountering the EADDRINUSE error specifically on port 5000. I've attempted using sudo lsof -i tcp:5000 and sudo kill -9 [PID]. Here's a snippet of the shell command: Borealis:BackEnd g ...

Apply a Fade In transition to the ul li elements following a JavaScript toggle

I'm currently experimenting with implementing a Fade in from the right animation for the links displayed in the menu after toggling the menu body in the browser. Despite my efforts, I am unable to determine why the animation is not functioning as expe ...

Numerous covert fields within HTML

I am currently working on a popup dialog box where I need to include a set of values in hidden format. However, when I retrieve the value through AJAX post, only the last value is returned. In my PHP code snippet: $plan_ids=array(); foreach($test_plan as ...

Error alert: The $ symbol is not defined

I followed a tutorial to create an auto-advancing slideshow in JavaScript/jQuery and it worked perfectly on jsfiddle. However, when I transferred everything to Dreamweaver, it stopped functioning. I have triple-checked that all the necessary files are link ...

Triangle-shaped border image with a gradient pattern

How can I create an odd-shaped triangle using CSS? Initially, I used transparent borders with transform: rotate to achieve the left triangle shape successfully. However, I am now attempting to use a gradient border image pattern as the background for the s ...

Is it possible to integrate a Backbone app as a component within a separate app?

I am currently in the process of familiarizing myself with Backbone.js and front-end development, as my background is more focused on back-end development. I have a question related to composition. Imagine that I need to create a reusable component, like ...

Issue with React application and nginx configuration causing components not to switch when using router functionality

I have encountered an issue while trying to deploy my React app using nginx. The problem I am facing is that when I change routes, for example to /about, the front end does not update and remains on the index page. Here is the configuration in sites-avai ...

Guide on linking Influxdb information in a Vue application using node.js?

I have successfully connected my InfluxDB database to my Vue app and can log data in the terminal using the code below: // index.js import express from "express"; // These lines make "require" available import { createRequire ...

What is the best method to reset values in ngx-bootstrap date picker?

At the moment, it is only accepting the most recently selected values. To see a live demo, click here. ...

Issue with custom video plugin functionality on Internet Explorer browser

I designed a custom video plugin that allows me to use shortcodes for videos with a unique format. I implemented a code snippet from jsfiddle to create a prominent play button, which functions smoothly across all browsers except for Internet Explorer. Desp ...