Hello,

 

I updated my application to use the updated version of iTextSharp (5.0.1.1) 
only to find that code that I used to insert an image at an absolute position 
no longer shows the image. I updated to 5.0.2 as well, and still encounter the 
same issue.

 

I receive no exceptions from my code nor does Acrobat report any syntax issues 
with the generated PDF. The code adds an image (loaded from a PDF) and places 
it at the lower-left-hand corner of the table on the TableLayout event. In the 
handler I also draw a dashed border around the table, which continues to work 
as expected, just my image isn't visible any longer. My code is as follows:

 

 

public void TableLayout(PdfPTable table, float[][] width, float[] heights, int 
headerRows, int rowStart, PdfContentByte[] canvases)

{


float[] widths = width[0];

PdfContentByte cb = canvases[PdfPTable.TEXTCANVAS];

PdfGState gState = null;

gState = new PdfGState();

gState.FillOpacity = 1f;

gState.StrokeOpacity = 1f;

 

cb.SaveState();

cb.SetLineWidth(1f);

cb.SetRGBColorStroke(0, 0, 0);

cb.SetLineDash(4f, 2f, 0f);

cb.Rectangle(widths[0], heights[heights.Length - 1], widths[widths.Length - 1] 
- widths[0], heights[0] - heights[heights.Length - 1]);

cb.Stroke();

 

PdfReader reader = new PdfReader(iconsFolderPath + "myicons.pdf");

PdfImportedPage importedPage = writer.GetImportedPage(reader, 1);

Image icon = Image.GetInstance(importedPage);

 

cb.SetGState(gState);

icon.Alignment = Image.ALIGN_LEFT | Image.ALIGN_TOP;

icon.SetAbsolutePosition(widths[0] - (icon.ScaledWidth / 2f), 
heights[heights.Length - 1] - (icon.ScaledHeight / 2f) - 2f);

cb.AddImage(icon);

 

cb.RestoreState();

 

// clean-up

importedPage = null;

icon = null;

reader.Close();

reader = null;

}
 
Any help in correcting this would be appreciated. Thank you.
 
Mark
 
                                          
_________________________________________________________________
Game on: Challenge friends to great games on Messenger
http://go.microsoft.com/?linkid=9734387
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to