2x8 label sheet WFG

by frogggeee McFrogggeee

HTML

<p id = "labels" style = "font-size: 18px;  margin-top: 0px;"></p>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.5/jspdf.debug.js"></script>

CSS

CMG MORTGAGE INC., DA CMG FINANCIAL
3160 CROW CANYON ROAD STE 400
SAN RAMON, CA 94583-1382
#ERROR!
U.S. Bank,
Hopkins Excelsior Blvd
9380 Excelsior Blvd, Floor #3
Hopkins, MN 55343
#ERROR!
UNITED WHOLESALE MORTGAGE, LLC
585 SOUTH BOULEVARD E
PONTIAC. MI 48341
#ERROR!
OnPoint Community Credit Union
2701 NW Vaughn Street, #800
Portland, OR 97210
#ERROR!
Indecomm Global Services
1427 Energy Park Drive
St. Paul, MN 55108
#ERROR!
OPTIMUM FIRST INC
8900 WARNER AVE
FOUNTAIN VALLEY, CALIFORNIA 92708
#ERROR!
1st Security Bank of Washington C/O DocProbe
1820 Swarthmore Avenue
P.O. Box 840
Lakewood, NJ 08701
#ERROR!
Nova Financial &amp;amp; Investment Corporation
6245 East Broadway, Suite 400
Tucson, AZ 85711
#ERROR!
Rocket Mortgage, LLC
1050 Woodward Ave
Detroit, MI 48226-1906
(313) 373-0000
#ERROR!
Primary Residential Mortgage, Inc. c/o First American
1795 International Way
Idaho Falls, ID 83402
#ERROR!
NW Equity Lending, LLC
4660 NE 77th Avenue, Suite 200
Vancouver, WA 98662
#ERROR!
Cardinal Financial Company, Limited Partnership
3701 Arco Corporate Drive, Suite 200
Charlotte, NC 28273
#ERROR!
Rebecca Waldrup/Symmetry Lending
6600 Peachtree Dunwoody Rd.
Building 400, Suite 290
Atlanta, Georgia 30328
#ERROR!
ResiCentral, LLC C/O Doc Probe
1133 Ocean Avenue
Mail Stop: DP1700
Lakewood, NJ 08701
800-647-8750
#ERROR!
MOVEMENT MORTGAGE LLC
8024 CALVIN HALL RD
INDIAN LAND, SC 29707
#ERROR!
LOANDEPOT. COM, LLC
6531 IRVINE CENTER DRIVE, SUITE 100
IRVINE, CA 92618
(888) 337-6888
#ERROR!
Umpqua Bank
6610 SW Cardinal Lane, 1st Floor
Tigard, OR 97224
#ERROR!
CORNERSTONE HOME LENDING c/o DocProbe, LLC
1133 Ocean Avenue
Mail stop code: DP7243
Lakewood, NJ 08701
#ERROR!
SIERRA PACIFIC MORTGAGE
COMPANY, INC.
2330 COMMERCE PARK DRIVE
NE, STE 2
PALM BAY, FL 32905
#ERROR!
Willamette Valley Bank
5140 River Road N
Keizer, OR 97303
#ERROR!
Rivermark Community Credit Union
PO BOX 4044
Beaverton, OR 97076
#ERROR!
First American Mortgage Solutions C/O American Pacific Mortgago
Mail Stop:...

JavaScript

let labels = prompt().split("#ERROR!");
labels = labels.join("").replace(/\n|\r/g, "=").split("==")//.split("<");
let lines = [];
let rows = [];
let length = 34;
let lineCount = 0; // total lines for current row
let linesCreated = 0; // lines created for current label
for (let i = 0; i < labels.length; i++) {
  if (labels[i] == "") {
    lines.push(">");
    lineCount++;
    linesCreated = 0;
  } else {
    // insert > symbol at row breaks
    let words = labels[i].split(" ");
    let line = "";
    for (let j = 0; j < words.length; j++) {
      words[j] = words[j].substr(0, 1).toUpperCase() + words[j].substr(1, words[j].length).toLowerCase();
      if (words[j].toLowerCase() == "llc" || words[j].toLowerCase() == "lic") {
        words[j] = "LLC";
      }
      if (words[j].length == 2) {
        words[j] = words[j].toUpperCase();
      }
      if ((line + " " + words[j]).length > length) {
        lines.push(line);
        lineCount++;
        linesCreated++;
        line = words[j] + " ";
      } else {
        line += words[j] + " ";
      }

    }
    lines.push(line)
    linesCreated++;
    lineCount++;
    line = "";
  }
}
lines = (lines.join("\n").split(">"));
for (let i = 0; i < lines.length; i++) { // only creates a sheet of an address once. change to lines.length to create a sheet for every address
var doc = new jsPDF();
doc.setFontSize(11);
	for (let x = 0; x < 3; x++) {
  let xPos = 0;
  switch (x) {
  	case 0: xPos = 0; break;
    case 1: xPos = 70; break;
    case 2: xPos = (70*2)+4; break;
  }
  	for (let y = 0; y < 10; y++) {
    	doc.text(lines[(i)], xPos, (y*26.5)+24);
    }
  } 
  let name = lines[i].split("\n")[0];
  if (name == "") {
  name = lines[i].split("\n")[1];
  }
  console.log(name)
  //doc.save(name+'.pdf')
}