Enhancing Document Formatting: Utilizing “text-align: center” for Neat and Organized Tables in PDF Generation

The provided HTML code represents a table structure for document formatting, likely intended for generating a PDF.

Let’s elaborate on the use of “text-align: center” within the “p” tag to correct the alignment of data.

In HTML, the “text-align” property is used to define the horizontal alignment of text content within an element.

In this case, “text-align: center” is applied to the “p” (paragraph) tag inside each table cell (“<td>”).

  • P.O. No.:The first row of the table contains headers, such as “P.O. No.,” “Terms,” “Ship Date,” “Due Date,” “Ship Via,” and “Shipping Point.” The “text-align: center” style is applied to ensure that the text content within each header cell is horizontally centered.
  • Data Cells:The second row contains actual data corresponding to the headers. For example, “${record.otherrefnum}” represents the purchase order number. The “text-align: center” style is employed within each “p” tag to correct the alignment of data, ensuring that the content is centered within its respective cell.
  • This is particularly useful when dealing with data that might be stretched, misplaced, or exhibit extra spaces in the generated PDF.

By using “text-align: center,” the design aims to present the data in a neat and organized manner, improving the overall visual appeal of the generated document. It ensures consistency in the alignment of both headers and data cells, creating a more professional and readable appearance in the final PDF output.

