Free Support Forum - aspose.com

Help! Problem in displaying full image in pdf on html (containing table) bound

Hi,

We are using the code below to bind html to the pdf. When the html has a table and an image inside a td tag, the image in the td is not shown fully on the generated pdf. e.g: There is a table with two tr's and 2 td'd in each tr. The first td in the first row has some text in it and the second td has an image. when the pdf is generated, we only see half of the image shown in the pdf . please have a look at the code below used to convert html to pdf. How do we display the complete image.

Regards,

DSR

Please have a look at the code below for generating pdf from html (containg image in a td):

///

/// This method is used to bind the article abstract with any images

/// to the PDF document from a Memory stream.

///

public void BindArticleAbstract()

{

//DSRReportData dsReportData = new DSRReportData();

//List articleAbstract = dsReportData.PopulateDataArticleAbstract(dtReportDate, 2);

DSRReportBusiness dsReportData = new DSRReportBusiness();

List articleAbstract = dsReportData.ArticleAbstract(dtReportDate, 2);

Text SecText = new Text("");

SecText.ID = "Article0";

Section objSection = objPdf.Sections.Add();

objSection.IsNewPage = true;

objSection.Paragraphs.Add(SecText);

int iSummaryNo = 0;

foreach (string sArticleAbstract in articleAbstract)

{

if(iSummaryNo !=0)

{

Text SecText1 = new Text("");

SecText1.ID = "Article" + iSummaryNo.ToString();

Section objFirstSec = objPdf.Sections[objPdf.Sections.Count - 1];

objFirstSec.Paragraphs.Add(SecText1);

}

string sAbstract = null;

sAbstract = sAbstract + "

" + sArticleAbstract;

sAbstract = sAbstract.Replace("\r\n", " ");

sAbstract = ModifyImageURL(sAbstract);

byte[] by = System.Text.Encoding.UTF8.GetBytes(sAbstract);

MemoryStream ms = new MemoryStream(by);

// Binding memory stream to a PDF file as HTML.

objPdf.BindHTML(ms);

Section objLastSec = objPdf.Sections[objPdf.Sections.Count - 1];

objLastSec.Paragraphs.Add(new Text(""));

objLastSec.Paragraphs.Add(new Text(""));

Aspose.Pdf.Table objTbl = new Aspose.Pdf.Table(objLastSec);

objTbl.ColumnWidths = "100%";

objTbl.Border = new BorderInfo((int)(BorderSide.Top), 1F, new Color("Grey"));

Row row = objTbl.Rows.Add();

Cell cell = row.Cells.Add("");

objLastSec.Paragraphs.Add(objTbl);

//if (iSummaryNo != 0)

// {

objLastSec.IsNewPage = false;

//}

iSummaryNo = iSummaryNo + 1;

}

}

}

Hi,

Can you please save the html to a file and send it to us along with the image so that we can more accurately figure out the cause of the problem.

Thanks.