Кодеки: Как Сконвертировать DOCX/DOC в TIFF?
В этом разделе
SDK выполнит рендеринг DOCX/DOC-страницы при преобразовании DOCX-документа в TIFF-файл.
Вот C#/VB.NET код, который демонстрирует, как преобразовать DOCX/DOC-документ в TIFF-файл с помощью классов
ImageCollection и
TiffEncoder:
/// <summary>
/// Converts DOCX document to TIFF file using ImageCollection and TiffEncoder classes.
/// DOCX document is rendered with specified resolution.
/// </summary>
public static void ConvertDocxToTiff(string docxFileName, string tiffFileName, float dpi)
{
// create image collection
using (Vintasoft.Imaging.ImageCollection imageCollection = new Vintasoft.Imaging.ImageCollection())
{
// add DOCX document to collection
imageCollection.Add(docxFileName);
// 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 DOCX document to TIFF file using ImageCollection and TiffEncoder classes.
''' DOCX document is rendered with specified resolution.
''' </summary>
Public Shared Sub ConvertDocxToTiff(docxFileName As String, tiffFileName As String, dpi As Single)
' create image collection
Using imageCollection As New Vintasoft.Imaging.ImageCollection()
' add DOCX document to collection
imageCollection.Add(docxFileName)
' 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