Position = 0 //Defining the ContentType for pdf file. Close ( true ) //If the position is not set to '0' then the PDF will be empty. Compress ( options ) //Creating the stream object MemoryStream stream = new MemoryStream () //Save the document into stream. ImageQuality = 50 //Assign the compression option to the document loadedDocument. CompressImages = true //Set the image quality. PdfCompressionOptions options = new PdfCompressionOptions () //Enable the compress image. Read ) //Load the existing PDF document PdfLoadedDocument loadedDocument = new PdfLoadedDocument ( docStream ) //Create a new compression option. Load an existing PDF FileStream docStream = new FileStream ( "Input.pdf", FileMode. The following example code snippet illustrates how to compress the images in existing PDF document. The ImageQuality property is used to reduce the quality of the image based on percentage value, where 100 is unchanged quality and 10 is low quality. You can compress all the images of an existing PDF document by enabling the CompressImages property and assigning ImageQuality available in PdfCompressionOptions class. NET Core, you need to include assembly reference in. To compress the existing PDF document in. The following compression techniques are used to compress the existing PDF document. You can compress the existing PDF document by using PdfLoadedDocument and PdfCompressionOptions. PDF supports compressing PDF document only in Windows Forms, WPF, ASP.NET and ASP.NET MVC platforms. Image.Compress(.Essential PDF allows you to compress the PDF document and thereby reduce the file size in the following three ways. if image is black-white if (image.PixelFormat = ) PdfCompressionSettings compressionSettings = public static void ChangeCompressionBlackWhiteImages( string pdfFilename) / /// Changes compression of all black-white image-resources of PDF document. Here is an example that demonstrates how to change the compression algorithm of all black-white image resources: call PdfImageResource.Compress method to change the compression algorithm of image resource.To change the compression algorithm of image resource it is necessary to do the following: Graphics.DrawImage(imageResource, New (100, 100, 200, 300))Įnd Using End Using ' save changes to a file ' create image-resource based on image Dim imageResource As New. ' get PDF graphics of PDF page Using graphics As. ' open image Using image As New Vintasoft.Imaging. ' open PDF document Using document As New. Public Shared Sub DrawImageOnPdfPage(pdfFilename As String, imageFilename As String) PdfImageResource(ĭocument, image, .Auto) PdfGraphics graphics = page.GetGraphics()) public static void DrawImageOnPdfPage( string pdfFilename, string imageFilename) Here is an example that demonstrates how to draw a new image on PDF page:
0 Comments
Leave a Reply. |