Microsoft® Visio Python Yoluyla Dönüştürme Biçimleri

Platformlar arası Python uygulamalar oluşturmak için MS Visio Diyagramlarını HTML, PDF ve JPG, BMP, PNG, TIFF dahil olmak üzere Görüntülere dönüştürün.

 

Akış şemaları ve iş akış şemaları vb. tasarlamak gibi herhangi bir Microsoft Visio biçimi oluşturma çözümü için Python Visio API, tüm karmaşık çizimleri kolay bir şekilde kolaylaştırır. kullanarak kaynak dosyayı yükleyin Diagram sınıfı ve uygun parametrelerle kaydetme yöntemini çağırın.

Dönüşümler Arası Visio Dosyaları

Programcılar VSDX, VSX, VTX, VDX, VSSX, VSTX, VSDM, VSSM, VSTM formatlarını kolayca dönüştürebilir ve ayrıca VDW, VSD, VSS, VST ve PDF, HTML ve Görüntülere dönüştürür. VSDX - VDX senaryosu göz önüne alındığında, process is, kaynak VSDX dosyasını diagram sınıfını kullanarak yükleyin ve çıktı dosyasını sağlayarak save yöntemini çağırın ve KaydetDosya Biçimi parametreler olarak.

VSDX - VDX Dönüşümü için Python Kodu
// Load the VSDX in an object of Diagram
Diagram visio = new Diagram("template.vsdx");
// save VSDX as VDX
visio.save("output.vdx", SaveFileFormat.VDX);
 

Visio Görüntü Dönüşümü

Jenerik dönüştürme için, visio dosyasının görüntüye dönüştürülmesi işlemi aynıdır. Dosyayı Diagram sınıfı aracılığıyla yükleyin ve çıktı dosyası ve SaveFileFormat çıktı parametreleriyle kaydetme yöntemini çağırın. Ayrıca, belirli seçenekleri tanımlamaya ihtiyaç duyulduğunda, geliştiriciler diagram sayfaları görüntülere dönüştürürken ImageSaveOptions sınıfını ve SVG dönüşümü için SVGSaveOptions’ı kullanabilir.

Visio\'yi Görüntü Biçimlerine Dönüştürecek Python Kodu
Diagram vsdxtoImages = new Diagram("sourceDocument.vsdx");
ImageSaveOptions ImgOptions = new ImageSaveOptions(SaveFileFormat.JPEG);
// specify the quality level to use during compositing.
ImgOptions.setCompositingQuality(CompositingQuality.HIGH_QUALITY);
//The default value is 0.5. The value must be in the range between 0 and 1.
ImgOptions.setImageBrightness(1f);
ImgOptions.setDefaultFont("MS Gothic");
// sets the number of pages to render in image.
ImgOptions.setPageCount(2);
// sets the 0-based index of the first page to render. Default is 0.
ImgOptions.setPageIndex(0);
// set page size
PageSize pgSize = new PageSize(PaperSizeFormat.A_1);
ImgOptions.setPageSize(pgSize);
// discard saving background pages of the Visio diagram
ImgOptions.setSaveForegroundPagesOnly(true);
// sets the color mode for the generated images.
ImgOptions.setImageColorMode(ImageColorMode.BLACK_AND_WHITE);
// the default value is 0.5. The value must be in the range between 0 and 1.
ImgOptions.setImageContrast(1f);
// this property has effect only when saving to raster image formats.
ImgOptions.setInterpolationMode(InterpolationMode.NEAREST_NEIGHBOR);
// the value may vary from 0 to 100 where 0 means worst quality,
ImgOptions.setJpegQuality(100);
// set a value specifying how pixels are offset during rendering.
ImgOptions.setPixelOffsetMode(PixelOffsetMode.HIGH_SPEED);
// sets the resolution for the generated images, in dots per inch. The default value is 96.
ImgOptions.setResolution(2f);
// the default value is 1.0. The value must be greater than 0.
ImgOptions.setScale(1f);
// specify whether smoothing (antialiasing) is applied to lines
// and curves and the edges of filled areas.
ImgOptions.setSmoothingMode(SmoothingMode.HIGH_QUALITY);
// sets the type of compression to apply when saving generated images to the TIFF format.
ImgOptions.setTiffCompression(TiffCompression.CCITT_3);
// save in visio file into image of choice
vsdxtoImages.save("visiofiletoimage_Out.jpeg", ImgOptions);
Visio\'yi SVG\'ye Dönüştürecek Python Kodu
Diagram vsdxTosvg = new Diagram("sourceFile.vsdx");
SVGSaveOptions svgOpts = new SVGSaveOptions();
svgOpts.setDefaultFont("MS Gothic");
// sets the 0-based index of the first page to render. Default is 0.
svgOpts.setPageIndex(0);
// set page size
PageSize pgSize = new PageSize(PaperSizeFormat.A_1);
svgOpts.setPageSize(pgSize);
vsdxTosvg.save("visio-to-svg.svg", svgOpts);
 

