Adding multiple records to the same PDF template

How do I create a PDF tempate that is a list of records? I seperated a text file into many indivdual records and now I need to use those records to make a product catalog of all the records. Thanks in advance.

Hello @dan_hamacher,

I assume that you have created a DataMapper configuration to separate a text file into many individual records? If so, then you need to create a Print Template to create the content for the PDF output and create a Job- and Output Preset to be able to create the actual PDF output.

  • To create a Print Template: Go to Designer application > File > New… > New… window > Template folder > Print Template
  • To create a Job Preset: Go to Designer application > File > New… > New… window > Presets folder > Job Preset
  • To create a Output Preset: Go to Designer application > File > New… > New… window > Presets folder > Output Preset

As in regards to creating a new Job- and Output Preset, please note that the above go-tos apply from version 2023.1 of OL Connect.

I did create the data mapper configuration which for my test, produced 6 records. Now I’m trying to achieve this…

I start this process by working with a preset?

I understand that I have to make a table and map out the extractions. I just don’t know how to make each additional table show the next record.

Can you let us know please whether you would like to print 6 records (pages) on one page or whether you would like to get the same result as shown in the provided screenshot? In case of the latter, I assume that you need to reconfigure your DataMapper configuration so that you have 6 detail table records instead of 6 records to be able to achieve the shown example on the Template side.

I’m not sure I totally understand the difference between those two scenarios.

Basically, I will eventually have a huge list of products (numbering in the thousands) and I need to create a catalog of those products where they appear approximately 6 on a page. So I started by using the data mapper to split that list into separate records. Now I need to output the individual records onto pages that can be printed as an actual catalog. Does that make sense?

It is possible what you would like to achieve but this require some experience with especially HTML and JavaScript. You also need to reconfigure your DataMapper configuration so that you don’t have, for example, 6 records but a detail table with 6 records.

To achieve the following example…

…I’ve applied the following Standard Script:

  • Name: Example
  • Selector: table#example tbody tr
if ("detail" in record.tables) {
	let result = "";
	let tdElements = [];

	for (let i = 0; i < record.tables.detail.length; i++) {
		let field = record.tables.detail[i].fields.recordNumber;
		let tdElement = "";
		
		tdElement += "<td style=\"" + (i > 1 ? "" : "width: 50%; ") + "\">";

		tdElement += "<div style=\"border: 1px solid black; padding: 64px 32px; margin: 36px;\">";
		tdElement += "<h2 style=\"text-align: center; color: red;\">" + field + "</h2>";
		tdElement += "</div></td>";

		tdElements.push(tdElement);
	}

	if (tdElements.length % 2 !== 0) {
		let tdElement = "<td " + (tdElements.length == 1 ? "style=\"width: 50%;\"" : "") + "></td>";
		tdElements.push(tdElement);
	}

	for (let i = 0; i < tdElements.length; i++) {
		if (i % 2 == 0) {
			result += "<tr data-breakable=\"\">";
			result += tdElements[i];
		} else {
			result += tdElements[i];
			result += "</tr>";
		}
	}
	this.replaceWith(result);
} else {
	this.parent().parent().hide();
}

Attached you will find the DataMapper configuration and Print Template I used to achieve the example as shown in the shared screenshot.

example_20240521.OL-datamapper (3.5 KB)
example_20240521.OL-template (9.5 KB)