CreateLossyCompressor(Double,Boolean,Boolean,Boolean) Метод (PdfDocumentCompressorCommand)
В этом разделе
Создает компрессор PDF с потерями.
Синтаксис
'Declaration
Public Overloads Shared Function CreateLossyCompressor( _
ByVal As Double, _
ByVal As Boolean, _
ByVal As Boolean, _
ByVal As Boolean _
) As PdfDocumentCompressorCommand
public static PdfDocumentCompressorCommand CreateLossyCompressor(
double ,
bool ,
bool ,
bool
)
public: static PdfDocumentCompressorCommand* CreateLossyCompressor(
double ,
bool ,
bool ,
bool
)
public:
static PdfDocumentCompressorCommand^ CreateLossyCompressor(
double ,
bool ,
bool ,
bool
)
Parameters
- viewResolution
- Разрешение в DPI для просмотра сжатого документа в приложениях.
- useJbig2
- Значение, указывающее, должен ли компрессор использовать сжатие без потерь JBIG2 вместо сжатия CcittFax для битональных изображений.
- useJpeg2000
- Значение, указывающее, должен ли компрессор использовать сжатие без потерь JPEG2000 вместо Flate(ZIP) для цветных и серых изображений.
- subsetFonts
- Значение, указывающее, должен ли компрессор использовать поднабор шрифтов.
Return Value
Пример
Вот пример, показывающий, как определить "глубину цвета чтения" ресурсов изображения PDF и сжать PDF документ с разрешением 150 точек на дюйм:
''' <summary>
''' Detects "read color depth" of PDF image resources and compress PDF document with intent to view in 150DPI.
''' </summary>
''' <param name="inPdfFilename">The input PDF filename.</param>
''' <param name="outPdfFilename">The output PDF filename.</param>
Public Shared Sub CompressToViewIn150DPI(inPdfFilename As String, outPdfFilename As String)
' create compressor that will compress PDF document using lossy compression algorithms
Dim compressor As Vintasoft.Imaging.Pdf.Processing.PdfDocumentCompressorCommand = Vintasoft.Imaging.Pdf.Processing.PdfDocumentCompressorCommand.CreateLossyCompressor(150, False, False, False)
' specify that compressor must use JPEG compression for color images
compressor.ColorImagesCompression = Vintasoft.Imaging.Pdf.PdfCompression.Jpeg
' specify that compressor must set JPEG quality to 70
compressor.ColorImagesCompressionSettings.JpegQuality = 70
' specify that compressor must detect if image is bitonal image and use optimal compression for bitonal image
compressor.DetectBitonalImageResources = True
' specify that compressor must detect if image is black-white image and use optimal compression for black-white image
compressor.DetectBlackWhiteImageResources = True
' specify that compressor must detect if image is grayscale image and use optimal compression for grayscale image
compressor.DetectGrayscaleImageResources = True
' compress PDF document
compressor.Compress(inPdfFilename, outPdfFilename)
End Sub
/// <summary>
/// Detects "read color depth" of PDF image resources and compress PDF document with intent to view in 150DPI.
/// </summary>
/// <param name="inPdfFilename">The input PDF filename.</param>
/// <param name="outPdfFilename">The output PDF filename.</param>
public static void CompressToViewIn150DPI(string inPdfFilename, string outPdfFilename)
{
// create compressor that will compress PDF document using lossy compression algorithms
Vintasoft.Imaging.Pdf.Processing.PdfDocumentCompressorCommand compressor =
Vintasoft.Imaging.Pdf.Processing.PdfDocumentCompressorCommand.CreateLossyCompressor(150, false, false, false);
// specify that compressor must use JPEG compression for color images
compressor.ColorImagesCompression = Vintasoft.Imaging.Pdf.PdfCompression.Jpeg;
// specify that compressor must set JPEG quality to 70
compressor.ColorImagesCompressionSettings.JpegQuality = 70;
// specify that compressor must detect if image is bitonal image and use optimal compression for bitonal image
compressor.DetectBitonalImageResources = true;
// specify that compressor must detect if image is black-white image and use optimal compression for black-white image
compressor.DetectBlackWhiteImageResources = true;
// specify that compressor must detect if image is grayscale image and use optimal compression for grayscale image
compressor.DetectGrayscaleImageResources = true;
// compress PDF document
compressor.Compress(inPdfFilename, outPdfFilename);
}
Требования
Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5
Смотрите также