В этом разделе
Определяет кодировщик, использующий сжатие с потерями смешанного растрового содержимого (MRC) для кодирования PDF документов.
Объектная модель
Синтаксис
Пример
Вот C#/VB.NET код, который демонстрирует, как кодировать изображения в PDF формат с использованием сжатия MRC:
Public Shared Sub EncodeImagesUseMrc(images As Vintasoft.Imaging.ImageCollection, pdfFilename As String)
' create PDF MRC encoder
Dim encoder As New Vintasoft.Imaging.Codecs.Encoders.PdfMrcEncoder()
' set MRC compression settings
SetCompressionSettings(encoder.MrcCompressionSettings)
' save images to PDF use MRC compression
images.SaveSync(pdfFilename, encoder)
End Sub
Private Shared Sub SetCompressionSettings(settings As Vintasoft.Imaging.Codecs.Encoders.PdfMrcCompressionSettings)
' background layer
settings.CreateBackgroundLayer = True
settings.BackgroundLayerCompression = Vintasoft.Imaging.Pdf.PdfCompression.Jpeg Or Vintasoft.Imaging.Pdf.PdfCompression.Zip
settings.BackgroundLayerCompressionSettings.JpegQuality = 35
' images layer, images placed to background layer
settings.ImageSegmentation = New Vintasoft.Imaging.ImageProcessing.Info.ImageSegmentationCommand()
settings.CreateImagesLayer = False
' mask layer
settings.HiQualityMask = True
settings.MaskCompression = Vintasoft.Imaging.Pdf.PdfCompression.Jbig2
settings.MaskCompressionSettings.Jbig2Settings.Lossy = True
' front layer
settings.CreateFrontLayer = True
settings.HiQualityFrontLayer = True
settings.FrontLayerCompression = Vintasoft.Imaging.Pdf.PdfCompression.Jpeg Or Vintasoft.Imaging.Pdf.PdfCompression.Zip
settings.FrontLayerCompressionSettings.JpegQuality = 25
End Sub
public static void EncodeImagesUseMrc(Vintasoft.Imaging.ImageCollection images, string pdfFilename)
{
// create PDF MRC encoder
Vintasoft.Imaging.Codecs.Encoders.PdfMrcEncoder encoder =
new Vintasoft.Imaging.Codecs.Encoders.PdfMrcEncoder();
// set MRC compression settings
SetCompressionSettings(encoder.MrcCompressionSettings);
// save images to PDF use MRC compression
images.SaveSync(pdfFilename, encoder);
}
private static void SetCompressionSettings(Vintasoft.Imaging.Codecs.Encoders.PdfMrcCompressionSettings settings)
{
// background layer
settings.CreateBackgroundLayer = true;
settings.BackgroundLayerCompression =
Vintasoft.Imaging.Pdf.PdfCompression.Jpeg | Vintasoft.Imaging.Pdf.PdfCompression.Zip;
settings.BackgroundLayerCompressionSettings.JpegQuality = 35;
// images layer, images placed to background layer
settings.ImageSegmentation =
new Vintasoft.Imaging.ImageProcessing.Info.ImageSegmentationCommand();
settings.CreateImagesLayer = false;
// mask layer
settings.HiQualityMask = true;
settings.MaskCompression = Vintasoft.Imaging.Pdf.PdfCompression.Jbig2;
settings.MaskCompressionSettings.Jbig2Settings.Lossy = true;
// front layer
settings.CreateFrontLayer = true;
settings.HiQualityFrontLayer = true;
settings.FrontLayerCompression =
Vintasoft.Imaging.Pdf.PdfCompression.Jpeg |
Vintasoft.Imaging.Pdf.PdfCompression.Zip;
settings.FrontLayerCompressionSettings.JpegQuality = 25;
}
Иерархия наследования
Требования
Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5
Смотрите также