We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose pdf and images

Hi, I'm trying to get several images in a table, but the images shows up randomly, here is part of the code:

Dim imgX As New Aspose.Pdf.Image()
imgX.ImageInfo.File = Server.MapPath("../images/") & "test.jpg"
imgX.ImageInfo.ImageFileType = ImageFileType.Jpeg
for r = 0 to 25
oRow = New Aspose.Pdf.Row(oTbl)
oTbl.Rows.Add(oRow)
for c = 0 to 3
oCell = New Aspose.Pdf.Cell(oTbl)
oRow.Cells.Add(oCell)
if c = 0 then
oCell.Paragraphs.Add(imgX)
else
oCellText = New Aspose.Pdf.Text(oSection)
oCell.Paragraphs.Add(oCellText)
oCellSeg = New Aspose.Pdf.Segment(oCellText)
oCellText.Segments.Add(oCellSeg)
oCellSeg.Content = "Testing"
end if
next
next

There should be something else then oCell.Paragraphs.Add(imgX), what?

Hello Jan,

Thanks for considering Aspose.

we are looking into this matter and will reply to you soon. Sorry for your inconvenience.

Hi janlars,

I think I can fix this problem in about one week, sorry for the inconvenience caused by this problem.

Thanks.

Hi janlars,

I think you need to code like the below:


for r = 0 to 25
oRow = New Aspose.Pdf.Row(oTbl)
oTbl.Rows.Add(oRow)
for c = 0 to 3
oCell = New Aspose.Pdf.Cell(oTbl)
oRow.Cells.Add(oCell)
if c = 0 then

Dim imgX As New Aspose.Pdf.Image()
imgX.ImageInfo.File = Server.MapPath("../images/") & "test.jpg"
imgX.ImageInfo.ImageFileType = ImageFileType.Jpeg
oCell.Paragraphs.Add(imgX)
else
oCellText = New Aspose.Pdf.Text(oSection)
oCell.Paragraphs.Add(oCellText)
oCellSeg = New Aspose.Pdf.Segment(oCellText)
oCellText.Segments.Add(oCellSeg)
oCellSeg.Content = "Testing"
end if
next
next

The reason of images showing up randomly is that you add the same image object to the cell everytime, eventually, there is only one image in the table. When break the table into another page, a copy of the image is create, that is why each page has only one image.

If you still have some problems, Please let me know.

Thanks.