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 9172895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:27:45+00:00 2026-06-17T16:27:45+00:00

I’m creating a PDF using iTextSharp for check-printing purposes. My issue is that I

  • 0

I’m creating a PDF using iTextSharp for check-printing purposes. My issue is that I cannot get the name/address to print on the check where the little window is on the envelope for the check. The spacing between the address lines is too big. I am setting the line-height in a font tag in the HTML document, but it is not being carried over.

Here is the address part, specifically:

            conn.Open();
            using (SqlDataReader itemReader = strSQL.ExecuteReader())
            {
                checksHolder.InnerHtml += "<table cellSpacing=\"0\" cellPadding=\"0\" border=\"0\" width=\"100%\">\n";

                while (itemReader.Read())
                {

                    if (i % 3 == 0 && i != 0)
                    {
                        checksHolder.InnerHtml += "</table>\n";
                        checksHolder.InnerHtml += "<!-- pagebreak -->\n";
                        checksHolder.InnerHtml += "<table cellSpacing=\"0\" cellPadding=\"0\" border=\"0\" width=\"100%\">\n";
                        f = 0;
                    }

                    if (i > 0 && i % 3 != 0)
                    {
                        checksHolder.InnerHtml += "<tr><td colspan=\"3\"><br/><br/><br/><br/><br/><br/>";
                        checksHolder.InnerHtml += "</td></tr>\n";
                    }

                    String[] tmpArray = getConsignorInfo(itemReader["check_cs_id"].ToString());

                    int CheckNum = Int32.Parse(itemReader["check_number"].ToString());
                    String CheckAmount = itemReader["check_amount"].ToString();
                    String PayableTo = tmpArray[0];
                    String Memo = itemReader["check_memo"].ToString();

                    String name = tmpArray[0];
                    String address = tmpArray[1];
                    String city = tmpArray[2];
                    String state = tmpArray[3];
                    String zip = tmpArray[4];

                    Char NBSP = '\u00A0';

                    checksHolder.InnerHtml += "<tr><td colspan=\"3\"><br/><br/></td></tr>\n";
                    checksHolder.InnerHtml += "<tr>\n";
                    //checksHolder.InnerHtml += "<td width=\"5\"></td>\n";
                    checksHolder.InnerHtml += "<td colspan=\"2\">\n";
                    checksHolder.InnerHtml += "<font size=\"2\">\n";
                    checksHolder.InnerHtml += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n";
                    checksHolder.InnerHtml += PayableTo + "</font>\n";
                    checksHolder.InnerHtml += "</td>\n";
                    checksHolder.InnerHtml += "<td align=\"right\">\n";
                    checksHolder.InnerHtml += "<font align=\"right\" size=\"2\">" + string.Format("{0:c}", Double.Parse(CheckAmount.ToString())).Replace("$", "") + "</font>\n";
                    checksHolder.InnerHtml += "</td>\n";
                    checksHolder.InnerHtml += "</tr>\n";
                    checksHolder.InnerHtml += "<tr>\n";
                    checksHolder.InnerHtml += "<td colspan=\"3\">\n";
                    checksHolder.InnerHtml += "&nbsp;\n";
                    checksHolder.InnerHtml += "</td>\n";
                    checksHolder.InnerHtml += "</tr>\n";
                    checksHolder.InnerHtml += "<tr>\n";
                    checksHolder.InnerHtml += "<td colspan=\"3\">\n";
                    checksHolder.InnerHtml += "<font size=\"2\">";
                    if (wordify(decimal.Parse(CheckAmount.ToString())).Length >= 90)
                    {
                        checksHolder.InnerHtml += wordify(decimal.Parse(CheckAmount.ToString()));
                    }
                    else
                    {
                        string exes = " ";
                        for (int x = wordify(decimal.Parse(CheckAmount.ToString())).Length; x <= 90; x++)
                        {
                            exes += "x";
                        }
                        checksHolder.InnerHtml += wordify(decimal.Parse(CheckAmount.ToString())) + exes;
                    }
                    checksHolder.InnerHtml += "</font>\n";
                    checksHolder.InnerHtml += "</td>\n";
                    checksHolder.InnerHtml += "</tr>\n";
                    checksHolder.InnerHtml += "<tr>\n";
                    checksHolder.InnerHtml += "<td colspan=\"2\">\n";

                    checksHolder.InnerHtml += "<table cellSpacing=\"0\" cellPadding=\"0\" border=\"0\" width=\"100%\">\n";
                    checksHolder.InnerHtml += "<tr>\n";
                    checksHolder.InnerHtml += "<td colspan=\"2\"><br/>\n";
                    checksHolder.InnerHtml += "<font size=\"2\" line-height=\"8p\">" + name + "<br/>\n";
                    checksHolder.InnerHtml += address + "<br/>\n";
                    checksHolder.InnerHtml += city + ",\n";
                    checksHolder.InnerHtml += state + " \n";
                    checksHolder.InnerHtml += zip + "</font>\n";
                    checksHolder.InnerHtml += "</td>\n";
                    checksHolder.InnerHtml += "</tr>\n";

                    checksHolder.InnerHtml += "<tr>\n";
                    checksHolder.InnerHtml += "<td colspan=\"3\">\n";
                    checksHolder.InnerHtml += "<br/></td>\n";
                    checksHolder.InnerHtml += "</tr>\n";

                    checksHolder.InnerHtml += "<tr>\n";
                    checksHolder.InnerHtml += "<td width=\"10\"></td>\n";
                    checksHolder.InnerHtml += "<td>\n";
                    checksHolder.InnerHtml += "<font size=\"2\">" + Memo.Substring(0, 50) + "...</font>\n";
                    checksHolder.InnerHtml += "</td>\n";
                    checksHolder.InnerHtml += "</tr>\n";
                    checksHolder.InnerHtml += "</table>\n";

                    checksHolder.InnerHtml += "</td>\n";
                    checksHolder.InnerHtml += "<td valign=\"bottom\" width=\"40\">\n";
                    checksHolder.InnerHtml += "<img valign=\"bottom\" align=\"left\" src=\"images/wesSig.png\" Alt=\"\" /><br/>\n";
                    checksHolder.InnerHtml += "</td>\n";
                    checksHolder.InnerHtml += "</tr>\n";


                    i++;
                    f++;
                }

                checksHolder.InnerHtml += "</table>\n";

                itemReader.Close();
            }

