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.

Fri Mar 03, 2023 2:07 am

Hi,

I'm using the current .NET version of Spire.Pdf,

After inserting a Table to the document, I would like to and some additional Text, but I can't find the Position for inserting my text.

Is there any workaround or best practice?

best regards,
Chris

ChristianFreund
 
Posts: 1
Joined: Fri Mar 03, 2023 1:58 am

Fri Mar 03, 2023 8:36 am

Hi,

Thanks for your inquiry.
Currently we can’t get the table position by calling PdfTableExtractor. ExtractTable(pageIndex), but you can find the text near or in the table to get the approximate position of the table, then you can adjust the position to the place where you want to add some texts. Please see the following code for reference.
Code: Select all
                PdfDocument pdf = new PdfDocument();
                pdf.LoadFromFile("test.pdf");
                PdfTextFind[] result = null;
                PdfPageBase page = pdf.Pages[0];
                //Find the text near the table
                result = page.FindText("test", TextFindParameter.None).Finds;
                PdfTextFind pdfTextFind = result[0];
                //get the position
                float x = pdfTextFind.Position.X;
                float y = pdfTextFind.Position.Y;

If the code does not meet your requirement, please share your test document with us to help us work out a solution for you. Thanks for your assistance.

Sincerely,
Triste
E-iceblue support team
User avatar

Triste.Dai
 
Posts: 1000
Joined: Tue Nov 15, 2022 3:59 am

Return to Spire.PDF