Contains an asynchronous extension to write PDF content to a LEAD stream. PdfCompressorExtensions is an abstract class and cannot be created directly.
public abstract PdfCompressorExtensions
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.
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";
}
Reference to Leadtools.Async.dll and Leadtools.PdfCompressor.dll are required to use the extension in this class.
PdfCompressorEngine.WriteAsync(ILeadStream)
PdfCompressorEngine.WriteAsync Overload List
PdfCompressorEngine.Write Overload List