Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6719247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:04:12+00:00 2026-05-26T09:04:12+00:00

We’re using ITextSharp for reasons I do not understand and we dont have the

  • 0

We’re using ITextSharp for reasons I do not understand and we dont have the book yet and I have an annoying problem that I’d appreciate help with.

I’m working with a footer and I can not get it to align as I want it.

The function I have takes a list of strings, but it’s generally 4 strings I want on a row each. It does not seam like itextsharp can handle strings with linebreaks so that’s the reason for the list.

Now this does not position correctly for me, the first string looks ok, but then the second string is a bit longer and it’s half outside the document as is the third string and the 4th is not even visible even thou there is 1 cm of space left.

Thanks for help!

public PdfTemplate AddPageText(IList<string> stringList, PdfWriter writer) 
{
    var cb = writer.DirectContent;
    PdfTemplate footerTemplate = cb.CreateTemplate(450, 120); //55);

    footerTemplate.BeginText();
    BaseFont bf2 = BaseFont.CreateFont(BaseFont.TIMES_ITALIC, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
    footerTemplate.SetFontAndSize(bf2, 9);
    footerTemplate.SetColorStroke(BaseColor.DARK_GRAY);
    footerTemplate.SetColorFill(BaseColor.GRAY);

    footerTemplate.SetLineWidth(3);
    footerTemplate.LineTo(50, footerTemplate.YTLM);

    int y = 10;
    foreach (string text in stringList)
    {
        float widthoftext = 500.0f - bf2.GetWidthPoint(text, 9);
        footerTemplate.ShowTextAligned(PdfContentByte.ALIGN_RIGHT, text, widthoftext, 50 - y, 0);
        y += y;
    }
    footerTemplate.EndText();

    return footerTemplate;

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:04:12+00:00Added an answer on May 26, 2026 at 9:04 am

    If you are doing string placement and using DirectContent then you are responsible for the content. In this case you will need to calculate the string rectangles and wrap accordingly.

    I would suggest, however, moving to using a table with cells for the text. Tables wrap text and handle some of the issues you are dealing with.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I have thousands of HTML files to process using Groovy/Java and I need to
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.