Do you own a Debenu Quick PDF Library 12/11/10/9/8/7? Upgrade to Debenu Quick PDF Library 13!

Foxit Quick PDF Library

Frequently Asked Question:

Return to FAQ Index

How to put an image inside a table cell?

Question

I want to put an image inside a table cell. Is there any way to achieve it?

Answer

It's not possible using the table functions to insert an image, however, you can take not of the co-ordinates of the table and draw an image in the right location after the table has been drawn. Here's some sample Delphi code:

// This code has to be executed after the DrawTableRows execution, 
// then is when we really know cell dimensions and position

// Get cell's left, top, width and heigth     
posXCell := QP.GetTableCellDblProperty(tableId, row, col, 101); 
posYCell := QP.GetTableCellDblProperty(tableId, row, col, 102);    
widthCell := QP.GetTableCellDblProperty(tableId, row, col, 103);    
heightCell := QP.GetTableCellDblProperty(tableId, row, col, 104);

// Select image    
QP.SelectImage(imgId);

// Calculate image dimensions in order to draw it inside cell    
wImage := widthCell;    
if wImage>QP.ImageWidth then wImage := QP.ImageWidth;

hImage := heightCell;    
if hImage>QP.ImageHeight then hImage := QP.ImageHeight;

ratio := QP.ImageWidth / QP.ImageHeight;
hImage := wImage/ratio;

QP.DrawImage(posXCell + 5, posYCell + heightCell - hImagen + 10, 
wImage - 10, hImage - 15);

© 2015 Debenu & Foxit. All rights reserved. AboutBuyContactBlogNewsletterSupportFAQProduct UpdatesForum