Microsoft® Visio การแยกไฟล์ผ่าน Java
แยกเอกสาร Visio ฉบับเดียวออกเป็นไฟล์ต่างๆ โดยใช้รหัส Java ภายในแอปพลิเคชันที่ใช้ Java
Java Visio ห้องสมุด สามารถแบ่งเอกสาร Visio ออกเป็นหลายหน้าภายในแอปพลิเคชันที่ใช้ Java รูปแบบไฟล์ที่รองรับ ได้แก่ VDW, VDX, VSD, VSDM, VSDX, VSS, VSSM,VSSX,VST,VSTM,VSTX,VSX,VTX
แยกเอกสาร Visio ออกเป็นหลายไฟล์
วิธีที่ง่ายที่สุดในการแยกไฟล์ Visio หน้าอย่างชาญฉลาดคือ การเข้าถึงทุกหน้าผ่าน หน้า วนซ้ำในแต่ละหน้าและเรียก สำเนา กระบวนการ. ในที่สุดก็บันทึกลงในเส้นทางที่ระบุ
- โหลดไฟล์ Visio พร้อมพาธแบบเต็มโดยใช้ คลาสไดอะแกรม . วนซ้ำในแต่ละหน้า
- สร้าง Diagram วัตถุคลาส . ใหม่
- คัดลอกหน้าผ่าน วิธีการคัดลอก
- เรียกเมธอด save() และส่งชื่อไฟล์ (เส้นทางแบบเต็ม) ที่มี SaveFormat ที่เกี่ยวข้อง
Java รหัสสำหรับแยก Visio ไฟล์
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |