vendredi 27 février 2015

ABCPDF Position of image in center of page

I Use AbcPdf, when I export HTML with images to pdf I use css to positioning image into center of page



<div class="alignToCenter">
<%foreach (var item in images)
{%>
<div style="padding-left: 5px;">
<div style="page-break-before:always">&nbsp;</div>
<img src="<%= @"data:image/gif;base64," + item.ToString() %>" />
</div>
<%} %>
</div>


here is alignToCenter css



.alignToCenter{
height:100px;
/*background-color: red;*/
text-align: center;
position: absolute;
top:0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}


Now I want to add images using XImage



foreach (var item in exportPhotos)
{
theDoc.Page = theDoc.AddPage();
XImage image = new XImage();
image.SetFile("path"+ item);

theDoc.Rect.String = image.Selection.String;
theDoc.HtmlOptions.PageCacheEnabled = false;

int theID2 = theDoc.AddImage(image);

while (true)
{
theDoc.FrameRect();
if (!theDoc.Chainable(theID2))
break;
theDoc.Page = theDoc.AddPage();
theID2 = theDoc.AddImageToChain(theID2);
}
}


images is added but I need to display in center of the page,.. and if the Image is very big then I need to resize image


Aucun commentaire:

Enregistrer un commentaire