Usando Aspose.Total for .NET você pode exportar facilmente CGM para imagem SVGZ em qualquer aplicativo .NET em duas etapas simples. Em primeiro lugar, usando Aspose.PDF for .NET , você pode exportar CGM para JPEG. Depois disso, usando Aspose.Imaging for .NET API de processamento de imagem, você pode converter JPEG para SVGZ.
Converter arquivo CGM para SVGZ via .NET
- Abra o arquivo CGM usando a classe Document
- Inicialize o objeto de classe JpegDevice e renderize CGM para JPEG usando Process método
- Carregue o arquivo JPEG usando a classe Image
- Salve o documento no formato SVGZ usando o método Salvar
Requisitos de conversão
Instale a partir da linha de comando como nuget install Aspose.Total
ou via Package Manager Console do Visual Studio com Install-Package Aspose.Total
.
Como alternativa, obtenha o instalador MSI offline ou as DLLs em um arquivo ZIP em downloads .
// supports PDF, CGM, EPUB, TeX, PCL, PS, XPS, MD, MHTML, XSLFO, HTML file formats | |
// load PDF with an instance of Document | |
var document = new Document("input.pdf"); | |
// create an object of jpegDevice | |
var renderer = new JpegDevice(); | |
// convert a particular page and save the image in JPEG format | |
renderer.Process(document.Pages[1], "output.jpeg"); | |
// load JPEG file | |
var image = Image.Load("output.jpeg"); | |
// supports Dicom, Jpeg2000, Apng, Psd, Dxf, Wmf, Emz, Wmz, Tga, Svgz file formats | |
// save JPEG to PSD file format | |
image.Save("output.psd", new PsdOptions()); |
Converter arquivo CGM para SVGZ em um único arquivo via C#
Usando a API, você também pode converter o arquivo CGM para SVGZ em um único arquivo de imagem. Para converter todas as páginas, você pode primeiro renderizar seu documento CGM para um arquivo TIFF e depois exportar o arquivo TIFF para SVGZ. Você pode abrir o arquivo de entrada usando a classe Document e criar objetos de dispositivo Resolution, TiffSettings e TIFF. Você pode obter uma única imagem TIFF usando o método Process de TiffDevice . Finalmente, você pode carregar o arquivo TIFF usando a classe Image e salve-o no formato SVGZ usando o método Save .
// supports PDF, CGM, EPUB, TeX, PCL, PS, XPS, MD, MHTML, XSLFO, HTML file formats | |
// Open PDF document | |
Document pdfDocument = new Document("input.pdf"); | |
// Create Resolution object | |
Resolution resolution = new Resolution(300); | |
// Create TiffSettings object | |
TiffSettings tiffSettings = new TiffSettings | |
{ | |
Compression = CompressionType.None, | |
Depth = ColorDepth.Default, | |
Shape = ShapeType.Landscape, | |
SkipBlankPages = false | |
}; | |
// Create TIFF device | |
TiffDevice tiffDevice = new TiffDevice(resolution, tiffSettings); | |
// Convert a particular page and save the image to stream | |
tiffDevice.Process("output.tif"); | |
// load TIFF file | |
var image = Image.Load("output.tif"); | |
// supports Dicom, Jpeg2000, Apng, Psd, Dxf, Wmf, Emz, Wmz, Tga, Svgz file formats | |
// save TIFF to PSD file format | |
image.Save("output.psd", new PsdOptions()); |
Converta e gire o arquivo CGM para SVGZ via C#
Usando a API, você também pode girar a imagem SVGZ de saída conforme suas necessidades. O método Image.RotateFlip pode ser usado para girar a imagem em 90/180/270 graus e virar a imagem horizontalmente ou verticalmente. Você pode especificar o tipo de rotação e inversão para aplicar à imagem. Para girar e inverter a imagem, você pode carregar a imagem JPEG convertida usando o método de fábrica exposto pela classe Image e chamar a classe Image .RotateFlip enquanto especifica o RotateFlipType apropriado.
// supports PDF, CGM, EPUB, TeX, PCL, PS, XPS, MD, MHTML, XSLFO, HTML file formats | |
// load PDF with an instance of Document | |
var document = new Document("input.pdf"); | |
// create an object of jpegDevice | |
var renderer = new JpegDevice(); | |
// convert a particular page and save the image in JPEG format | |
renderer.Process(document.Pages[1], "output.jpeg"); | |
// load JPEG file | |
var image = Image.Load("output.jpeg"); | |
// rotate the image | |
image.RotateFlip(RotateFlipType.Rotate270FlipNone); | |
// supports Dicom, Jpeg2000, Apng, Psd, Dxf, Wmf, Emz, Wmz, Tga, Svgz file formats | |
// save JPEG to PSD file format | |
image.Save("output.psd", new PsdOptions()); |