Class GifDevice
内容
[
隐藏
]GifDevice class
表示图像设备,帮助将pdf文档页面保存为gif。
public sealed class GifDevice : ImageDevice
Constructors
Name | Description |
---|---|
GifDevice() | 使用默认分辨率初始化GifDevice 类的新实例。 |
GifDevice(PageSize) | 使用提供的页面大小初始化GifDevice 类的新实例,默认分辨率(=150)。 |
GifDevice(Resolution) | 初始化GifDevice 类的新实例。结果图像文件的分辨率,请参见Resolution 类。 |
GifDevice(int, int) | 使用提供的图像尺寸初始化GifDevice 类的新实例,默认分辨率(=150)。 |
GifDevice(PageSize, Resolution) | 使用提供的页面大小和分辨率初始化GifDevice 类的新实例。 |
GifDevice(int, int, Resolution) | 使用提供的图像尺寸和分辨率初始化GifDevice 类的新实例。 |
Properties
Name | Description |
---|---|
CoordinateType { get; set; } | 获取或设置页面坐标类型(媒体/裁剪框)。默认使用CropBox值。 |
FormPresentationMode { get; set; } | 获取或设置表单呈现模式。 |
Height { get; } | 获取图像输出高度。 |
RenderingOptions { get; set; } | 获取或设置渲染选项。 |
Resolution { get; } | 获取图像分辨率。 |
Width { get; } | 获取图像输出宽度。 |
Methods
Name | Description |
---|---|
override Process(Page, Stream) | 将页面转换为gif并将其保存在输出流中。 |
Process(Page, string) | 对给定页面执行某些操作并将结果保存到文件中。 |
Examples
以下示例演示如何将PDF文件转换为GIF图像。
[C#]
// The path to your PDF Directory
string dataDir = @"YOUR_DATA_DIRECTORY";
// The file name of the PDF
string pdfFile = @"YOUR_PDF_FILE";
// Initialize instance of Document class
using (Document pdfDocument = new Document(Path.Combine(dataDir, pdfFile)))
{
// Create Resolution object
Resolution resolution = new Resolution(300);
// Initialize GifDevice
GifDevice gifDevice = new GifDevice(resolution);
for (int pageCount = 1; pageCount <= pdfDocument.Pages.Count; pageCount++)
{
using (FileStream gifStream =
new FileStream($"{dataDir}image{pageCount}_out.gif",
FileMode.Create))
{
// Convert a particular page and save the image to stream
gifDevice.Process(pdfDocument.Pages[pageCount], gifStream);
// Close stream
gifStream.Close();
}
}
}
[VB.NET]
' The path to your PDF Directory
Dim dataDir As String = "YOUR_DATA_DIRECTORY"
' The file name of the PDF
Dim pdfFile As String = "YOUR_PDF_FILE"
' Initialize instance of Document class
Using pdfDocument As Document = New Document(Path.Combine(dataDir, pdfFile))
' Create Resolution object
Dim resolution As Resolution = New Resolution(300)
' Initialize GifDevice
Dim gifDevice As GifDevice = New GifDevice(resolution)
For pageCount As Integer = 1 To pdfDocument.Pages.Count
Using gifStream As FileStream = New FileStream($"{dataDir}image{pageCount}_out.gif", FileMode.Create)
' Convert a particular page and save the image to stream
gifDevice.Process(pdfDocument.Pages(pageCount), gifStream)
' Close stream
gifStream.Close()
End Using
Next
End Using
See Also
- class ImageDevice
- namespace Aspose.Pdf.Devices
- assembly Aspose.PDF