Java
  Home arrow Java arrow Page 2 - Adding Images With iTextSharp
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
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? 
JAVA

Adding Images With iTextSharp
By: Peyton McCullough
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 5
    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:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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


       · Hello, all,This is yet another article on using the iTextSharp library to create...
       · Thanks for this tutorial.I would just need to know one more thing : is it possible...
       · You mean to flip the image (mirror it) horizontally?Yes, it's possible, and...
       · Yes, it's what I meant (flipping the image horizontally or mirror it).For now, I...
     

       

    JAVA ARTICLES

    - 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...
    - Java Operators
    - Primitive Data Types and Basic Language Rule...
    - Java and Object-Oriented Programming
    - Java Beginning Programming





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT