Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > FusionPro® VDP Producer (formerly FusionPro® Direct)

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old November 10th, 2016, 08:36 AM
Landisa's Avatar
Landisa Landisa is offline
Junior Community Member
 
Join Date: Jun 2014
Location: United States
Posts: 31
Question Variable Tables Not Displayed on Composition [SOLVED]

[SOLVED]

I am working on several items in this field including multiple possible body pages based on column value, overflow, and variable tables based on key customers and multi-row external data.

My big issue right now is that my tables display on Preview but nothing shows up during Composition. I am assuming it is simple missed code or misplaced code on my behalf.

OnRecordStart
Code:
if (Field("MCE_Letter_Code") == "1")
{
    FusionPro.Composition.SetBodyPageUsage("PP006", false);
    FusionPro.Composition.SetBodyPageUsage("PP006_2", false);
    FusionPro.Composition.SetBodyPageUsage("PP006_3", false);
    FusionPro.Composition.SetBodyPageUsage("PP006_Overflow",false);
    FusionPro.Composition.SetBodyPageUsage("PP009", false);
    FusionPro.Composition.SetBodyPageUsage("PP010", false);
    FusionPro.Composition.SetBodyPageUsage("PP026", false);
}
else if (Field("MCE_Letter_Code") == "6")
{
    FusionPro.Composition.SetBodyPageUsage("PP001",false);
    FusionPro.Composition.SetBodyPageUsage("PP001_2",false);
    FusionPro.Composition.SetBodyPageUsage("PP001_Overflow",false);
    FusionPro.Composition.SetBodyPageUsage("PP009", false);
    FusionPro.Composition.SetBodyPageUsage("PP010", false);
    FusionPro.Composition.SetBodyPageUsage("PP026", false);
}
else if (Field("MCE_Letter_Code") == "9")
{
    FusionPro.Composition.SetBodyPageUsage("PP001",false);
    FusionPro.Composition.SetBodyPageUsage("PP001_2",false);
    FusionPro.Composition.SetBodyPageUsage("PP001_Overflow",false);
    FusionPro.Composition.SetBodyPageUsage("PP006", false);
    FusionPro.Composition.SetBodyPageUsage("PP006_2", false);
    FusionPro.Composition.SetBodyPageUsage("PP006_3", false);
    FusionPro.Composition.SetBodyPageUsage("PP006_Overflow",false);
    FusionPro.Composition.SetBodyPageUsage("PP010", false);
    FusionPro.Composition.SetBodyPageUsage("PP026", false);
}
else if (Field("MCE_Letter_Code") == "10")
{
    FusionPro.Composition.SetBodyPageUsage("PP001",false);
    FusionPro.Composition.SetBodyPageUsage("PP001_2",false);
    FusionPro.Composition.SetBodyPageUsage("PP001_Overflow",false);
    FusionPro.Composition.SetBodyPageUsage("PP006", false);
    FusionPro.Composition.SetBodyPageUsage("PP006_2", false);
    FusionPro.Composition.SetBodyPageUsage("PP006_3", false);
    FusionPro.Composition.SetBodyPageUsage("PP006_Overflow",false);
    FusionPro.Composition.SetBodyPageUsage("PP009", false);
    FusionPro.Composition.SetBodyPageUsage("PP026", false);
}
else if (Field("MCE_Letter_Code") == "26")
{
    FusionPro.Composition.SetBodyPageUsage("PP001",false);
    FusionPro.Composition.SetBodyPageUsage("PP001_2",false);
    FusionPro.Composition.SetBodyPageUsage("PP001_Overflow",false);
    FusionPro.Composition.SetBodyPageUsage("PP006", false);
    FusionPro.Composition.SetBodyPageUsage("PP006_2", false);
    FusionPro.Composition.SetBodyPageUsage("PP006_3", false);
    FusionPro.Composition.SetBodyPageUsage("PP006_Overflow",false);
    FusionPro.Composition.SetBodyPageUsage("PP009", false);
    FusionPro.Composition.SetBodyPageUsage("PP010", false);
}
else
{

}
return "";
OnJobStart
Code:
//Link to the external data file.  
data = new ExternalDataFileEx("data_feed.csv", ",");

if (!data.valid)
{
   ReportError("Cannot successfully read/find the external data file.");
}
Rule_DataTable
Code:
//The following if statement will detect if we are currently in preview mode or editing this rule (versus composing output).
if(FusionPro.Composition.isPreview == true || FusionPro.inValidation == true)
{
    Rule("OnJobStart");
}

//Create empty
var table = [];
var tbl = [];

//Get a count of the total number of records in the external data file
NumberOfRecords = data.recordCount;

var type = 
[
    [' '] //Header
];

//Create Table
var myTable = new FPTable;

myTable.AddColumns(13000, 2000, 20000, 8500, 6500);

tbl.push(["", "", "Provider Name", "Phone Number", "Miles Away"]); //Header Rows 

    //Now, loop through all records in the external data file and find the records
    for (var n=1; n<=NumberOfRecords; n++) 
    {
    function ExField(field) {return data.GetFieldValue(n, field);}
        if (Field("MCE_Case_Number") == ExField("Case_Number"))
        {
            type.forEach(function(s) 
            {
              var [provider, phone, miles] = s; 
                provider = ExField("Prov_Name");
                phone = ExField("Prov_Phone").replace(/^[\D]*(\d{3})[\D]*(\d{3})[\D]*(\d{4})$/, "($1) $2-$3");
                miles = FormatNumber("0.0", ExField("Prov_Mileage")/100);
                tbl.push(['Check to choose this provider', '', provider, phone, miles]);
            });
        }           
    }
   
   // Formatting
    for (var i=0; i<tbl.length; i++) 
    {
        var row = myTable.AddRow();
        var cell = row.Cells[0]; 
        row.minHeight = 2000; 
        cell.Margins = new FPTableMargins;
        cell.Margins.Bottom = 0;
        row.CopyCells (0,1,2,3,4);
        if (i >= 1) myTable.Rows[i].Cells[1].SetBorders ("Thin", "Black", "Top", "Bottom", "Right", "Left");
        if (i == 0) cell.HStraddle = 2;
        myTable.Rows[0].Cells[1].Bold = "On"; 
        cell.VAlign = "Middle";
        row.CopyCells (1,2,3,4);
        myTable.Rows[i].Cells[2].HAlign = "Left";
        myTable.Rows[i].Cells[3].HAlign = "Center";
        myTable.Rows[i].Cells[4].HAlign = "Right";
        var [col0, col1, col2, col3, col4] = tbl[i];
        row.SetContents (col0, col1, col2, col3, col4);
    } 
myTable.AddRow(1); //Blank row for seperation

//Push variable into Array
table.push(myTable.MakeTags());

return table;
Text Frame
Code:
If you want a doctor not listed in the chart below, write the name and city on the lines below.
Name: 		
City: 		

«Rule_DataTable»
Person completing this form:
Again I get the results I need from preview but the composition file is well lacking the data table.

Suggestions? Another set of eyes on my code helps a lot.
__________________
Audra Landis
Computer Systems Admin

VDP Producer v10.0.3
Windows 7 / Windows 10
Acrobat Pro DC (2015.010.20056)

Last edited by Landisa; November 10th, 2016 at 10:45 AM.. Reason: Solved
Reply With Quote
  #2  
Old November 10th, 2016, 09:37 AM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Variable Tables Not Displayed on Composition

Are you getting any errors in your message log? Like: "Cannot successfully read/find the external data file."?

You could try just defining your data file within the rule itself rather than assigning it to a global variable in OnJobStart:
Code:
//Link to the external data file.  
data = new ExternalDataFileEx("data_feed.csv", ",");

if (!data.valid)
{
   ReportError("Cannot successfully read/find the external data file.");
}

//Create empty
var table = [];
var tbl = [];

//Get a count of the total number of records in the external data file
NumberOfRecords = data.recordCount;

var type = 
[
    [' '] //Header
];

//Create Table
var myTable = new FPTable;

myTable.AddColumns(13000, 2000, 20000, 8500, 6500);

