Skip to content

Exporting

Aravinda VK edited this page Jul 29, 2026 · 1 revision

Chitra supports exporting to PDF, PNG and SVG formats.

Export to PDF

import chitra;
​
void main()
{
    auto ctx = new Chitra(700);
    with (ctx)
    {
        rect(100, 100, 500, 200);
        saveAs("rect.pdf");
    }
}

Export to PNG

import chitra;
​
void main()
{
    auto ctx = new Chitra(700);
    with (ctx)
    {
        rect(100, 100, 500, 200);
        saveAs("rect.png");
    }
}

Export to SVG

import chitra;
​
void main()
{
    auto ctx = new Chitra(700);
    with (ctx)
    {
        rect(100, 100, 500, 200);
        saveAs("rect.svg");
    }
}

Resolution

Default resolution is 300. Change the resolution while saving.

saveAs("rect.pdf", resolution: 72);
saveAs("rect.png", resolution: 72);
saveAs("rect.svg", resolution: 72);

Clone this wiki locally