public void CreatePDFDocument(string strHtml)
{
    string strFileName = HttpContext.Current.Server.MapPath("printCheck.pdf");
    // step 1: creation of a document-object

    iTextSharp.text.Rectangle rec = new iTextSharp.text.Rectangle(612, 792);
    Document document = new Document(rec);
    document.SetMargins(45f, 30f, 55f, 30f);

    // step 2:
    // we create a writer that listens to the document
    var pdfWriter = PdfWriter.GetInstance(document, new FileStream(strFileName, FileMode.Create));
    pdfWriter.InitialLeading = 12.5f;

    string[] stringSeparators = new string[] { "<!-- pagebreak -->" };
    //Response.Write(strHtml);
    string[] newString = strHtml.Split(stringSeparators, StringSplitOptions.None);

    //HTMLWorker obj = new HTMLWorker(document);

    document.Open();

    var xmlWorkerHelper = XMLWorkerHelper.GetInstance();
    var cssResolver = new StyleAttrCSSResolver();
    var xmlWorkerFontProvider = new XMLWorkerFontProvider();

    var cssAppliers = new CssAppliersImpl(xmlWorkerFontProvider);
    var htmlContext = new HtmlPipelineContext(cssAppliers);
    htmlContext.SetTagFactory(Tags.GetHtmlTagProcessorFactory());

    PdfWriterPipeline pdfWriterPipeline = new PdfWriterPipeline(document, pdfWriter);
    HtmlPipeline htmlPipeline = new HtmlPipeline(htmlContext, pdfWriterPipeline);
    CssResolverPipeline cssResolverPipeline = new CssResolverPipeline(cssResolver, htmlPipeline);
    XMLWorker xmlWorker = new XMLWorker(cssResolverPipeline, true);
    XMLParser xmlParser = new XMLParser(xmlWorker);

    int i = 0;
    foreach (String currentString in newString) {
        if (i > 0)
        {
            document.NewPage();
        }

        StringReader sr = new StringReader(currentString);
        xmlParser.Parse(sr);

        i++;
    }

    document.Close();

    ShowPdf(strFileName);
}

I only have half an inch to put the name/address into. I’ve tried specifying the line-height with both 8px and just 8 just in case. Nothing worked. Does anyone know how I need to format the HTML to have the line height carried over? Thanks in advance.

  • 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-06-17T16:27:46+00:00Added an answer on June 17, 2026 at 4:27 pm

    I upgraded to itextsharp’s xmlworker (http://sourceforge.net/projects/xmlworker/) which allows me to use css and div tags. Margin doesn’t work, unfortunately, but padding does, so I was able to do what I needed to do.

    • 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'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am using JSon response to parse title,date content and thumbnail images and place
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... 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.