This documentation provides a detailed guide on how to override the printPartList function to customize the printing behavior of the part list in the configurator. In the first part of this documentation we want to focus on an generic implementation of overriden the Rubens onPrintPartList callback. In the second part we want to show an example case how to generate an PDF with an java script library - if you want to use your own java script library or just do something else with the print part list button you can skip the second part.
Code Sandbox:
If you need some example or just want to copy paste, please have a look in this
Overriding the onPartlistPrint callback
1. Step: Initialize the configurator as usual
If you initialize the configurator for the first time please have a look in Getting started.
If you don't want to override the print button but want to hide it you can set the partlist_print in the init data to false.
const configurator = await RoomleConfiguratorApi.createConfigurator(
"demoConfigurator",
document.getElementById("configurator-container"),
{
id: "usm:frame",
autoStart: true,
buttons: {
partlist_print: true, // Currently it is true by default so it is fine to not use it as well but you can hide it
},
}
);
2. Step: Override the onPartlistPrint callback
As usual you can override the onPartlistPrint callback with every function you want, we override it in this case with our own custom printPartList function which is described in the following steps.
Parameters of the onPartlistPrint Callback
partList: An array containing the parts in the configuration.
price: The total price of the configuration.
label: A label for the configuration.
bounds: The bounds of the configuration.
catalogLabel: A catalog label for the configuration.
Since we want to show the parts list data in the PDF as a table, we need to generate an array out of the parts list data.
This looks a little bit complicated, but basically is formatting all the labels and data of the parts list to a human readable format. Just do it in the way you want to format your data.
To implement your custom parts list there are some steps needed, as mentioned above you after overriding the onPartlistPrint callback you can implement printing the parts list PDF in your own way.
As described above this is just an example how you can generate an PDF with our parts list data. You can generate a PDF in every way you prefer. You can find the full code in the in the print.js file.
We use for our example:
We now set up the PDF as it is needed for the jspdf library. You can set the font family, font wheight, font size and so on - if you need more information please have a look in the documentation of the .
If you want to look up the full example please have a look in this