Free Support Forum -

Add multiline texts at specified location without overlapping the existing pdf content

Specified location like top left/top center/top right/bottom left/bottom center/bottom right and Text should not overlap other pdf content. I used table and floating box.
FloatingBox floatingBox = new FloatingBox();
Aspose.Pdf.Table table = new Aspose.Pdf.Table();
table.ColumnWidths = (“400”);
table.Left = 10;
table.Top = 10;
table.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Justify;
Aspose.Pdf.Row row = table.Rows.Add();
Aspose.Pdf.Cell cell = row.Cells.Add();
It works for top left. while I tried for bottom(left/right/center). It gives excessive space at the bottom and at the right side of both top and bottom.
//code for bottom left
table.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Left;
table.VerticalAlignment = Aspose.Pdf.VerticalAlignment.Bottom;
table.Top = 700;
table.Left = 10;
//code for bottom center
table.Top = 680;
table.VerticalAlignment = Aspose.Pdf.VerticalAlignment.Bottom;
table.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center;
//code for bottom right
table.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Right;
table.VerticalAlignment = Aspose.Pdf.VerticalAlignment.Bottom;
table.Top = 650;
table.Left = (float)page.Rect.Width / 2 - 100;
how can I remove unwanted spaces? and
Is there any way to achieve my results? Please any help would be appreciated.


Would you kindly explain a bit more about your requirement by sharing a sample source PDF along with expected output document. We will test the scenario in our environment and address it accordingly.

AUTOMATIC TEXT SUMMARIZER USING LSTM by lisalujinamonika.pdf (227.7 KB)

first question:
this is the pdf and I need to add text (text with multiple lines)eg. "Historically in SharePoint, we just had what’s now known as “classic” SharePoint Sites. Most of my
blog posts are about them. They were and still are a great way to create department sites, document repositories, etc. " on topleft of the page of pdf and center/bottomleft/bottomcenter/bottomright/topcenter and topright. These added lines should not overlap existing text on the pdf. The problem with excessive spaces on the bottom of the pdf is solved when I used textstamp to add these texts.

Second question:
How can I add texts at specific location without overlapping other content of pdf? TextInMerge.pdf (268.4 KB)

similarly to above pdf but added text between sentences in any paragraphs, at the end of paragraph.

please suggest me solutions. Thank you


We have used the following code snippet in order to add the text at your mentioned positions inside the PDF document:

Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(dataDir + "AUTOMATIC TEXT SUMMARIZER USING LSTM by lisalujinamonika.pdf");

TextStamp textStamp = new TextStamp(@"Historically in SharePoint, we just had what’s now known as “classic” SharePoint Sites. Most of my
blog posts are about them.They were and still are a great way to create department sites, document repositories, etc.");
textStamp.WordWrap = true;
textStamp.Width = 100;
textStamp.Background = false;
textStamp.TextState.ForegroundColor = Color.FromArgb(100, 255, 0, 0);
textStamp.Opacity = 0.5f;

// top left
textStamp.HorizontalAlignment = HorizontalAlignment.Left;
textStamp.VerticalAlignment = VerticalAlignment.Top;

// center
textStamp.HorizontalAlignment = HorizontalAlignment.Center;
textStamp.VerticalAlignment = VerticalAlignment.Center;

// bottom left
textStamp.HorizontalAlignment = HorizontalAlignment.Left;
textStamp.VerticalAlignment = VerticalAlignment.Bottom;

// bottom center
textStamp.HorizontalAlignment = HorizontalAlignment.Center;
textStamp.VerticalAlignment = VerticalAlignment.Bottom;

// bottom right
textStamp.HorizontalAlignment = HorizontalAlignment.Right;
textStamp.VerticalAlignment = VerticalAlignment.Bottom;

// top right
textStamp.HorizontalAlignment = HorizontalAlignment.Right;
textStamp.VerticalAlignment = VerticalAlignment.Top;

// top center
textStamp.HorizontalAlignment = HorizontalAlignment.Center;
textStamp.VerticalAlignment = VerticalAlignment.Top;
pdfDocument.Save(dataDir + "normalstamp.pdf");

normalstamp.pdf (231.6 KB)

Regarding your above requirements, would you please confirm if you want to shift the PDF content accordingly while adding stamps?

You can add text using TextFragment and specify its position by the Position property. But again, would you please clarify for our better understandings - do you want to move the other text/content of the PDF accordingly after adding new text. We will check related information at our side and share it with you.

Thank you for the solutions. It really helps to add text where I wanted. Yes I want to move the other text/content of the PDF accordingly after adding new text so that it solves overlapping problem. How can it be done?


Thanks for your feedback.

We are afraid that moving text/content of the PDF by adding a text stamp would not be feasible as it is added on a different layer inside PDF. Furthermore, text adjustments can be made during replacement operations and we assume that you do not want to replace the text but to add new. Nevertheless, would you kindly care to provide one sample PDF (which is your expected output) so that we can further investigate the feasibility of your requirements and share our feedback with you.

AsposeUtilityImportedAnnotations_output1.pdf (1.9 MB)

Please update me soon.
Thank you


This PDF is different than the PDF which you had shared earlier. Nevertheless, please check following code snippet which we used to resize the content of first page of the PDF which was shared earlier. You can notice in the output that now there is more space around exisiting content where you can add text stamp.

Document doc = new Document(dataDir + "AUTOMATIC TEXT SUMMARIZER USING LSTM by lisalujinamonika.pdf");

Facades.PdfFileEditor fileEditor = new Facades.PdfFileEditor();

// Specify Parameter to be used for resizing
Facades.PdfFileEditor.ContentsResizeParameters parameters = new Facades.PdfFileEditor.ContentsResizeParameters(
            // Left margin = 10% of page width
            // New contents width calculated automatically as width - left margin - right margin (100% - 10% - 10% = 80%)
            // Right margin is 10% of page
            // Top margin = 10% of height
            // New contents height is calculated automatically (similar to width)
            // Bottom margin is 10%

// Resize Page Contents
fileEditor.ResizeContents(doc, new int[] { 1 }, parameters);

dataDir = dataDir + "size_pdf_out.pdf";
// Save the document

size_pdf_out.pdf (228.7 KB)

In case you have further requirements, please let us know.