Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello, I am trying to use the exportPdf method defined here. My question is about the documentSize parameter. The documentation says that you can provide one of the given strings or provide a custom size. However, it is not documented what this ObjectMetricSize is supposed to be. Furthermore, there is another parameter called objectSize which uses an ObjectPixelSize without documenting what it should be.
My assumption is that both are objects with height and width properties, but I can't say for sure.
Can anyone add any clarification?
Hi,
Yes, you are correct. They are both objects with height and width properties:
/** * @typedef ObjectMetricSize {object} - Describes the size, in millimeters (mm), of a 2D object. * @property {number} height - Object height in millimeters (mm). * @property {number} width - Object width in millimeters (mm). */ /** * @typedef ObjectPixelSize {object} - Describes the size, in pixels, of a 2D object. * @property {number} height - Object height in pixels. * @property {number} width - Object width in pixels. */
Thanks for reporting this.
Hi,
Yes, you are correct. They are both objects with height and width properties:
/** * @typedef ObjectMetricSize {object} - Describes the size, in millimeters (mm), of a 2D object. * @property {number} height - Object height in millimeters (mm). * @property {number} width - Object width in millimeters (mm). */ /** * @typedef ObjectPixelSize {object} - Describes the size, in pixels, of a 2D object. * @property {number} height - Object height in pixels. * @property {number} width - Object width in pixels. */
Thanks for reporting this.
Thanks for the clarification. I did notice something else though while testing. The strings that you can provide for documentSize don't seem to have any effect (or I'm doing something wrong). Curiously though, when I provide a document size (even just the A3 size), it does create the correct document size. I've attached images showing the settings that I am passing to exportPdf and the generated pdf.
And the PDFs
It looks like there is a slight mismatch between the docs and the code here. It should work if you use lower case strings in the documentSize parameter:
vis.exportPdf({ documentSize: 'a3' }).then(console.log);
Ah, that makes sense. Thanks