Does anyone know if the smartsrteam design can be used to output different files? We have a client that wants a separate PDF for each record. My first thought is, just split it within Switch. But they want the files named according to a variable in the database, so I'm not sure how to make that happen.
Any ideas?
Smartstream Question
Smartstream Question
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Re: Smartstream Question
And to simplify this question: can you pull text out of a PDF via Switch or Pitstop? If so, we could tie the variable to a hidden field in the PDF.
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Re: Smartstream Question
Answer to this, you can use PdfSpy from Apago. It has an function that reads text and make it metadata.. Have used it with some jobs.gabrielp wrote:And to simplify this question: can you pull text out of a PDF via Switch or Pitstop? If so, we could tie the variable to a hidden field in the PDF.
Between jobs!
Re: Smartstream Question
I got this from Dwight at Apago..


Code: Select all
// PDFspy text search
// (c) 2012-2014 by Apago, Inc.
// All rights reserved
//
// Created by Dwight Kelly <dkelly@apago.com>
// Date: 2012/01/20
// Modified: 2014/11/31
// Switch logging & output levels
const cLogAssert = -2;
const cLogDebug = -1;
const cLogInfo = 1;
const cLogWarning = 2;
const cLogError = 3;
const cLogProgress = 5;
const cSendSuccess = 1;
const cSendWarning = 2;
const cSendError = 3;
function isolate( job : Job, str : String, matchPos : Integer ) : String
{
// trim left side
if (matchPos > 1)
str = str.substring(matchPos);
var ltPos = matchPos;
if (str.charAt(ltPos) == ' ') // watch out for leading spaces
ltPos++;
var parts = str.split(" ");
if (parts.length > 1)
return parts[1];
return "";
}
function jobArrived( s : Switch, job : Job )
{
if (job.isFolder()) {
job.fail( "This configurator cannot handle job folders" );
return;
}
if (!job.isType("pdf")) {
job.fail("This configurator only supports PDF");
return;
}
var appPath;
if (s.isMac())
appPath = "/Applications/pdfspy/pdfspy";
else
appPath = "c:/Program Files (x86)/Apago/PDFSpy/pdfspy";
var String args = new Array();
var argc = 0;
args[argc++] = appPath;
args[argc++] = "-text";
var String outFile = job.createPathWithExtension("txt", false); // output file
args[argc++] = "-o";
args[argc++] = outFile;
args[argc++] = job.getPath(); // input file
var exitStatus = Process.execute(args);
if (exitStatus != 0) {
// failure
job.log(cLogError, "Could not extract text from PDF");
job.sendToData( cSendError, job.getPath() );
return;
}
if (!File.exists(outFile)) {
// failure
job.log(cLogError, "Could not open text file " + outFile);
job.sendToData( cSendError, job.getPath() );
return false;
}
var textFile = new File( outFile, "UTF-8" );
textFile.open(File.ReadOnly);
var theMarker = s.getPropertyValue("marker");
var theSearchType = s.getPropertyEditor("marker");
var theRegEx = (theSearchType == "Single-line text") ? theMarker : new RegExp(theMarker);
var cnt = 0, matchPos;
do {
var line = textFile.readLine();
if (cnt++ == 0 && line.charCodeAt(0) == 0x0c) {
// blank page
textFile.close();
var jobid = job.getNameProper().split("_");
job.setPrivateData("ExtractedName", jobid[0]);
//job.log(cLogInfo, "Blank page '" + jobid[0] + "'");
job.sendToData( cSendSuccess, job.getPath() );
return;
}
matchPos = line.search(theRegEx);
if (matchPos >= 0) {
line = isolate(job, line, matchPos);
if (line.length > 0) {
textFile.close();
job.setPrivateData("ExtractedName", line);
job.log(cLogInfo, "Extracted name = '" + line + "'");
job.sendToData( cSendSuccess, job.getPath() );
return;
}
}
} while (!textFile.eof);
// failure
textFile.close();
job.log(cLogError, "Could not find the marker text");
job.sendToData( cSendError, job.getPath() );
}


Between jobs!
Re: Smartstream Question
Thanks man. I'll look into PDFSpy.
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Re: Smartstream Question
No problem, glad if it helped!
And as an example you use the "Marker" text as trigger. It looks for that text and to the next "space" I think it was..
And as an example you use the "Marker" text as trigger. It looks for that text and to the next "space" I think it was..
Between jobs!
Re: Smartstream Question
Got it working today with some help from Dwight. Thanks Lombert. PDFSpy is super useful. 

Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix