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:
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:
But after saving image the result is:
My nodes html content is:
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
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
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:
-
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-nodeor.shadow-nodeare defined there. -
Make the CSS file publicly accessible
Place the CSS file inside thepublic/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 -
Load the stylesheet in the application
You can include the stylesheet either by:-
Adding a
<link>tag inindex.html, or https://fnaffree.io -
Importing it directly in
main.tsusingimport '/styles/designer-nodes.css'
-
-
Pass stylesheet references during export
When callinggetDiagramContent(), 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">' ]); -
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
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
- 3 Replies
- 3 Participants
-
AB Alexander Bondarew | Fenêtre bv
- Dec 19, 2025 01:51 PM UTC
- Feb 3, 2026 10:50 AM UTC