tbl.push(["", "", "Provider Name", "Phone Number", "Miles Away"]); //Header Rows 

    //Now, loop through all records in the external data file and find the records
    for (var n=1; n<=NumberOfRecords; n++) 
    {
    function ExField(field) {return data.GetFieldValue(n, field);}
        if (Field("MCE_Case_Number") == ExField("Case_Number"))
        {
            type.forEach(function(s) 
            {
              var [provider, phone, miles] = s; 
                provider = ExField("Prov_Name");
                phone = ExField("Prov_Phone").replace(/^[\D]*(\d{3})[\D]*(\d{3})[\D]*(\d{4})$/, "($1) $2-$3");
                miles = FormatNumber("0.0", ExField("Prov_Mileage")/100);
                tbl.push(['Check to choose this provider', '', provider, phone, miles]);
            });
        }           
    }
   
   // Formatting
    for (var i=0; i<tbl.length; i++) 
    {
        var row = myTable.AddRow();
        var cell = row.Cells[0]; 
        row.minHeight = 2000; 
        cell.Margins = new FPTableMargins;
        cell.Margins.Bottom = 0;
        row.CopyCells (0,1,2,3,4);
        if (i >= 1) myTable.Rows[i].Cells[1].SetBorders ("Thin", "Black", "Top", "Bottom", "Right", "Left");
        if (i == 0) cell.HStraddle = 2;
        myTable.Rows[0].Cells[1].Bold = "On"; 
        cell.VAlign = "Middle";
        row.CopyCells (1,2,3,4);
        myTable.Rows[i].Cells[2].HAlign = "Left";
        myTable.Rows[i].Cells[3].HAlign = "Center";
        myTable.Rows[i].Cells[4].HAlign = "Right";
        var [col0, col1, col2, col3, col4] = tbl[i];
        row.SetContents (col0, col1, col2, col3, col4);
    } 
myTable.AddRow(1); //Blank row for seperation

//Push variable into Array
table.push(myTable.MakeTags());

return table;
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #3  
Old November 10th, 2016, 09:45 AM
Landisa's Avatar
Landisa Landisa is offline
Junior Community Member
 
Join Date: Jun 2014
Location: United States
Posts: 31
Default Re: Variable Tables Not Displayed on Composition

Quote:
Originally Posted by step View Post
Are you getting any errors in your message log? Like: "Cannot successfully read/find the external data file."?

You could try just defining your data file within the rule itself rather than assigning it to a global variable in OnJobStart:
I tried making that change. No success.

As for the Message Log, I have no idea where to find it. I will go looking for it.
__________________
Audra Landis
Computer Systems Admin

VDP Producer v10.0.3
Windows 7 / Windows 10
Acrobat Pro DC (2015.010.20056)
Reply With Quote
  #4  
Old November 10th, 2016, 09:59 AM
Landisa's Avatar
Landisa Landisa is offline
Junior Community Member
 
Join Date: Jun 2014
Location: United States
Posts: 31
Default Re: Variable Tables Not Displayed on Composition

No errors were found on composition.
Code:
====================SUMMARY====================
Collection Directory:
  C:\Users\AppData\Local\Temp\
------------------
Composition files:
  C:\Users\Desktop\FusionPro\Passport Letter_FPro.pdf
  C:\Users\Desktop\FusionPro\caseworkers.csv
Graphics resource files copied: 0
------------------
Text resource files copied: 0
------------------
Page media files copied: 0
------------------
Imposition files copied: 0
------------------
------------------
------------------
------------------
------------------
------------------
Following files are generated for server composition after collect.
Data Definition File:
  Passport Letter_FPro.def
DIF format file:
  Passport Letter_FPro.dif
Configuration File:
  Passport Letter_FPro-o.cfg
Unicode Font Files: 4
    C:\Users\Public\Documents\PTI\FusionPro\Fonts\Arial Italic-1.pfa
    C:\Users\Public\Documents\PTI\FusionPro\Fonts\Arial Bold Italic-1.pfa
    C:\Users\Public\Documents\PTI\FusionPro\Fonts\Arial Bold-1.pfa
    C:\Users\Public\Documents\PTI\FusionPro\Fonts\Arial-1.pfa
__________________
Audra Landis
Computer Systems Admin

VDP Producer v10.0.3
Windows 7 / Windows 10
Acrobat Pro DC (2015.010.20056)
Reply With Quote
  #5  
Old November 10th, 2016, 10:36 AM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Variable Tables Not Displayed on Composition

That isn't the composition log; that is the collection log. The composition log would likely be in the same place as your composed output file.

Are you composing the output on a different machine than the one you're using to preview the template? I still think that the issue is that your template can't find your external data file at the time of composition. You can try adding an absolute path to your external data file:
Code:
data = new ExternalDataFileEx("C:\Users\Desktop\FusionPro\data_feed.csv", ",");
Or you could add the path to your external data file to the "Search Path" under the "Advanced" tab of the composition settings.
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #6  
Old November 10th, 2016, 10:44 AM
Landisa's Avatar
Landisa Landisa is offline
Junior Community Member
 
Join Date: Jun 2014
Location: United States
Posts: 31
Default Re: Variable Tables Not Displayed on Composition

Quote:
Originally Posted by step View Post
That isn't the composition log; that is the collection log. The composition log would likely be in the same place as your composed output file.

Are you composing the output on a different machine than the one you're using to preview the template? I still think that the issue is that your template can't find your external data file at the time of composition. You can try adding an absolute path to your external data file:
You are a genius! I forgot to add the external file as a Resource.
Once I did that the composition worked! *facepalm*

Yes, I am previewing the document on a separate machine then composition.
Problem Solved!
__________________
Audra Landis
Computer Systems Admin

VDP Producer v10.0.3
Windows 7 / Windows 10
Acrobat Pro DC (2015.010.20056)
Reply With Quote
  #7  
Old November 10th, 2016, 10:49 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,359
Default Re: Variable Tables Not Displayed on Composition

Quote:
Originally Posted by step View Post
You can try adding an absolute path to your external data file:
Code:
data = new ExternalDataFileEx("C:\Users\Desktop\FusionPro\data_feed.csv", ",");
Please be careful doing this! That code does not do what you expect. Backslashes need to be escaped in JavaScript string literals, like so:
Code:
data = new ExternalDataFileEx("C:\\Users\\Desktop\\FusionPro\\data_feed.csv", ",");
Although, if you really want to hard-code a local path, I would just use forward slashes instead:
Code:
data = new ExternalDataFileEx("C:/Users/Desktop/FusionPro/data_feed.csv", ",");
However, if the job is being composed on a remote Producer machine, then that path is not going to be correct anyway. You probably want to use a UNC path to a shared file server, something like this:
Code:
data = new ExternalDataFileEx("\\\\fileserver\\share\\subfolder\\etc\\data_feed.csv", ",");
But trying to hard-code paths in JavaScript is really not a good idea at all. This is a much better one:
Quote:
Originally Posted by step View Post
Or you could add the path to your external data file to the "Search Path" under the "Advanced" tab of the composition settings.
Although, again, you probably want a UNC path there, so that both your local Designer machine and the Producer machine can find the data file.

Having said all of that, though, I think the easiest solution is to add the external data file data_feed.csv to the template as a text resource. Then it will get collected up with the job when it's submitted to Producer for composition, and will be found at composition time without having to specify a full path anywhere.
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

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)});
Reply With Quote
  #8  
Old November 14th, 2016, 02:42 PM
Landisa's Avatar
Landisa Landisa is offline
Junior Community Member
 
Join Date: Jun 2014
Location: United States
Posts: 31
Default Re: Variable Tables Not Displayed on Composition

Attached File
Attached Files
File Type: zip Sample FPro.zip (25.1 KB, 9 views)
__________________
Audra Landis
Computer Systems Admin

VDP Producer v10.0.3
Windows 7 / Windows 10
Acrobat Pro DC (2015.010.20056)
Reply With Quote
Reply

Tags
composition, display, table, variable

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:44 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.