![]() ![]() 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) See the notes in the code for more details. Select the PDF file you want to make smaller. print it to the Adobe PDF printer using the desired page size), which is not a great option, or to scale it using a script, like this (paid-for) one Ive. In that case your options are to 're-fry' the file (ie. 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. How to Compress PDF to 300KB To resize PDF file to 300kb online you just have to follow the simple steps below. Click the Select a file button above, or drag and drop files into the drop zone. I need to resize a document (attached) from 6x9 to 8.5x11, but cant figure out to do this. It dynamically creates two images of different sizes with two red arrows stretching across both vertically and horizontally. Our easy-to-use online platform allows you to quickly convert, edit, and sign your PDF documents with just a few clicks. Site news and updates: OctoWe upgraded our servers and doubled the maximum allowed upload file size to 200MB. 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. 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(). 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.) Choose files Maximum combined file size: 100MB, up to 50 files Supported types: PDF, DOC, DOCX, ODT, PPT, PPTX (all files will be converted to PDF automatically) Sort and rearrange PDF pages online To reorder pages in PDF, upload your document and this tool will instantly display a grid list of all pages it contains. 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. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |