Кодеки: Как сконвертировать PPTX в TIFF?
В этом разделе
VintaSoft Imaging .NET SDK ренедрит PPTX страницу при конвертации документа PPTX в файл TIFF.
Для выполнения приведенного ниже кода необходимо:
- VintaSoft Imaging .NET SDK (Vintasoft.Shared.dll; Vintasoft.Imaging.dll; Vintasoft.Imaging.Gdi.dll или Vintasoft.Imaging.Drawing.SkiaSharp.dll)
- VintaSoft Office .NET Plug-in (Vintasoft.Imaging.Office.OpenXml.dll)
- System.IO.Packaging nuget-пакет (nuget-пакет используется Vintasoft.Imaging.Office.OpenXml.dll)
-
System.Drawing.Common nuget-пакет (nuget-пакет необходим, если GDI+ следует использовать в качестве движка для 2D-рисования в VintaSoft Imaging .NET SDK) или
SkiaSharp nuget-пакет (nuget-пакет необходим, если SkiaSharp следует использовать в качестве движка для 2D-рисования в VintaSoft Imaging .NET SDK)
Вот C#/VB.NET код, который показывает, как сконвертировать документ PPTX в файл TIFF с помощью классов
ImageCollection и
TiffEncoder:
/// <summary>
/// Converts PPTX document to TIFF file using ImageCollection and TiffEncoder classes.
/// PPTX document is rendered with specified resolution.
/// </summary>
public static void ConvertPptxToTiff(string pptxFileName, string tiffFileName, float dpi)
{
// specify that VintaSoft Imaging .NET SDK should use GDI+ for drawing of 2D graphics
Vintasoft.Imaging.Drawing.Gdi.GdiGraphicsFactory.SetAsDefault();
// specify that VintaSoft Imaging .NET SDK should use SkiaSharp for drawing of 2D graphics
//Vintasoft.Imaging.Drawing.SkiaSharp.SkiaSharpDrawingFactory.SetAsDefault();
// create image collection
using (Vintasoft.Imaging.ImageCollection imageCollection = new Vintasoft.Imaging.ImageCollection())
{
// add PPTX document to collection
imageCollection.Add(pptxFileName);
// set rendering settings
imageCollection.SetRenderingSettings(new Vintasoft.Imaging.Codecs.Decoders.RenderingSettings(dpi, dpi));
// create TiffEncoder
using (Vintasoft.Imaging.Codecs.Encoders.TiffEncoder tiffEncoder =
new Vintasoft.Imaging.Codecs.Encoders.TiffEncoder(true))
{
// set TIFF compression to Zip
tiffEncoder.Settings.Compression =
Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffCompression.Zip;
// save images of image collection to TIFF file using TiffEncoder
imageCollection.SaveSync(tiffFileName, tiffEncoder);
}
// dispose images
imageCollection.ClearAndDisposeItems();
}
}
''' <summary>
''' Converts PPTX document to TIFF file using ImageCollection and TiffEncoder classes.
''' PPTX document is rendered with specified resolution.
''' </summary>
Public Shared Sub ConvertPptxToTiff(pptxFileName As String, tiffFileName As String, dpi As Single)
' specify that VintaSoft Imaging .NET SDK should use GDI+ for drawing of 2D graphics
Vintasoft.Imaging.Drawing.Gdi.GdiGraphicsFactory.SetAsDefault()
' specify that VintaSoft Imaging .NET SDK should use SkiaSharp for drawing of 2D graphics
'Vintasoft.Imaging.Drawing.SkiaSharp.SkiaSharpDrawingFactory.SetAsDefault()
' create image collection
Using imageCollection As New Vintasoft.Imaging.ImageCollection()
' add PPTX document to collection
imageCollection.Add(pptxFileName)
' set rendering settings
imageCollection.SetRenderingSettings(New Vintasoft.Imaging.Codecs.Decoders.RenderingSettings(dpi, dpi))
' create TiffEncoder
Using tiffEncoder As New Vintasoft.Imaging.Codecs.Encoders.TiffEncoder(True)
' set TIFF compression to Zip
tiffEncoder.Settings.Compression = Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffCompression.Zip
' save images of image collection to TIFF file using TiffEncoder
imageCollection.SaveSync(tiffFileName, tiffEncoder)
End Using
' dispose images
imageCollection.ClearAndDisposeItems()
End Using
End Sub