Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Tue Mar 25, 2025 10:20 pm

I have an Image that I want to add to a Table Cell. Currently, I can calculate approximately where in coordinates I want to Image to be located. I am currently doing it like this:

Code: Select all
                        imageBarcode = PdfImage.FromImage(Encode(sWONum + "," + Convert.ToSingle(dr2["OpNum"].ToString()).ToString("0.00")));
                        xBarcodeLocation += pdfGridRow2.Height;
                        page.Canvas.DrawImage(imageBarcode, 18, xBarcodeLocation, 80, 80);


That works OK, but only for the first page. The table crosses multiple pages, so I'd really just like to attach the image to the Cell somehow. Is this possible?

.Net 4.5

Spire.PDF v11.3.0

tim8w123
 
Posts: 18
Joined: Wed Feb 22, 2023 3:55 pm

Wed Mar 26, 2025 2:03 am

Hello,

Thanks for your inquiry.
Sorry, there is no table object in the PDF specification. The table we draw is actually some closed lines, so if you want to insert the picture into the cell, you need to know the position of the inserted picture on each page in advance, just like the code you provided. If you cannot determine the coordinates of the picture on the second page, the picture cannot be inserted correctly. As a suggestion, you can set some placeholders in the document in advance, find the positions of these placeholders before inserting the picture, and then insert the picture into these positions.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 757
Joined: Mon Dec 27, 2021 2:23 am

Return to Spire.PDF