• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Exporting named artboard as svg without the rest of the files contents?

Community Beginner ,
Jan 24, 2023 Jan 24, 2023

Copy link to clipboard

Copied

Is there a way to export an artboard as an svg but only the contents of that artboard and nothing else on the canvas/other artboards?

I had a look and seems like other people have has this issue?
Would a solution be to remove all objects/artboards except the contents of the artboard needed first?

Thanks in advance!

// Get the active document
var doc = app.activeDocument;

// Loop through all artboards in the document
for (var i = 0; i < doc.artboards.length; i++) {
  var artboard = doc.artboards[i];
  
  // Check if the artboard's name is "Backprint"
  if (artboard.name == "Backprint") {
    
    // Set the artboard as the active artboard by its index
    doc.artboards.setActiveArtboardIndex(i);

    // Get the current document's name
    var docName = doc.name.split(".")[0];
    
    // Set the export options
    var exportOptions = new ExportOptionsSVG();
    exportOptions.embedRasterImages = true;
    exportOptions.embedAllFonts = true;
    exportOptions.coordinatePrecision = 7;
    exportOptions.minify = false;
    exportOptions.cssProperties = SVGCSSPropertyLocation.STYLEELEMENTS;
    exportOptions.fontType = SVGFontType.SVGFONT;
    
    // Set the file name
    var fileName = docName + "_Backprint";
    
    // Get the current file's path
    var filePath = doc.path;
    
    // Export the artboard
    doc.exportFile(new File(filePath + "/" + fileName), ExportType.SVG, exportOptions);
    
    // Exit the loop
    break;
  }
}

 

TOPICS
Scripting

Views

141

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
LEGEND ,
Jan 24, 2023 Jan 24, 2023

Copy link to clipboard

Copied

LATEST

Artboards are not object containers, so no, just removing other artboards wouldn't do much. You can of course cook up all sorts of checks if an object is off-artbhoard and such and then remove them, but there's no simply function for that.

 

Mylenium

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines