Skip to content

Commit 114bf2d

Browse files
committed
diagram convert options
1 parent 04e7aa8 commit 114bf2d

2 files changed

Lines changed: 338 additions & 2 deletions

File tree

Lines changed: 336 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,336 @@
1+
---
2+
id: convert-to-diagram-with-advanced-options
3+
url: conversion/net/convert-to-diagram-with-advanced-options
4+
title: Convert to Diagram with advanced options
5+
weight: 18
6+
description: "Follow this guide and learn how to convert between diagram formats (VSDX, VSD, VSS, etc.) and customize page fitting using GroupDocs.Conversion for .NET."
7+
keywords: Convert to Diagram, Convert to VSDX, Convert to VSD, Visio conversion, Diagram format conversion
8+
productName: GroupDocs.Conversion for .NET
9+
hideChildren: False
10+
toc: True
11+
---
12+
13+
## Introduction
14+
15+
GroupDocs.Conversion provides [DiagramConvertOptions](https://reference.groupdocs.com/conversion/net/groupdocs.conversion.options.convert/diagramconvertoptions) for converting between diagram formats. Along with [common convert options]({{< ref "conversion/net/developer-guide/advanced-usage/converting/common-conversion-options/_index.md" >}}) from the base class, [DiagramConvertOptions](https://reference.groupdocs.com/conversion/net/groupdocs.conversion.options.convert/diagramconvertoptions) provides the following additional options:
16+
17+
## Properties
18+
19+
| Property | Type | Description |
20+
|----------|------|-------------|
21+
| [Format](https://reference.groupdocs.com/conversion/net/groupdocs.conversion.options.convert/convertoptions-1/format/) | `DiagramFileType` | Specifies the desired diagram format |
22+
| [AutoFitPageToDrawingContent](https://reference.groupdocs.com/conversion/net/groupdocs.conversion.options.convert/diagramconvertoptions/autofitpagetodrawingcontent) | `bool` | Defines whether to enlarge the page to fit drawing content |
23+
| [PageNumber](https://reference.groupdocs.com/conversion/net/groupdocs.conversion.options.convert/commonconvertoptions-1/pagenumber) | `int` | Specifies the starting page number for conversion |
24+
| [PagesCount](https://reference.groupdocs.com/conversion/net/groupdocs.conversion.options.convert/commonconvertoptions-1/pagescount) | `int` | Specifies the number of pages to convert |
25+
| [Pages](https://reference.groupdocs.com/conversion/net/groupdocs.conversion.options.convert/commonconvertoptions-1/pages) | `List<int>` | Specifies specific page numbers to convert |
26+
27+
## Basic Usage
28+
29+
Convert diagram files with default options:
30+
31+
```csharp
32+
using (var converter = new Converter("flowchart.vsdx"))
33+
{
34+
var options = new DiagramConvertOptions();
35+
converter.Convert("flowchart-copy.vsdx", options);
36+
}
37+
```
38+
39+
## Converting Between Diagram Formats
40+
41+
### Convert VSDX to VSD
42+
43+
Convert modern Visio format to legacy binary format:
44+
45+
```csharp
46+
using (var converter = new Converter("network-diagram.vsdx"))
47+
{
48+
var options = new DiagramConvertOptions
49+
{
50+
Format = DiagramFileType.Vsd
51+
};
52+
converter.Convert("network-diagram.vsd", options);
53+
}
54+
```
55+
56+
### Convert VSD to VSDX
57+
58+
Modernize legacy Visio files to the current format:
59+
60+
```csharp
61+
using (var converter = new Converter("legacy-diagram.vsd"))
62+
{
63+
var options = new DiagramConvertOptions
64+
{
65+
Format = DiagramFileType.Vsdx
66+
};
67+
converter.Convert("modernized-diagram.vsdx", options);
68+
}
69+
```
70+
71+
## Auto-Fit Page to Drawing Content
72+
73+
Automatically adjust the page size to fit all drawing content:
74+
75+
```csharp
76+
using (var converter = new Converter("org-chart.vsdx"))
77+
{
78+
var options = new DiagramConvertOptions
79+
{
80+
AutoFitPageToDrawingContent = true
81+
};
82+
converter.Convert("org-chart-autofit.vsdx", options);
83+
}
84+
```
85+
86+
This feature is useful when:
87+
- Diagrams have content extending beyond page boundaries
88+
- You want to eliminate excessive white space
89+
- Creating PDFs or images with optimal dimensions
90+
- Preparing diagrams for presentations
91+
92+
## Converting Specific Pages
93+
94+
Convert only selected pages from multi-page diagrams:
95+
96+
### Convert First Page Only
97+
98+
```csharp
99+
using (var converter = new Converter("multi-page-diagram.vsdx"))
100+
{
101+
var options = new DiagramConvertOptions
102+
{
103+
PageNumber = 1,
104+
PagesCount = 1
105+
};
106+
converter.Convert("selected-page.vsdx", options);
107+
}
108+
```
109+
110+
### Convert Specific Page Range
111+
112+
```csharp
113+
using (var converter = new Converter("architecture-plans.vsdx"))
114+
{
115+
var options = new DiagramConvertOptions
116+
{
117+
PageNumber = 2, // Start from page 2
118+
PagesCount = 3 // Convert 3 pages (pages 2-4)
119+
};
120+
converter.Convert("selected-pages.vsdx", options);
121+
}
122+
```
123+
124+
## Supported Diagram Formats
125+
126+
DiagramConvertOptions works with the following Visio formats:
127+
128+
### Modern Formats (Office 2013+)
129+
- **VSDX** - Visio Drawing (default format for Visio 2013 and later)
130+
- **VSSX** - Visio Stencil
131+
- **VSTX** - Visio Template
132+
133+
### Legacy Formats (Office 2010 and earlier)
134+
- **VSD** - Visio Drawing (binary format)
135+
- **VSS** - Visio Stencil (binary format)
136+
- **VST** - Visio Template (binary format)
137+
138+
### Macro-Enabled Formats
139+
- **VSDM** - Visio Macro-Enabled Drawing
140+
- **VSSM** - Visio Macro-Enabled Stencil
141+
- **VSTM** - Visio Macro-Enabled Template
142+
143+
### XML Formats
144+
- **VDX** - Visio Drawing XML
145+
- **VSX** - Visio Stencil XML
146+
- **VTX** - Visio Template XML
147+
148+
### Web Format
149+
- **VDW** - Visio Web Drawing
150+
151+
## Format Details
152+
153+
### VSDX vs VSD
154+
155+
**VSDX (Modern Format)**:
156+
- XML-based open format
157+
- Smaller file sizes (compression)
158+
- Better compatibility with Office 365
159+
- Preferred for new diagrams
160+
161+
**VSD (Legacy Format)**:
162+
- Binary format
163+
- Larger file sizes
164+
- Required for older Visio versions (2010 and earlier)
165+
- Use for backward compatibility
166+
167+
### Stencil Files (VSS/VSSX)
168+
169+
Stencils contain reusable shapes and templates:
170+
- VSS - Legacy stencil format
171+
- VSSX - Modern stencil format
172+
- Used for maintaining consistent diagram elements
173+
174+
### Template Files (VST/VSTX)
175+
176+
Templates provide starting points for new diagrams:
177+
- VST - Legacy template format
178+
- VSTX - Modern template format
179+
- Include predefined layouts and styles
180+
181+
## Common Use Cases
182+
183+
### 1. Format Modernization
184+
185+
Upgrade legacy Visio files to modern format:
186+
187+
```csharp
188+
using (var converter = new Converter("legacy-flowchart.vsd"))
189+
{
190+
var options = new DiagramConvertOptions
191+
{
192+
Format = DiagramFileType.Vsdx,
193+
AutoFitPageToDrawingContent = true
194+
};
195+
converter.Convert("modern-flowchart.vsdx", options);
196+
}
197+
```
198+
199+
### 2. Diagram Optimization
200+
201+
Optimize diagrams by auto-fitting content:
202+
203+
```csharp
204+
using (var converter = new Converter("process-diagram.vsdx"))
205+
{
206+
var options = new DiagramConvertOptions
207+
{
208+
AutoFitPageToDrawingContent = true
209+
};
210+
converter.Convert("optimized-diagram.vsdx", options);
211+
}
212+
```
213+
214+
### 3. Page Extraction
215+
216+
Extract specific pages from large diagram sets:
217+
218+
```csharp
219+
using (var converter = new Converter("complete-architecture.vsdx"))
220+
{
221+
var options = new DiagramConvertOptions
222+
{
223+
PageNumber = 5,
224+
PagesCount = 1
225+
};
226+
converter.Convert("network-layer.vsdx", options);
227+
}
228+
```
229+
230+
### 4. Batch Conversion
231+
232+
Standardize diagram formats across an organization:
233+
234+
```csharp
235+
string[] diagramFiles = Directory.GetFiles(@"C:\diagrams", "*.vsd");
236+
237+
foreach (var file in diagramFiles)
238+
{
239+
using (var converter = new Converter(file))
240+
{
241+
var options = new DiagramConvertOptions
242+
{
243+
Format = DiagramFileType.Vsdx
244+
};
245+
246+
string outputFile = Path.ChangeExtension(file, ".vsdx");
247+
converter.Convert(outputFile, options);
248+
}
249+
}
250+
```
251+
252+
## When to Use DiagramConvertOptions
253+
254+
Use DiagramConvertOptions when you need to:
255+
256+
- **Convert between Visio formats** (VSD ↔ VSDX, etc.)
257+
- **Modernize legacy diagrams** to current Visio format
258+
- **Optimize diagram pages** with auto-fit functionality
259+
- **Extract specific pages** from multi-page diagrams
260+
- **Standardize diagram formats** across projects
261+
- **Prepare diagrams** for archival or distribution
262+
263+
## Converting Diagrams to Other Formats
264+
265+
To convert diagram files to non-diagram formats (PDF, images, documents), use the appropriate ConvertOptions for the target format:
266+
267+
```csharp
268+
// Convert diagram to PDF
269+
using (var converter = new Converter("flowchart.vsdx"))
270+
{
271+
var options = new PdfConvertOptions();
272+
converter.Convert("flowchart.pdf", options);
273+
}
274+
275+
// Convert diagram to PNG images (page by page)
276+
using (var converter = new Converter("org-chart.vsdx"))
277+
{
278+
var options = new ImageConvertOptions
279+
{
280+
Format = ImageFileType.Png
281+
};
282+
converter.Convert("org-chart-page.png", options);
283+
}
284+
285+
// Convert diagram to Word document
286+
using (var converter = new Converter("process-flow.vsdx"))
287+
{
288+
var options = new WordProcessingConvertOptions();
289+
converter.Convert("process-flow.docx", options);
290+
}
291+
```
292+
293+
## Best Practices
294+
295+
1. **Use modern formats** (VSDX, VSSX, VSTX) for new diagrams:
296+
- Better compression
297+
- Improved compatibility
298+
- Enhanced features
299+
300+
2. **Enable auto-fit when appropriate**:
301+
- Eliminates unnecessary whitespace
302+
- Optimizes output dimensions
303+
- Improves readability
304+
305+
3. **Convert VSD to VSDX** for long-term storage:
306+
- Smaller file sizes
307+
- Better archival format
308+
- Future-proof compatibility
309+
310+
4. **Extract pages strategically**:
311+
- Reduce file sizes
312+
- Focus on specific content
313+
- Improve processing speed
314+
315+
5. **Test macro-enabled conversions**:
316+
- VSDM, VSSM, VSTM contain macros
317+
- Verify macro requirements in target environment
318+
- Consider security implications
319+
320+
## Summary
321+
322+
DiagramConvertOptions provides comprehensive control over diagram format conversions:
323+
324+
- **Format conversion**: Convert between 13 Visio format types
325+
- **Auto-fit functionality**: Automatically adjust pages to content
326+
- **Page selection**: Convert specific pages or page ranges
327+
- **Format modernization**: Upgrade legacy VSD files to modern VSDX
328+
- **Diagram optimization**: Optimize page sizes and content fitting
329+
330+
All examples on this page have been verified through automated testing to ensure accuracy.
331+
332+
## See Also
333+
334+
- [Common Conversion Options]({{< ref "conversion/net/developer-guide/advanced-usage/converting/common-conversion-options/_index.md" >}})
335+
- [DiagramConvertOptions API Reference](https://reference.groupdocs.com/conversion/net/groupdocs.conversion.options.convert/diagramconvertoptions/)
336+
- [DiagramFileType API Reference](https://reference.groupdocs.com/conversion/net/groupdocs.conversion.filetypes/diagramfiletype/)

net/developer-guide/advanced-usage/converting/conversion-options-by-document-family/convert-to-ebook-with-advanced-options.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ using (var converter = new Converter("user-manual.pdf"))
226226
var options = new EBookConvertOptions
227227
{
228228
Format = EBookFileType.Mobi,
229-
PageWidth = 600,
230-
PageHeight = 800
229+
PageWidth = 432, // 6 inches × 72 points/inch
230+
PageHeight = 648 // 9 inches × 72 points/inch
231231
};
232232
converter.Convert("user-manual.mobi", options);
233233
}

0 commit comments

Comments
 (0)