Microsoft® Visio Dzielenie plików przez Java
Podziel pojedynczy dokument Visio na różne pliki przy użyciu Java kodu w Java aplikacjach opartych na
Java Visio Biblioteka jest w stanie podzielić Visio dokument na wiele stron w aplikacjach opartych na Java. Obsługiwane formaty plików to VDW, VDX, VSD, VSDM, VSDX, VSS, VSSM,VSSX,VST,VSTM,VSTX,VSX,VTX.
Podziel Visiodokument na wiele plików
Najprostszym sposobem podziału Visio plików na stronę jest dostęp do wszystkich stron przez strony Iterowanie przez każdą stronę i wywoływanie Kopiuj metoda. Wreszcie zapisując go w określonej ścieżce.
- Załaduj plik Visio z pełną ścieżką za pomocą diagram klasa . Iteruj po każdej stronie
- Utwórz nowy Diagram obiekt klasy
- Skopiuj stronę przez Metoda kopiowania
- Wywołaj metodę save() i przekaż nazwę pliku (pełną ścieżkę) z odpowiednim SaveFormat.
Java Kod do podziału Visio plików
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(CopyVisioPage.class); | |
// Call the diagram constructor to load diagram from a VSD file | |
Diagram originalDiagram = new Diagram(dataDir + "Drawing1.vsd"); | |
// initialize the new visio diagram | |
Diagram newDiagram = new Diagram(); | |
// add all masters from the source Visio diagram | |
MasterCollection originalMasters = originalDiagram.getMasters(); | |
for (Master master : (Iterable<Master>) originalMasters) { | |
newDiagram.addMaster(originalDiagram, master.getName()); | |
} | |
// get the page object from the original diagram | |
Page SrcPage = originalDiagram.getPages().getPage("Page-1"); | |
// set page name | |
SrcPage.setName("new page"); | |
// it calculates max page id | |
int max = 0; | |
if (newDiagram.getPages().getCount() != 0) | |
max = newDiagram.getPages().get(0).getID(); | |
for (int i = 1; i < newDiagram.getPages().getCount(); i++) | |
{ | |
if (max < newDiagram.getPages().get(i).getID()) | |
max = newDiagram.getPages().get(i).getID(); | |
} | |
int MaxPageId = max; | |
// set page id | |
SrcPage.setID(MaxPageId); | |
// add reference of the original diagram page | |
newDiagram.getPages().add(SrcPage); | |
// remove first empty page | |
newDiagram.getPages().remove(newDiagram.getPages().get(0)); | |
// save diagram in VDX format | |
newDiagram.save(dataDir + "CopyVisioPage_Out.vsdx", SaveFileFormat.VSDX); |