Skip to main content
karth80472045
Inspiring
May 21, 2016
Question

Help me to convert svg to pdf in the script

  • May 21, 2016
  • 0 replies
  • 886 views

dear all,

i need to modify this script of saving svg to pdf can anybody help me

  1. function filesToArtboards() { 
  2.  
  3.           // My function variables… 
  4.           var doc, fileList, i, inFolder, mm, svgFile; 
  5.  
  6.           // Get the user to select a folder 
  7.           inFolder = Folder.selectDialog( 'Please choose your Folder of files to place…' ); 
  8.  
  9.           // Check they ain't cancelled 
  10.           if ( inFolder != null ) { 
  11.  
  12.                     // Gets just the SVG files… 
  13.                     fileList = inFolder.getFiles( /\.svg$/i ); 
  14.  
  15.                     // Make sure it has AI files in it… 
  16.                     if ( fileList.length > 0 ) { 
  17.  
  18.                               mm = 2.83464567 // Metric MM converter… 
  19.  
  20.                               // Set the script to work with artboard rulers 
  21.                               app.coordinateSystem = 
  22.                               CoordinateSystem.ARTBOARDCOORDINATESYSTEM; 
  23.  
  24.                               // Add new multi-page document 
  25.                               doc = app.documents.add( 
  26.                                          DocumentColorSpace.RGB, 
  27.                                          width = 148.5*mm, 
  28.                                          height = 210*mm, 
  29.                                          numArtboards = fileList.length, // The number of SVG files 
  30.                                          DocumentArtboardLayout.GridByCol, 
  31.                                          artboardSpacing = 20*mm, 
  32.                                          artboardRowsOrCols = Math.round( Math.sqrt( fileList.length ) ) 
  33.                               ); 
  34.  
  35.                               // Loop thru the counter 
  36.                               for ( i = 0; i < fileList.length; i++ ) { 
  37.  
  38.                                         // Set the active artboard rulers based on this   
  39.                                         doc.artboards.setActiveArtboardIndex( i ); 
  40.  
  41.                                         // Create group from SVG 
  42.                                         svgFile = doc.groupItems.createFromFile( fileList ); 
  43.  
  44.                                         // Move relative to this artboards rulers 
  45.                                         // Top Left 
  46.                                         sgvFile.position = [ 0, 0 ]; 
  47.  
  48.                               }; 
  49.                     }; 
  50.  
  51.           }; 
  52.  
  53. }; 
  54.  
  55. filesToArtboards();

i want to modify this code that it has to save as pdf , because we will save svg file as pdf by pressing (shift+o)  artboard selection and we choose landscape and save as A4 format as pdf with same file name can anybody modify this script .

This topic has been closed for replies.