{"id":1564,"date":"2010-03-03T02:53:52","date_gmt":"2010-03-03T10:53:52","guid":{"rendered":"https:\/\/developer.microsoft.com\/en-us\/office\/blogs\/?p=1564"},"modified":"2021-11-17T12:16:48","modified_gmt":"2021-11-17T20:16:48","slug":"new-visio-2010-api-for-configuring-raster-export","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/new-visio-2010-api-for-configuring-raster-export\/","title":{"rendered":"New Visio 2010 API for Configuring Raster Export"},"content":{"rendered":"<p>When we talk to developers to get their feedback on the Visio development platform, a common request we hear is the ability, through the API, to control the settings used when exporting a diagram as a raster image in the PNG, JPG, BMP, or TIFF format. Typically, they want to automate the export of the pages in a document as images for use in a web page or other application that requires certain settings. In this post, we\u2019ll talk about the additions to the Visio 2010 object model that let developers configure each of these raster export settings.<\/p>\n<p>When you save a diagram in one of the raster formats, a dialog box appears to let you configure various settings, such as the color format, resolution, or size of the image. For example, this is the dialog for the PNG format:<\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/TNBlogsFS\/BlogFileStorage\/blogs_msdn\/visio\/WindowsLiveWriter\/NewVisio2010APIforConfiguringRasterExpor_8B00\/image_4.png\"><img decoding=\"async\" title=\"image\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/TNBlogsFS\/BlogFileStorage\/blogs_msdn\/visio\/WindowsLiveWriter\/NewVisio2010APIforConfiguringRasterExpor_8B00\/image_thumb_1.png\" alt=\"image\" width=\"508\" height=\"441\" border=\"0\" \/><\/a><\/p>\n<p>Until now, there hasn\u2019t been a way to automate the settings in this dialog via the API. In Visio 2010, we\u2019ve enhanced the object model to make it possible to drive these settings programmatically using a set of new methods and properties on the\u00a0<strong>ApplicationSettings<\/strong>\u00a0object. You can use the methods to get and set the raster-export resolution and size, and you can use the properties to get and set raster export attributes such as data format, data compression, color reduction, color format, background color, transparency, and quality. You can use these methods and properties with the existing Page.Export and Selection.Export methods to export a diagram in a raster file format.<\/p>\n<p>Here is the complete list of new raster export methods and properties on\u00a0<strong>ApplicationSettings<\/strong>:<\/p>\n<h4><strong>Methods<\/strong><\/h4>\n<table border=\"1\" width=\"85%\" cellspacing=\"0\" cellpadding=\"3\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"30%\"><strong>Name<\/strong><\/td>\n<td valign=\"top\" width=\"70%\"><strong>Description<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"30%\">GetRasterExportResolution<\/td>\n<td valign=\"top\" width=\"70%\">Returns the raster export resolution settings.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"30%\">GetRasterExportSize<\/td>\n<td valign=\"top\" width=\"70%\">Gets the raster export size.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"30%\">SetRasterExportResolution<\/td>\n<td valign=\"top\" width=\"70%\">Specifies the raster export resolution settings.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"30%\">SetRasterExportSize<\/td>\n<td valign=\"top\" width=\"70%\">Sets the raster export size.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4><\/h4>\n<h4><strong>Properties<\/strong><\/h4>\n<table border=\"1\" width=\"85%\" cellspacing=\"0\" cellpadding=\"3\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"30%\"><strong>Name<\/strong><\/td>\n<td valign=\"top\" width=\"70%\"><strong>Description<\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"30%\">RasterExportBackgroundColor<\/td>\n<td valign=\"top\" width=\"70%\">Determines the background color that is applied to the exported image.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"30%\">RasterExportColorFormat<\/td>\n<td valign=\"top\" width=\"70%\">Determines the color format that is applied to the exported image.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"30%\">RasterExportColorReduction<\/td>\n<td valign=\"top\" width=\"70%\">Determines the color reduction that is applied to the exported image.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"30%\">RasterExportDataCompression<\/td>\n<td valign=\"top\" width=\"70%\">Determines the data compression algorithm that is applied to the exported image (BMP, TIFF).<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"30%\">RasterExportDataFormat<\/td>\n<td valign=\"top\" width=\"70%\">Determines whether the exported image is interlaced or non-interlaced (PNG, GIF).<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"30%\">RasterExportFlip<\/td>\n<td valign=\"top\" width=\"70%\">Determines the flip that is applied to the exported image.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"30%\">RasterExportOperation<\/td>\n<td valign=\"top\" width=\"70%\">Determines the export operation that is applied to the exported image (JPG only).<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"30%\">RasterExportQuality<\/td>\n<td valign=\"top\" width=\"70%\">Determines the export quality that is applied to the exported image (JPG only).<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"30%\">RasterExportRotation<\/td>\n<td valign=\"top\" width=\"70%\">Determines the rotation that is applied to the exported image.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"30%\">RasterExportTransparencyColor<\/td>\n<td valign=\"top\" width=\"70%\">Determines the transparency color that is applied to the exported image (PNG, GIF).<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"30%\">RasterExportUseTransparencyColor<\/td>\n<td valign=\"top\" width=\"70%\">Determines whether Visio applies, to the exported image, the transparency color that is specified in the RasterExportTransparencyColor property (PNG, GIF).<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>For more details on these methods and properties, such as their parameters and constants, see the Visio Developer Reference in the Visio 2010 Beta.<\/p>\n<h3>Example<\/h3>\n<p>This VBA code executes the settings in the PNG Output Options dialog box as shown above and exports the diagram as a PNG:<\/p>\n<blockquote><p><span style=\"color: #008000\">&#8216;Set the export resolution to the printer resolution at 600 x 600 pixels\/inch\n<\/span>Application.Settings.SetRasterExportResolution visRasterUsePrinterResolution, 600#, 600#, visRasterPixelsPerInch<\/p>\n<p><span style=\"color: #008000\">&#8216;Set the export size to custom 8 x 5 inches<\/span>\nApplication.Settings.SetRasterExportSize visRasterFitToCustomSize, 8#, 5#, visRasterInch<\/p>\n<p><span style=\"color: #008000\">&#8216;Set the data format to Interlace<\/span>\nApplication.Settings.RasterExportDataFormat = visRasterInterlace<\/p>\n<p><span style=\"color: #008000\">&#8216;Set the color format to 24-bit color<\/span>\nApplication.Settings.RasterExportColorFormat = visRaster24Bit<\/p>\n<p><span style=\"color: #008000\">&#8216;Rotate the image to the left<\/span>\nApplication.Settings.RasterExportRotation = visRasterRotateLeft<\/p>\n<p><span style=\"color: #008000\">&#8216;Don\u2019t flip the image<\/span>\nApplication.Settings.RasterExportFlip = visRasterNoFlip<\/p>\n<p><span style=\"color: #008000\">&#8216;Set the background color<\/span>\nApplication.Settings.RasterExportBackgroundColor = 14798527<\/p>\n<p><span style=\"color: #008000\">&#8216;Set the transparency color<\/span>\nApplication.Settings.RasterExportTransparencyColor = 13269045<\/p>\n<p><span style=\"color: #008000\">&#8216;Use the transparency color<\/span>\nApplication.Settings.RasterExportUseTransparencyColor = True<\/p>\n<p><span style=\"color: #008000\">&#8216;Export the active page as a PNG to the specified path<\/span>\nApplication.ActiveWindow.Page.Export &#8220;&lt;drive&gt;:\\&lt;path&gt;\\Network Diagram.png&#8221;<\/p><\/blockquote>\n<p>We hope these additions to the API for raster export open up some new possibilities for Visio developers, or at least make it easier and more efficient to build automated solutions. Let us know what you think by commenting on the blog.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Visio developer typically want to automate the export a diagram as a raster image in the PNG, JPG, BMP, or TIFF format for use in a web page or other applications. In this post, we\u2019ll talk about the additions to the Visio object model that let developers configure each of these raster export settings.<\/p>\n","protected":false},"author":69200,"featured_media":25159,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[11],"tags":[77],"class_list":["post-1564","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-office-add-ins","tag-visio"],"acf":[],"blog_post_summary":"<p>Visio developer typically want to automate the export a diagram as a raster image in the PNG, JPG, BMP, or TIFF format for use in a web page or other applications. In this post, we\u2019ll talk about the additions to the Visio object model that let developers configure each of these raster export settings.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/1564","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/users\/69200"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/comments?post=1564"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/1564\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/media\/25159"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/media?parent=1564"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/categories?post=1564"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/tags?post=1564"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}