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). 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. Private void Form1_Load(object sender, EventArgs e) OneDrive PDF URL PDF & File Resizer Quickly Resize A PDF With this CocoDoc, you can immediately resize your PDF archives online for nothing. 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. See the notes in the code for more details. FEATURES Unlimited This PDF Compressor is free and provides you to use it unlimited times and compress PDF size online. 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) Online PDF resizer With this tool, you can instantly resize your PDF documents online for free (personal or business). 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. It dynamically creates two images of different sizes with two red arrows stretching across both vertically and horizontally. 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. 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) Or, you sack also resize your PDF of dragging and dropping PDF files directly for the resize a PDF convert box used click. ![]() (Also, if you happen to add anything else the image will be added relative to that, too.) 1 Choose files Select a PDF file to resize: upload the download from your computer or cloud storage service like Google Running or Dropbox. 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 |