<?xml version="1.0"?><!DOCTYPE pdf PUBLIC "-//big.faceless.org//report" "report-1.1.dtd">
<pdf>
<head>
	<link name="NotoSans" type="font" subtype="truetype" src="${nsfont.NotoSans_Regular}" src-bold="${nsfont.NotoSans_Bold}" src-italic="${nsfont.NotoSans_Italic}" src-bolditalic="${nsfont.NotoSans_BoldItalic}" bytes="2" />
	<#if .locale == "zh_CN">
		<link name="NotoSansCJKsc" type="font" subtype="opentype" src="${nsfont.NotoSansCJKsc_Regular}" src-bold="${nsfont.NotoSansCJKsc_Bold}" bytes="2" />
	<#elseif .locale == "zh_TW">
		<link name="NotoSansCJKtc" type="font" subtype="opentype" src="${nsfont.NotoSansCJKtc_Regular}" src-bold="${nsfont.NotoSansCJKtc_Bold}" bytes="2" />
	<#elseif .locale == "ja_JP">
		<link name="NotoSansCJKjp" type="font" subtype="opentype" src="${nsfont.NotoSansCJKjp_Regular}" src-bold="${nsfont.NotoSansCJKjp_Bold}" bytes="2" />
	<#elseif .locale == "ko_KR">
		<link name="NotoSansCJKkr" type="font" subtype="opentype" src="${nsfont.NotoSansCJKkr_Regular}" src-bold="${nsfont.NotoSansCJKkr_Bold}" bytes="2" />
	<#elseif .locale == "th_TH">
		<link name="NotoSansThai" type="font" subtype="opentype" src="${nsfont.NotoSansThai_Regular}" src-bold="${nsfont.NotoSansThai_Bold}" bytes="2" />
	</#if>
    <macrolist>
        <macro id="nlheader">
            <table class="header" style="width: 100%;"><tr>
	<td rowspan="2" style="padding-top: -15px;padding-right:-5px;margin-left:-13px;"><#if subsidiary.logo?length != 0><img src="${subsidiary.logo@url}" style="float: left; margin: 6px; width:216px; height:90px" /> </#if></td>
	<td align="right"><span style="font-weight: bold; font-size: 20pt;">Invoice</span></td>
	</tr>
	<tr>
	<td align="right" style="padding: 0;">
	<table border="1"><tr line-height="260%">
		<td align="center" border-bottom="1 px solid black" border-right="1 px solid black" style="width:130px;"><b>Date</b></td>
		<td align="center" border-bottom="1 px solid black" style="width:150px;"><b>Invoice #</b></td>
		</tr>
		<tr line-height="210%">
		<td align="center" border-right="1 px solid black" style="width:70px;">${record.trandate}</td>
		<td align="center" style="width:70px;">${record.tranid}</td>
		</tr></table>
	</td>
	</tr>
	<tr>
	<td style="padding-right:-5px;margin-left:21px;margin-top:15px;padding-top:-25px;line-height:17px;">East Electronics<br />48273 Lakeview Blvd Fremont, CA 94538<br />Phone # 510-413-0002<br />Fax # 510-413-0010<br />http://east-elec.com</td>
	</tr></table>
        </macro>
        <macro id="nlfooter">
          <table>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
          </table>
            <table class="footer" padding-top="-13px" style="width: 100%;margin-left:3px;margin-right:3px;"><tr>
	<td colspan="13">
	<p style="font-size:10px;">For any Invoice over 30 days past due, there will be a 1% late charge assessed each month on the accruing balance. Please note that all unpaid interest will be documented on a &quot;Past Due Interest Statement&quot;, and will remain owed until paid. Any quantity discrepancy or discrepancies between packing slip and received quantity shall be submitted to MynTahl within five (5) working days after receipt of goods, otherwise the shipment shall be considered as received in full.</p>
	</td>
	</tr>
              <tr>
               <td colspan="13">&nbsp;</td></tr>
              <tr>
               <td colspan="13">&nbsp;</td></tr>
          <tr>
               <td colspan="13" align="right" style="padding-right:-24px;"><pagenumber/> of <totalpages/></td></tr></table>
        </macro>
    </macrolist>
    <style type="text/css">* {
		<#if .locale == "zh_CN">
			font-family: NotoSans, NotoSansCJKsc, sans-serif;
		<#elseif .locale == "zh_TW">
			font-family: NotoSans, NotoSansCJKtc, sans-serif;
		<#elseif .locale == "ja_JP">
			font-family: NotoSans, NotoSansCJKjp, sans-serif;
		<#elseif .locale == "ko_KR">
			font-family: NotoSans, NotoSansCJKkr, sans-serif;
		<#elseif .locale == "th_TH">
			font-family: NotoSans, NotoSansThai, sans-serif;
		<#else>
			font-family: NotoSans, sans-serif;
		</#if>
		}
		table {
			font-size: 9pt;
			table-layout: fixed;
		}
        th {
            font-weight: bold;
            font-size: 8pt;
            vertical-align: middle;
            padding: 5px 6px 3px;
            background-color: #e3e3e3;
            color: #333333;
        }
        td {
            padding: 4px 6px;
        }
		
        b {
            font-weight: bold;
            color: #333333;
        }
        table.header td {
            padding: 0px;
            font-size: 10pt;
        }
        table.footer td {
            padding: 0px;
            font-size: 8pt;
        }
        table.itemtable th {
            padding-bottom: 10px;
            padding-top: 10px;
        }
        table.body td {
            padding-top: 2px;
        }
        table.total {
            page-break-inside: avoid;
        }
        tr.totalrow {
            background-color: #e3e3e3;
            line-height: 200%;
        }
        td.totalboxtop {
            font-size: 12pt;
            background-color: #e3e3e3;
        }
        td.addressheader {
            
            padding-top: 6px;
            padding-bottom: 2px;
        }
        td.address {
            padding-top: 0px;
        }
        td.totalboxmid {
            font-size: 28pt;
            padding-top: 20px;
            background-color: #e3e3e3;
        }
        td.totalboxbot {
            background-color: #e3e3e3;
            font-weight: bold;
        }
        span.title {
            font-size: 28pt;
        }
        span.number {
            font-size: 16pt;
        }
        span.itemname {
            font-weight: bold;
            line-height: 150%;
        }
