Exporting Diagram as image with HTML nodes

Hi

I used this article as a base to create my sample:  How To export base64 Image with diagram size using blink rendering in Vue Diagram using MVC?

In my client side I create the model:

const htmlData = this.diagramInstance.getDiagramContent([fullUrl]);
            const diagramDiv = document.getElementById("diagram_diagramLayer");
            const contentWidth = diagramDiv.getBoundingClientRect().width;
            const contentHeight = diagramDiv.getBoundingClientRect().height;
            const model = new DesignerImageModel({
                versionId: this.currentProcessTemplateVersionId,
                designerImageData: htmlData as string,
                width: contentWidth,
                height: contentHeight,
                css: designerCssContent,
            });
            await Api.workboard.saveDesignerImage(model);


At API I store it as base64:

HtmlToPdfConverter converter = new HtmlToPdfConverter(HtmlRenderingEngine.Blink);
BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings();
blinkConverterSettings.ViewPortSize = new Syncfusion.Drawing.Size((int)Math.Round(model.Width), (int)Math.Round(model.Height));
blinkConverterSettings.Css = model.Css;
converter.ConverterSettings = blinkConverterSettings;
Syncfusion.Drawing.Image doc = converter.ConvertToImage(model.DesignerImageData, "");
MemoryStream stream = new MemoryStream();
byte[] imageByte = doc.ImageData;
processTemplateVesion.DiagramImage = imageByte;
return await UpdateInternalAsync(processTemplateVesion, messageList, userId);

My diagram looks like:
Image_6939_1766151897565
But after saving image the result is:
Image_6195_1766151949033
My nodes html content is:

<div class="designer-node shadow-node" style="background:white; cursor: pointer;">
                    <div class="panel">
                        <div class="row">
                            <div class="col-auto" style="background:${color}; color:white;">
                                <i class="${icon} fa-fw"></i>
                            </div>
                            <div class="col" style="background:#f2f4f8;">
                                <div class="text-center">
                                <span>${annotation}</span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>`;


As you can see, the first round node looks ok, but the rest have broken the styling, even if I pass the appropriate Css in my model, and apply it to blinkConverterSettings, I also tried to include link to scss file on this.diagramInstance.getDiagramContent, but the result is the same


3 Replies

MG Moulidharan Gopalakrishnan Syncfusion Team December 22, 2025 02:05 PM UTC

Hi,


Thank you for sharing your code snippet and workflow details. we understand your inline HTML nodes render correctly in the browser but lose styling after Blink-based export. Below are the recommended steps to ensure your custom CSS is applied both at runtime and during server-side conversion:

1. Move Styles to a Global CSS File

  • Extract node-specific styles from Vue SFC <style scoped> blocks.
  • Create a plain .css file (e.g., designer-nodes.css) with rules for classes like .designer-node, .shadow-node.

2. Host CSS Publicly

  • Place the CSS file in your public/ folder (Vite/Vue 3 projects).
  • It will be accessible at:
    https://<your-host>/styles/designer-nodes.css

3. Load CSS in Browser

  • Option A: Add to index.html <head>:
    /styles/designer-nodes.css
  • Option B: Import in main.ts:
    import '/styles/designer-nodes.css'

4. Pass Stylesheet References to getDiagramContent()

   

const htmlData = diagramInstance.getDiagramContent([

`${window.location.origin}/styles/designer-nodes.css`,

'<link rel='nofollow' href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">'

]);

 

5. Verify Accessibility

  • Confirm https://<your-host>/styles/designer-nodes.css returns correct CSS.


Following these steps will ensure consistent styling in both your live Vue diagram and Blink-exported output. please refer the sample attached. If you encounter issues such as CORS errors or missing rules, please let us know we’re happy to assist.


Best regards,
Moulidharan


Attachment: vuediagramexport_1e887fbc.zip


GW Gerald Warren January 29, 2026 06:56 AM UTC

Hi,

Thank you for providing the code snippet and explaining your workflow. Based on the information shared, the issue occurs because styles defined in scoped Vue SFC blocks are not preserved during the Blink-based export process. While the inline HTML renders correctly in the browser, the export requires externally accessible stylesheets.

To ensure your custom styling is applied consistently both at runtime and during server-side export, please follow the steps below:

  1. Move styles to a global CSS file
    Move all node-related styles out of <style scoped> blocks and place them into a standalone CSS file (for example: designer-nodes.css). Ensure classes such as .designer-node or .shadow-node are defined there.

  2. Make the CSS file publicly accessible
    Place the CSS file inside the public/ directory of your Vue (Vite) project. This allows it to be accessed via a public URL such as:
    https://<your-host>/styles/designer-nodes.css

  3. Load the stylesheet in the application
    You can include the stylesheet either by:

    • Adding a <link> tag in index.html, or https://fnaffree.io

    • Importing it directly in main.ts using import '/styles/designer-nodes.css'

  4. Pass stylesheet references during export
    When calling getDiagramContent(), include the stylesheet URLs so they are applied during the Blink export process. For example:

    const htmlData = diagramInstance.getDiagramContent([ `${window.location.origin}/styles/designer-nodes.css`, '<link rel="nofollow" rel='nofollow' href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">' ]);
  5. Validate accessibility
    Please verify that the CSS file is reachable directly in the browser and returns the expected styles.

Following these steps should result in consistent styling across both the live Vue diagram and the exported output. A sample project has been attached for reference. If you run into any issues such as missing styles or CORS-related errors, feel free to reach out and we’ll be happy to help.

Best regards,
Moulidharan

Attachment: vuediagramexport_1e887fbc.zip 



MG Moulidharan Gopalakrishnan Syncfusion Team February 3, 2026 10:50 AM UTC

Hi Gerald Warren,

 

Thank you for your update. We hope the provided suggestion works fine. Please feel free to reach out if you need further assistance, we're always happy to help!

 

 

Regards,

Moulidharan


Loader.
Up arrow icon