Using scalable images in your documentation
When writing FlexCel documentation at tms, we often need to include document screenshots.
In many cases, a simple screen capture will do. But in others, we'd like something that can scale with the monitor resolution, and a bitmap is not enough. In those cases, we use FlexCel to export the images as SVG (scalar vector graphics).
We will discuss two different cases here:
Sometimes you want to render a simple object. Like for example the chart at the top of this blog post We created that image from the file in the Chart API example, using the following code:
var svg = xls.RenderObjectAsSVG(-1, "@lines of code", "Lines of code over time", "This chart was rendered with RenderObjectAsSVG", Encoding.UTF8); { File.WriteAllText("flexcel-lines-of-code.svg", svg); }
Other times, you might want to render a part of a sheet, as we did in the diagram at the end of this article. On those cases, we use code similar to the following:
using (var svg = new FlexCelSVGExport(xls, true)) { // Set a page size that has the size of the image you want. // You will need to experiment a little to get the correct size. svg.PageSize = new TPaperDimensions("custom", 780, 300); svg.SaveAsImage((x) => { x.FileName = "result" + x.PageNumber.ToString(CultureInfo.InvariantCulture) + ".svg"; }); }
You might change the print scaling of the xlsx file to get a smaller or bigger image.