</style>
</head>
<body header="nlheader" header-height="17%" footer="nlfooter" footer-height="35pt" padding="0.5in 0.5in 0.5in 0.5in" size="Letter">
    <table style="width: 100%; margin-top: 14px;width:100%;padding-right:-5px;margin-left:35px;"><tr>
	<td class="addressheader" colspan="3"><b>${record.billaddress@label}:</b></td>
	<td class="addressheader" colspan="3"><b>${record.shipaddress@label}:</b></td>
	</tr>
	<tr>
	<td>&nbsp;</td>
	</tr>
	<tr>
      <td class="address" colspan="3" rowspan="2">
        <#if record.billattention?has_content>${record.billattention}<br/></#if>
        <#if record.billaddressee?has_content>${record.billaddressee}<br/></#if>
        <#if record.billaddr1?has_content>${record.billaddr1}<br/></#if>
        <#if record.billaddr2?has_content >${record.billaddr2}<br/></#if>
        <#if record.billcity?has_content > ${record.billcity}&nbsp;</#if>
        <#if record.billstate?has_content > ${record.billstate}&nbsp;</#if>
        <#if record.billzip?has_content > ${record.billzip}<br/> </#if>
        <#if record.billcountry?has_content >${record.billcountry}</#if></td>
	<td class="address" colspan="3" rowspan="2">  
      <#if record.shipattention?has_content>${record.shipattention}<br/></#if>
      <#if record.shipaddressee?has_content>${record.shipaddressee}<br/></#if>
        <#if record.shipaddr1?has_content>${record.shipaddr1}<br/></#if>
        <#if record.shipaddr2?has_content >${record.shipaddr2}<br/></#if>
        <#if record.shipcity?has_content > ${record.shipcity}&nbsp;</#if>
        <#if record.shipstate?has_content > ${record.shipstate}&nbsp;</#if>
        <#if record.shipzip?has_content > ${record.shipzip}<br/> </#if>
        <#if record.shipcountry?has_content >${record.shipcountry}</#if></td>
	</tr></table>


<table class="body" style="width: 100%; margin-top: 10px;"><tr>
	<td align="center" border="1px solid black" style="vertical-align:middle;">P.O.No.</td>
	<td align="center" border-bottom="1 px solid black" border-right="1 px solid black" border-top="1px solid black" style="vertical-align:middle;"><b>${record.terms@label}</b></td>
	<td align="center" border-bottom="1 px solid black" border-right="1 px solid black" border-top="1px solid black" style="vertical-align:middle;"><b>Ship Date</b></td>
	<td align="center" border-bottom="1 px solid black" border-right="1 px solid black" border-top="1px solid black" style="vertical-align:middle;"><b>Due Date</b></td>
	<td align="center" border-bottom="1 px solid black" border-right="1 px solid black" border-top="1px solid black" style="vertical-align:middle;"><b>Ship Via</b></td>
	<td align="center" border-bottom="1 px solid black" border-right="1 px solid black" border-top="1px solid black" style="vertical-align:middle;"><b>Shipping Point</b></td>
	</tr>
	<tr>
      <td align="center" border-bottom="1 px solid black" border-left="1px solid black" border-right="1 px solid black" style="vertical-align:middle;"><p style="text-align: center;">${record.otherrefnum}</p></td>
      <td align="center" border-bottom="1 px solid black" border-right="1 px solid black" style="vertical-align:middle;"><p style="text-align: center;">${record.terms}</p></td>
      <td align="center" border-bottom="1 px solid black" border-right="1 px solid black" style="vertical-align:middle;"><p style="text-align: center;">${record.custbody_jj_ee_ship_date}</p></td>
      <td align="center" border-bottom="1 px solid black" border-right="1 px solid black" style="vertical-align:middle;"><p style="text-align: center;">${record.duedate}</p></td>
      <td align="center" border-bottom="1 px solid black" border-right="1 px solid black" style="vertical-align:middle;"><p style="text-align: center;">${record.custbody_jj_ee_shipvia}</p></td>
      <td align="center" border-bottom="1 px solid black" border-right="1 px solid black" style="vertical-align:middle;"><p style="text-align: center;">${record.custbody_jj_ee_spt_313}</p></td>
	</tr></table>