Visio\'i PDF ve HTML\'ye dönüştürün

API, visio biçimlerini HTML’ye olduğu kadar PDF’ye de dönüştürebilir. Sadece kullan KaydetDosya Biçimi .PDF ve SaveFileFormat.HTML içinde parametre olarak kaydetme yöntemi. Ve özel ayarlar için geliştiriciler PdfSaveOptions ve HTMLSaveOptions sınıflarını kullanabilir.

Visio\'den PDF\'ye Dönüştürme için Python Kodu
// call the diagram constructor to load diagram from a VSDX file
Diagram vsdxtopdf = new Diagram("sourfile.vsdx");
// Options when saving a diagram into the PDF format
PdfSaveOptions pdfOpts = new PdfSaveOptions();
// discard saving background pages of the Visio diagram
pdfOpts.setSaveForegroundPagesOnly(true);
// specify the quality of JPEG compression for images (if JPEG compression is used). Default is 95.
pdfOpts.setJpegQuality(100);
// specify default font name
pdfOpts.setDefaultFont("Arial");
// conformance level for generated PDF document.
pdfOpts.setCompliance(PdfCompliance.PDF_15);
// sets a digital signature details. If not set, then no signing will be performed.
pdfOpts.setDigitalSignatureDetails(new PdfDigitalSignatureDetails(cert, "Test Signing", "Aspose Office", DateTime.getNow(), PdfDigitalSignatureHashAlgorithm.SHA_256));
// set encription details
PdfEncryptionDetails encriptionDetails = new PdfEncryptionDetails("user password", "Owner Password", PdfEncryptionAlgorithm.RC_4_128);
pdfOpts.setEncryptionDetails(encriptionDetails);
// sets the number of pages to render in PDF.
pdfOpts.setPageCount(2);
// sets the 0-based index of the first page to render. Default is 0.
pdfOpts.setPageIndex(0);
// set page size
PageSize pgSize = new PageSize(PaperSizeFormat.A_1);
pdfOpts.setPageSize(pgSize);
// save in visio file into PDF
vsdxtopdf.save("UsePDFSaveOptions_Out.pdf", pdfOpts);
Visio\'yi HTML Dosyasına Dönüştürecek Python Kodu
// call the diagram constructor to load diagram from a VSDX file
Diagram vsdxtohtml = new Diagram("sourceFile.vsdx");
// Options when saving a diagram into the HTML format
HTMLSaveOptions htmlOpt = new HTMLSaveOptions();
htmlOpt.setDefaultFont("MS Gothic");
// sets the number of pages to render in HTML.
htmlOpt.setPageCount(2);
// sets the 0-based index of the first page to render. Default is 0.
htmlOpt.setPageIndex(0);
// set page size
PageSize pgSize = new PageSize(PaperSizeFormat.A_1);
htmlOpt.setPageSize(pgSize);
// discard saving background pages of the Visio diagram
htmlOpt.setSaveForegroundPagesOnly(true);
// specify whether to include the toolbar or not. Default value is true.
htmlOpt.setSaveToolBar(false);
// set title of the HTML document
htmlOpt.setTitle("Title goes here");
// save visio file in HTML file format
vsdxtohtml.save("UseHTMLSaveOptions_Out.html", htmlOpt);