#11
|
||||
|
||||
![]() Quote:
Code:
for (var i = rec; i <= data.recordCount; i++) { function ExField(str) { return TaggedTextFromRaw(data.GetFieldValue(i, str)); } if (ExField('company') && i > rec) break; var row = table.AddRow(); row.Cells[0].HAlign = 'Left'; row.CopyCells(0, 1); row.SetContents.apply(row, ['Date', 'Amount'].map(ExField)); }
__________________
Ste Pennell FusionPro VDP Creator 9.3.15 Adobe Acrobat X 10.1.1 Mac OS X 10.12 |
#12
|
|||
|
|||
![]()
Thanks for your patience with me, Ste.
It looks great!
__________________
Fusion Pro Desktop 10.0.16 & Server • Acrobat Pro DC • Mac OSX 10.12 |
#13
|
||||
|
||||
![]()
Here's Ste's rule adapted to use the multi-line record feature in FP 10. (It's back to a regular rule named "RUL_table", as in the original template you posted, not an OnRecordStart rule.)
Code:
var numOfCols = 3; var data = FusionPro.GetMultiLineRecords(); var table = new FPTable(); table.AddColumns(7200, 8500); var header = table.AddRow(); header.Type = 'Header'; var cell = header.Cells[0]; cell.SetBorders('Thin', 'Black', 'Bottom'); cell.HAlign = 'Center'; header.CopyCells(0, 1); header.SetContents('Date', 'Amount'); for (var i = 1; i <= data.recordCount; i++) { function ExField(str) { return TaggedTextFromRaw(data.GetFieldValue(i, str)); } var row = table.AddRow(); row.Cells[0].HAlign = 'Left'; row.CopyCells(0, 1); row.SetContents.apply(row, ['Date', 'Amount'].map(ExField)); } // Number of rows needed to evenly distribute across numOfCols. // Minus 1 for the header row. var rows = Math.ceil((table.Rows.length - 1) / numOfCols); // Duplicate column 1 and 2 (and their headers) to make up numOfCols. for (var i = 0; i < (numOfCols - 1) * 2; i++) { table.Columns.push(table.Columns[i % 2]); table.Rows[0].Cells.push(table.Rows[0].Cells[i % 2]) } // Concatenate the rows cells in order to reduce our total rows // and fill up the extra columns. var rowCounter = 1; while ((table.Rows.length - 1) > rows) { var index = rowCounter % rows || rows; var row = table.Rows.splice(rows + 1, 1).pop(); table.Rows[index].Cells = table.Rows[index].Cells.concat(row.Cells) rowCounter++ } // Return the table tags. return table.MakeTags();
__________________
Dan Korn FusionPro Developer / JavaScript Guru / Forum Moderator PTI Marketing Technologies | Printable | MarcomCentral I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com. Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs. This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data. Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages. Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance. Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support. How To Ask Questions The Smart Way The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript. Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5. return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)}); ![]() |
#14
|
||||
|
||||
![]()
You could also accomplish this with a multi-column text frame, which makes the rule much simpler, since you only need a two-column table to flow into those three text frame columns. The only tricky part is the text that spans all columns after the table, but that's just a matter of using the <p paragraphplacement="straddleall"> tag. See the attached template.
__________________
Dan Korn FusionPro Developer / JavaScript Guru / Forum Moderator PTI Marketing Technologies | Printable | MarcomCentral I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com. Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs. This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data. Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages. Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance. Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support. How To Ask Questions The Smart Way The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript. Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5. return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)}); ![]() |
#15
|
|||
|
|||
![]()
Thanks, Dan!
A thing of beauty (as always) and great to see how to accomplish in v10. Sorry for my slow response, been out of the office. Happy New Year and thanks again to you both!! Kim
__________________
Fusion Pro Desktop 10.0.16 & Server • Acrobat Pro DC • Mac OSX 10.12 |
#16
|
|||
|
|||
![]()
Hi Dan and Ste,
Remember this thoroughly beautiful table you helped me work out? I wound up using the code below for v10 and it's great and just what I asked for. But now that I've got some real data, I've got a little wrinkle. Sometimes there is only 1 entry for Date and Amount. So, I don't need 3 columns in those cases, but it still outputs the Date Amount headers for all 3 columns. Any ideas on how to show the Date and Amount headers only if there is content to warrant them? Code:
var numOfCols = 3; var data = FusionPro.GetMultiLineRecords(); var table = new FPTable(); table.AddColumns(6000, 7000, 3000); var header = table.AddRow(); header.Type = 'Header'; var cell = header.Cells[0]; cell.SetBorders('Thin', 'Black', 'Bottom'); cell.HAlign = 'Left'; header.CopyCells(0, 1); header.SetContents('Date', 'Amount'); for (var i = 1; i <= data.recordCount; i++) { function ExField(str) { return TaggedTextFromRaw(data.GetFieldValue(i, str)); } var row = table.AddRow(); row.Cells[0].HAlign = 'Left'; row.CopyCells(0, 1); row.SetContents.apply(row, ['Date', 'Amount'].map(ExField)); } // Number of rows needed to evenly distribute across numOfCols. // Minus 1 for the header row. var rows = Math.ceil((table.Rows.length - 1) / numOfCols); // Duplicate column 1 and 2 (and their headers) to make up numOfCols. for (var i = 0; i < (numOfCols - 1) * 3; i++) { table.Columns.push(table.Columns[i % 3]); table.Rows[0].Cells.push(table.Rows[0].Cells[i % 3]) } // Concatenate the rows cells in order to reduce our total rows // and fill up the extra columns. var rowCounter = 1; while ((table.Rows.length - 1) > rows) { var index = rowCounter % rows || rows; var row = table.Rows.splice(rows + 1, 1).pop(); table.Rows[index].Cells = table.Rows[index].Cells.concat(row.Cells) rowCounter++ } // Return the table tags. return table.MakeTags(); Kim
__________________
Fusion Pro Desktop 10.0.16 & Server • Acrobat Pro DC • Mac OSX 10.12 |
#17
|
||||
|
||||
![]()
I haven't tested this but it seems like it would give you what you're looking for:
Code:
var numOfCols = 3; var data = FusionPro.GetMultiLineRecords(); var table = new FPTable(); table.AddColumns(6000, 7000, 3000); var header = table.AddRow(); header.Type = 'Header'; header.Cells[0].SetBorders('Thin', 'Black', 'Bottom'); header.CopyCells(0, 1); header.SetContents('Date', 'Amount'); for (var i = 1; i <= data.recordCount; i++) { function ExField(str) { return TaggedTextFromRaw(data.GetFieldValue(i, str)); } // Skip this record if 'Date' & 'Amount' fields are both empty. var contents = ['Date', 'Amount'].map(ExField); if (!Trim(contents.join(''))) continue; var row = table.AddRow(); row.SetContents.apply(row, contents); } // Determine how many columns are needed based on how many rows // were added to the table (minus 1 for the header row). var colsNeeded = table.Rows.length - 1; // Update the numOfCols variable if we need less than 3. numOfCols = colsNeeded < numOfCols ? colsNeeded : numOfCols; // Number of rows needed to evenly distribute across numOfCols. var rows = Math.ceil(colsNeeded / numOfCols); // Duplicate column 1 and 2 (and their headers) to make up numOfCols. for (var i = 0; i < (numOfCols - 1) * 3; i++) { table.Columns.push(table.Columns[i % 3]); table.Rows[0].Cells.push(table.Rows[0].Cells[i % 3]) } // Concatenate the rows cells in order to reduce our total rows // and fill up the extra columns. var rowCounter = 1; while (colsNeeded > rows) { var index = rowCounter % rows || rows; var row = table.Rows.splice(rows + 1, 1).pop(); table.Rows[index].Cells = table.Rows[index].Cells.concat(row.Cells) rowCounter++ } // Return the table tags. return table.MakeTags();
__________________
Ste Pennell FusionPro VDP Creator 9.3.15 Adobe Acrobat X 10.1.1 Mac OS X 10.12 |
#18
|
|||
|
|||
![]()
Hi Ste!
Thanks for the response. This is almost perfect. I thought it was doing it exactly as needed, but have found that it behaves a little weird when there are 4 records - it makes 2 columns with 2 lines each and puts a blank 3rd column with just headers. If I have 3 records it is fine and does 3 columns across. It just seems to get confused by 4 records. Examples of the one scenario that doesn't work attached along with examples of other record counts working as expected.
__________________
Fusion Pro Desktop 10.0.16 & Server • Acrobat Pro DC • Mac OSX 10.12 Last edited by Kim; January 15th, 2018 at 11:01 AM.. |
#19
|
|||
|
|||
![]()
Have I stumped you guys?
__________________
Fusion Pro Desktop 10.0.16 & Server • Acrobat Pro DC • Mac OSX 10.12 |
#20
|
||||
|
||||
![]()
No, sorry, I've just been busy. Try this:
Code:
var numOfCols = 3; var data = FusionPro.GetMultiLineRecords(); var table = new FPTable(); table.AddColumns(6000, 7000, 3000); var header = table.AddRow(); header.Type = 'Header'; header.Cells[0].SetBorders('Thin', 'Black', 'Bottom'); header.CopyCells(0, 1); header.SetContents('Date', 'Amount'); for (var i = 1; i <= data.recordCount; i++) { function ExField(str) { return TaggedTextFromRaw(data.GetFieldValue(i, str)); } // Skip this record if 'Date' & 'Amount' fields are both empty. var contents = ['Date', 'Amount'].map(ExField); if (!Trim(contents.join(''))) continue; var row = table.AddRow(); row.SetContents.apply(row, contents); } // Determine how many columns are needed based on how many rows // were added to the table (minus 1 for the header row). var colsNeeded = table.Rows.length - 1; // Number of rows needed to evenly distribute across numOfCols. var rows = Math.ceil(colsNeeded / numOfCols); // Duplicate column 1 and 2 (and their headers) to make up numOfCols. for (var i = 0; i < (numOfCols - 1) * 3; i++) { table.Columns.push(table.Columns[i % 3]); table.Rows[0].Cells.push(table.Rows[0].Cells[i % 3]) } // Concatenate the rows cells in order to reduce our total rows // and fill up the extra columns. var rowCounter = 1; while (colsNeeded > rows) { var index = rowCounter % rows || rows; var row = table.Rows.splice(rows + 1, 1).pop(); table.Rows[index].Cells = table.Rows[index].Cells.concat(row.Cells) rowCounter++ } // Create reference variables to the cells of the first row (header) // and second row (the date/amount values). var [headerCells, contentCells] = table.Rows.slice(0, 2).map(function(s) { return s.Cells }); // We only need as many header cells as there are content cells. So, if // there are more header cells than content cells, we can begin removing // headers until the columns are equal. while (headerCells.length > contentCells.length) headerCells.pop(); // Return the table tags. return table.MakeTags();
__________________
Ste Pennell FusionPro VDP Creator 9.3.15 Adobe Acrobat X 10.1.1 Mac OS X 10.12 |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|