<#if record.item?has_content>


<table class="itemtable" style="width: 100%;height:100%; margin-top: 10px;padding-bottom:5px;"><!-- start items --><#list record.item as item><#if item_index==0>
<thead>
	<tr>
	<th align="center" border="1 px solid black;" colspan="6" style="font-weight: normal;"><b>${item.item@label}</b></th>
	<th align="center" colspan="10" style="border-top:1 px solid black;border-right:1 px solid black;border-bottom:1px solid black;font-weight: normal;"><b>Description</b></th>
	<th align="center" colspan="3" style="border-top:1 px solid black;border-right:1 px solid black;border-bottom:1px solid black;font-weight: normal;"><b>${item.quantity@label}</b></th>
	<th align="center" colspan="3" style="border-top:1 px solid black;border-right:1 px solid black;border-bottom:1px solid black;font-weight: normal;"><b>${item.rate@label}</b></th>
	<th align="center" colspan="5" style="border-top:1 px solid black;border-right:1 px solid black;border-bottom:1px solid black;font-weight: normal;"><b>${item.amount@label}</b></th>
	</tr>
</thead>
</#if><tr>
	<td colspan="6" line-height="130%" style="border-left:1 px solid black;border-right:1 px solid black;border-bottom:1px solid black">${item.item}</td>
	<td colspan="10" style="border-right:1 px solid black;border-bottom:1px solid black">${item.description}</td>
	<td colspan="3" style="border-right:1 px solid black;border-bottom:1px solid black">${item.quantity}</td>
	<td align="right" colspan="3" style="border-right:1 px solid black;border-bottom:1px solid black">${item.rate}</td>
	<td align="right" colspan="5" style="border-right:1 px solid black;border-bottom:1px solid black">${item.amount}</td>
	</tr>
	</#list><!-- end items --></table>
</#if>
<table>
  <tr>
  <td>&nbsp;</td></tr>
  </table>


<table class="total" style="width: 100%;"><tr height="3%">
	<td colspan="21">&nbsp;</td>
	<td align="left" colspan="9" style="border-bottom: 1px solid black; border-left: 1px solid black; border-right: 1px solid black;border-top:1px solid black; vertical-align: middle;"><b>Total</b></td>
	<td align="right" colspan="6" style="border-right:1 px solid black;border-top:1px solid black;border-bottom:1px solid black;vertical-align: middle;"><#if record.currencySymbol?contains("USD")><b>USD</b> ${record.total?replace('$', '')}<#else>${record.total}</#if></td>
	</tr>
	<tr height="3%">
	<td colspan="21">&nbsp;</td>
	<td align="left" colspan="9" style="border-bottom: 1px solid black; border-left: 1px solid black; vertical-align: middle;border-right: 1px solid black;"><b>Payments/Credits</b></td>
	<td align="right" colspan="6" style="border-right:1 px solid black;border-bottom:1px solid black;vertical-align: middle;"><#if record.currencySymbol?contains("USD")><b>USD</b> ${record.amountpaid?replace('$', '')}<#else>${record.amountpaid}</#if></td>
	</tr>
	<tr height="3%">
	<td colspan="21" ></td>
     
	<td align="left" colspan="9" style="border-right: 1px solid black;border-bottom: 1px solid black; border-left: 1px solid black;vertical-align: middle;"><b>Balance Due</b></td>
	<td align="right" colspan="6" style="border-right:1 px solid black;border-bottom:1px solid black;vertical-align: middle;"><#if record.currencySymbol?contains("USD")><b>USD </b>${record.amountremaining?replace('$', '')}<#else>${record.amountremaining}</#if></td>
	</tr></table>
  <table  style="width: 100%;border:1 px solid black;">
    <tr><th ><b>${record.memo@label}</b></th></tr>
    <tr>
    <td style="border-top:1 px solid black;vertical-align: middle;">${record.memo}</td></tr>
  </table>
</body>
</pdf>

Leave a comment

Your email address will not be published. Required fields are marked *