OK so I got this squared away to where the art board moves to the selected items. Someone else wrote the code to move the art board to the selected items and I modified it to fit my needs. So that being said big thanks to pixxxel schubser for the code for that part (found here... https://forums.adobe.com/thread/1336506 ) Here is the code for anyone to see/modify/use!
#target illustrator
var newDocSet = new DocumentPreset;
newDocSet.title = "Cover"
newDocSet.width = (8.5 * 72);
newDocSet.height = (11 * 72);
newDocSet.units = RulerUnits.Inches;
newDocSet.colorMode = DocumentColorSpace.RGB;
var doc = app.activeDocument;
var selectedItems = doc.selection;
if (selectedItems.length > 0) {
var newDoc = app.documents.addDocument(DocumentColorSpace.RGB, newDocSet);
for (var i = 0; i < selectedItems.length; i++) {
var newArt = selectedItems.duplicate(newDoc, ElementPlacement.INSIDE);
}
} else {
alert("nothing selected");
}
// to move the new document artboard over to the selected items
var doc = app.activeDocument;
var selectedItems = doc.selection;
var abIdx = doc.artboards.getActiveArtboardIndex();
var actAbBds = doc.artboards[abIdx].artboardRect;
var vBounds = selectedItems[0].visibleBounds;
vBounds_Li = vBounds[0];
vBounds_Ob = vBounds[1];
vBounds_Re = vBounds[2];
vBounds_Un = vBounds[3];
if (selectedItems.length >1 ) {
for (i=1; i<selectedItems.length ; i++) {
vBdsI = selectedItems.visibleBounds;
if( vBounds_Li > vBdsI[0] ) {vBounds_Li = vBdsI[0]};
if( vBounds_Ob < vBdsI[1] ) {vBounds_Ob = vBdsI[1]};
if( vBounds_Re < vBdsI[2] ) {vBounds_Re = vBdsI[2]};
if( vBounds_Un > vBdsI[3] ) {vBounds_Un = vBdsI[3]};
}
doc.artboards[abIdx].artboardRect = [vBounds_Li +((vBounds_Re - vBounds_Li)/2-(actAbBds[2]-actAbBds[0])/2), vBounds_Ob -((vBounds_Ob - vBounds_Un)/2+(actAbBds[3]-actAbBds[1])/2), vBounds_Li +((vBounds_Re - vBounds_Li)/2-(actAbBds[2]-actAbBds[0])/2)+(actAbBds[2]-actAbBds[0]), vBounds_Ob -((vBounds_Ob - vBounds_Un)/2+(actAbBds[3]-actAbBds[1])/2)+(actAbBds[3]-actAbBds[1])];
}
// save .ai and .pdf file to correct locations, then close the file
var allDocs = app.documents;
for(var i = 0; i < allDocs.length; i++){
var fileName = allDocs[1].name;
var jobName = (fileName).substr(0, 11);
aiFile = "D:\\Job Number\\"+jobName+"\\AI\\Cover.ai"
pdfFile = "D:\\Job Number\\"+jobName+"\\PDF\\Cover.pdf"
var newaiFile = new File(aiFile);
var doc = app.activeDocument;
doc.saveAs (newaiFile);
saveAI();
var pdfOpts = new PDFSaveOptions();
pdfOpts.pDFXStandard=PDFXStandard.PDFXNONE;
pdfOpts.compatibility = PDFCompatibility.ACROBAT5;
pdfOpts.preserveEditability = false;
var newpdfFile = new File(pdfFile);
doc.saveAs(newpdfFile, pdfOpts);
}
function saveAI( path, name, id ) {
var saveOpts = new PDFSaveOptions();
saveOpts.compatibility = PDFCompatibility.ACROBAT6;
}
doc.close(SaveOptions.SAVECHANGES);
... View more