![]() And obviously you need to replace the file paths too. ![]() The working example above is in a web environment (.ashx HTTP handler), so you need to replace Response.OutputStream above with a FileStream (from your code snippet). Private void Form1_Load(object sender, EventArgs e) You can choose from standard paper sizes (A3, A4, A5, etc.) or create a custom page size, based on your requisites. This quick tool with a few clicks changes your documents' paper size. See the notes in the code for more details. OneDrive PDF URL PDF & File Resizer Quickly Resize A PDF With this CocoDoc, you can immediately resize your PDF archives online for nothing. Your code would obviously just use standard image loading and could thus omit a lot of this but I wanted to deliver a full working example. Or, you can also resize your PDF by dragging and dropping PDF files directly into the resize a PDF convert box for upload. It dynamically creates two images of different sizes with two red arrows stretching across both vertically and horizontally. 1 Choose file Select a PDF file to resize: upload the file from your computer or cloud storage service like Google Drive or Dropbox. Site news and updates: OctoWe upgraded our servers and doubled the maximum allowed upload file size to 200MB. Security All files uploaded by you will be automatically permanently erased from our servers after 2 hours. So, It takes less time to compress all the selected PDFs. Fast Compression Its compression processing is powerful. Then you can access the DirectContent property of the PdfWriter and call its AddImage() method: (img) īefore doing this you must also absolutely position the image by calling: img.SetAbsolutePosition(0, 0) īelow is a full working C# 2010 WinForms app targeting iTextSharp 5.1.1.0 that shows the DirectContent method above. PDF editor allows you to instantly split and merge, optimize, crop, resize, and convert your documents online with just a couple of clicks. FEATURES Unlimited This PDF Compressor is free and provides you to use it unlimited times and compress PDF size online. You're currently throwing away and not storing that object but you can easily change your line to: PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(saveFileDialog1.FileName,FileMode.Create)) ![]() Instead, it's easier to add the image directly to the PdfWriter object which you get from calling PdfWriter.GetInstance(). The software will automatically shrink your file. One solution would be to just remove the margins: doc.SetMargins(0, 0, 0, 0) ![]() (Also, if you happen to add anything else the image will be added relative to that, too.) Unfortunately for you, this also means that when you call doc.Add() it takes into account existing margins of the document. The Document object in iText and iTextSharp is an abstraction that takes care of various spacings, paddings and margins for you automatically. ![]()
0 Comments
Leave a Reply. |