PdfCompressorExtensions Class

Summary

Contains an asynchronous extension to write PDF content to a LEAD stream. PdfCompressorExtensions is an abstract class and cannot be created directly.

Syntax

C#
public abstract PdfCompressorExtensions 

Remarks

PdfCompressorExtensions provides an extension method to the namespace Leadtools.PdfCompressor.

The WriteAsync(PdfCompressorEngine,ILeadStream) method is implemented in Leadtools.Async.dll as an extension to the Leadtools.PdfCompressor namespace and is part of the Leadtools.PdfCompressor.PdfCompressorExtensions class.

The extension method WriteAsync(PdfCompressorEngine,ILeadStream) will not show up unless a reference to Leadtools.Async.dll is added to your project.

Example

C#
using Leadtools; 
using Leadtools.Codecs; 
 
using Leadtools.PdfCompressor; 
 
public void TestPdfCompressorSaveAsyncAwait() 
{ 
    string srcFile = Path.Combine(LEAD_VARS.ImagesDir, "glare.jpg"); 
    string dstFile = Path.Combine(LEAD_VARS.ImagesDir, "out.pdf"); 
 
    using (PdfCompressorEngine pdfCompressor = new PdfCompressorEngine()) 
    using (RasterCodecs codecs = new RasterCodecs()) 
    using (RasterImage image = codecs.Load(srcFile)) 
    { 
        pdfCompressor.Insert(image); 
        using (ILeadStream dstLeadStream = new Leadtools.LeadFileStream(dstFile, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite)) 
        { 
            Task task = Leadtools.PdfCompressor.PdfCompressorExtensions.WriteAsync(pdfCompressor, dstLeadStream); 
            task.Wait(); 
        } 
    } 
 
    Console.WriteLine("MainThread: WriteAsync returned..."); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 

Requirements

Reference to Leadtools.Async.dll and Leadtools.PdfCompressor.dll are required to use the extension in this class.

Target Platforms

See Also

PdfCompressorEngine.WriteAsync(ILeadStream)

PdfCompressorEngine.WriteAsync Overload List

PdfCompressorEngine.Write Overload List

PdfCompressorExtensions Members

Leadtools.PdfCompressor Namespace

Help Version 22.0.2023.3.31
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.PdfCompressor Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.