![]() The stronger compression mode is a premium option, but luckily, we offer 7-day free trials for those who need the tool immediately. ![]() #PDF SIZE REDUCER 150 KB PDF#But if the tool’s not able to compress your larger PDFs down to 300KB or less, there’s always the strong compression option to save the day.Īnd don’t worry about file size caps-we can upload and shrink PDF files up to a whopping 5GB per file. This should be more than enough for most PDFs. ImageCodecInfo codecs = ImageCodecInfo.The basic compression mode will compress your PDF file substantially–while maintaining the content in a near-identical version as it was in the original PDF format. Private ImageCodecInfo GetEncoder(ImageFormat format) Image1.ImageUrl = /Uploaded-Files/tn_" filename Label.Text = " File Size: ^_b style="color: red " >" () " " Write a message to inform the user all is OK Once finished with the bitmap objects, we deallocate them. NewBMP.Save(directory " tn_" filename) Save the new graphic file to the server OGraphics.DrawImage(originalBMP, 0, 0, newWidth, newHeight) Draw the new graphic based on the resized bitmap OGraphics.SmoothingMode = SmoothingMode.AntiAlias oGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic Set the properties for the new graphic file Graphics oGraphics = Graphics.FromImage(newBMP) Create a graphic based on the new bitmap Create a new bitmap which will hold the previous resized bitmapīitmap newBMP = new Bitmap(originalBMP, newWidth, newHeight) ![]() int newHeight = newWidth / sngRatio int newHeight = 320 Calculate the new image dimensions int origWidth = originalBMP.Width Create a bitmap of the content of the fileUpload control in memoryīitmap originalBMP = new Bitmap( c:\TestPhotoQualityZero.jpg") Specify the upload directory string directory = Server.MapPath( Uploaded-Files\") If it doesn't then we just create it before going any furtherĭirectory.CreateDirectory(MapPath( Uploaded-Files")) Check if the directory we want the image uploaded to actually exists or not if (!Directory.Exists(MapPath( Uploaded-Files"))) Find the fileUpload control string filename = fileUpload.FileName MyEncoderParameters.Param = myEncoderParameter īmp1.Save( c:\TestPhotoQualityZero.jpg", jgpEncoder, myEncoderParameters) EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 50L) // myEncoderParameters.Param = myEncoderParameter // jgpEncoder, myEncoderParameters) // myEncoderParameter = new EncoderParameter(myEncoder, 100L) // myEncoderParameters.Param = myEncoderParameter // jgpEncoder, myEncoderParameters) // Save the bitmap as a JPG file with zero quality level compression.ĮncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 25L) In this case, there is only one // EncoderParameter object in the array.ĮncoderParameters myEncoderParameters = new EncoderParameters( 1) An EncoderParameters object has an array of EncoderParameter // objects. Create an Encoder object based on the GUID // for the Quality parameter category. ImageCodecInfo jgpEncoder = GetEncoder(ImageFormat.Jpeg) #PDF SIZE REDUCER 150 KB CODE#Copy Code protected void uploadButton_Click( object sender, EventArgs e)īitmap bmp1 = new Bitmap(fileUpload.FileContent)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |