Hello friends, I am using a CSV file to populate a form in illustrator but which contains text fields are getting texts QUOTES
EXAMPLE:
instead of> MODEL <is filling> "MODEL" <
How do I remove QUOTES, tried using the REPLACE METHOD but could not.
Could anyone help me?
The script I'm creating is this:
#target illustrator
var sourceDoc = app.activeDocument;
var aFile = File ("~/Desktop/teste form com CSV.csv");
aFile.open("r");
var txtFile = aFile.read();
aFile.close();
var iText = txtFile.split("\n");
alert(iText)
var multTexts = new Array (iText.length-1);
var myTextFrame
var Dateformat = "dd/mm/yy";
function TodayDate()
{
var Today = new Date();
var Day = Today.getDate();
var Month = Today.getMonth() + 1;
var Year = Today.getYear();
var PreMon = ((Month < 10) ? "0" : "");
var PreDay = ((Day < 10) ? "0" : "");
if(Year < 999) Year += 1900;
var theDate = Dateformat.replace(/dd/,PreDay+Day);
theDate = theDate.replace(/mm/,PreMon+Month);
theDate = theDate.replace(/d/,Day);
theDate = theDate.replace(/m/,Month);
theDate = theDate.replace(/yyyy/,Year);
theDate = theDate.replace(/yy/,Year.toString().substr(2,2));
return theDate;
}
for (i=1; i<iText.length-1; i++) {
T=iText[i].split( ",");
texto=iText[i];
myTextFrame=sourceDoc.textFrames.getByName("CLIENTE");
myTextFrame.contents=T[0];
myTextFrame=sourceDoc.textFrames.getByName("COD");
myTextFrame.contents=T[1];
myTextFrame=sourceDoc.textFrames.getByName("MODELO");
myTextFrame.contents=T[2];
myTextFrame=sourceDoc.textFrames.getByName("REV");
myTextFrame.contents=T[3];
myTextFrame=sourceDoc.textFrames.getByName("DESENHISTA");
myTextFrame.contents=T[4];
myTextFrame=sourceDoc.textFrames.getByName("MATERIAL");
myTextFrame.contents=T[5];
myTextFrame=sourceDoc.textFrames.getByName("ADESIVO");
myTextFrame.contents=T[6];
myTextFrame=sourceDoc.textFrames.getByName("TUBETE");
myTextFrame.contents=T[7];
myTextFrame=sourceDoc.textFrames.getByName("ROLOS/PACOTES");
myTextFrame.contents=T[8];
myTextFrame=sourceDoc.textFrames.getByName("ESPV");
myTextFrame.contents=T[9];
myTextFrame=sourceDoc.textFrames.getByName("ESPH");
myTextFrame.contents=T[10];
myTextFrame=sourceDoc.textFrames.getByName("PUXADA");
myTextFrame.contents=T[11];
myTextFrame=sourceDoc.textFrames.getByName("CARREIRAS");
myTextFrame.contents=T[12];
myTextFrame=sourceDoc.textFrames.getByName("NOME ARQUIVO");
myTextFrame.contents=T[13];
myTextFrame=sourceDoc.textFrames.getByName("BOBINAMENTO");
myTextFrame.contents=T[14];
myTextFrame=sourceDoc.textFrames.getByName("DATA");
myTextFrame.contents=TodayDate();
}
var destFilePath = "~/Desktop/"+T[13]+"_ARTE.ai"
alert(destFilePath)
function exportFileToAI (dest) {
if ( app.documents.length > 0 ) {
var saveOptions = new IllustratorSaveOptions();
var ai8Doc = new File(dest);
saveOptions.compatibility = Compatibility.ILLUSTRATOR16;
saveOptions.flattenOutput = OutputFlattening.PRESERVEAPPEARANCE;
app.activeDocument.saveAs( ai8Doc, saveOptions );
}
}
exportFileToAI (destFilePath);
alert("Formulário preenchido com sucesso");