Java
  Home arrow Java arrow Page 2 - Adding Images With iTextSharp
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
JAVA

Adding Images With iTextSharp
By: Peyton McCullough
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 10
    2008-07-01


    Table of Contents:
  • Adding Images With iTextSharp
  • Adding padding and a border
  • Manipulating an Image
  • An example

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Adding Images With iTextSharp - Adding padding and a border
    ( Page 2 of 4 )

    Sometimes, it's necessary to put some space between the image and other content. This is done just as with a Paragraph. Like a Paragraph, an Image has IndentationLeft, IndentationRight, SpacingBefore, and SpacingAfter properties that can be used to pad the image. Here, we create half an inch of padding on all sides:

    logo.IndentationLeft = 36;

    logo.IndentationRight = 36;

    logo.SpacingBefore = 36;

    logo.SpacingAfter = 36;

    Note that adding padding will have no effect if there's nothing in the direction of the padding. For example, adding padding to the right of an image that's aligned to the right won't add extra space.

    Another technique that helps to set an image apart is adding a border to it. There are at least two steps involved in adding a border around an image. The first step is to set the Border property to specify what sides of the image will need a border. The binary OR operator can be used to combine Image.LEFT_BORDER, Image.RIGHT_BORDER, Image.TOP_BORDER, and Image_BOTTOM_BORDER to create the appropriate border. Here, we create a border around all sides of an image:

    logo.Border = Image.LEFT_BORDER | Image.TOP_BORDER |

     Image.RIGHT_BORDER | Image.BOTTOM_BORDER;

    The next step is to set the width of the border in points. Here, we set the border to be one point wide:

    logo.BorderWidth = 1;

    This will create a black border around all sides of the image. However, it's possible to specify a width for each side individually:

    logo.BorderWidthLeft = 1;

    logo.BorderWidthRight = 1;

    logo.BorderWidthTop = 1;

    logo.BorderWidthBottom = 1;

    These first two steps will create a black border around the image. Of course, black may not work in all situations, so it's possible to specify another color. Below, a border is set to red:

    logo.BorderColor = Color.RED;

    This will make the entire border red. As with width, though, each side can be colored differently:

    logo.BorderColorLeft = Color.LIGHT_GRAY;

    logo.BorderColorTop = Color.GRAY;

    logo.BorderColorRight = Color.DARK_GRAY;

    logo.BorderColorBottom = Color.BLACK;



     
     
    >>> More Java Articles          >>> More By Peyton McCullough
     

       

    JAVA ARTICLES

    - Exception Handling Techniques in Java
    - More About Multithreading in Java
    - The Basics of Multiple Threads in Java
    - Data Access Using Spring Framework JDBC
    - New Object Initialization in Java
    - Adding Images With iTextSharp
    - Adding Columns With iTextSharp
    - Creating Simple PDF Files With iTextSharp
    - The Spring Framework: Understanding IoC
    - Introducing the Spring Framework
    - Java Classes
    - Completing the Syntactic Comparison of Java ...
    - Syntactic Comparison of Java and C/C++
    - Java Statements
    - Conditionals, Expressions and Other Java Ope...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek