Trainings

Tuesday, September 16, 2014

ColdFusion 11 PDF documentation available now

CF11 PDF documentation:

Finally adobe has published PDF documentation for ColdFusion 11.
Below is the link
https://wikidocs.adobe.com/wiki/display/coldfusionen/ColdFusion+11+Documentation

Friday, August 1, 2014

Call another InDesign script with doScript in InDesign script

var myFile = new File ('/C/prashant/indd/bookCreateExport.jsx');  
 if (myFile.exists)  
 {  
        //Call another script
  app.doScript(myFile ,ScriptLanguage.JAVASCRIPT) 
 } 

InDesign Script: create an Indesign book and add documents to book and finally export book to pdf.

/************************************************
  1. Create an InDesign book
  2. add documents to InDesign book - bookContents object to be used
  3.. export book as a pdf

 **************************************************/


var filein ="/C/prashant/indd/Book3.indb" ; //path for indesign book which needs to be exported as pdf.
var fileout = "/C/prashant/indd/Book2.pdf" ;    //path for the exported pdf
var notesDoc = "/C/prashant/indd/HelloWorld.indd" ;


var mypdf = new File(fileout);  //create pdf file object
var mybook = new File(filein);

//1. Create / Open a book
//if book does not exists then create it
if(!mybook.exists)
{
    //create a new book
    var book = app.books.add(mybook);  
}
else{
    //book exists so we can open it.    
    var book = app.open(mybook);  //open book
}

//2. add documents to book
book.bookContents.add(File(notesDoc));

//3. export book to pdf
book.exportFile(ExportFormat.PDF_TYPE,mypdf);

//close book without save the book.
book.close(SaveOptions.NO);  

Thursday, July 31, 2014

InDesign Script : Update Table of content ( TOC )

To update Table of content / TOC using InDesign Script , Code is given below highlighted in Pink.

Note : 
1. This article assumes that you have already create TOCStyle and Table of content
and you want to update TOC at run time by indesign script.

2. TOCStyle is already created in document "TOCDocument.indd"
3. while exporting document , to include Table of Content as a bookmarks in pdf , use exportPdf seetings to export table of content as bookmarks. Otherwise TOC will not appear in PDF.

 //path for indesign book which needs to be exported as pdf.
var filein ="/C/prashant/indd/TOCDocument.indd" ;

var fileout = "/C/prashant/indd/TOCDocument.pdf" ;    //path for the exported pdf
var TOCStyle = "TOCStyle"; //this name can be changed depend on the TOCStyle.

var mypdf = new File(fileout);  //create pdf file object

//Open InDesign book
var doc = app.open(File(filein));  //open book


var tocStyles = doc.tocStyles ; //get all tocs from a document
var TOCStyle = tocStyles.itemByName(TOCStyle);  //got the fundbridge TOC style.
doc.createTOC(TOCStyle,true); // to update TOC pass replacing = true i.e. second argument of creatTOC() method.

//export book to pdf
doc.exportFile(ExportFormat.PDF_TYPE,mypdf);

//close book
doc.close(SaveOptions.NO);

Wednesday, July 30, 2014

InDesign Script : export InDesign book as a pdf

var filein ="/C/prashant/indd/Book1.indb" ; //path for indesign book which needs to be exported as pdf.
var fileout = "/C/prashant/indd/Book1.pdf" ;    //path for the exported pdf
var mypdf = new File(fileout);  //create pdf file object

//Open InDesign book
var book = app.open(File(filein));  //open book

//export book to pdf
book.exportFile(ExportFormat.PDF_TYPE,mypdf);

//close book
book.close(SaveOptions.NO);

Monday, June 16, 2014

Coldfusion 10/11 Case Sensitive URLs?!?

Problem:
I just migrated my CF8 site to CF11  and noticed that  issues were occuring with missing images. 
A link to "BLUEBALL.jpg" will not bring up "blueball.jpg".

Solution:
look for context.xml under {drive}\ColdFusion11\cfusion\runtime\conf

Change the context tag to look like:

After
<Context AllowLinking="true" caseSensitive="true">

Restart the CF service 

Monday, October 28, 2013

How to know External IP of a intranet IP

Let say you have a situation that your application runs on Intranet and you want to communicate with  other application which is behind the firewall. so they need the External IP to allow traffic
from fixed IP(s).

Below is the code which shows how to get the External IP in colfusion / Java.

IN ColdFusion
------------------
create a File IPAddress.cfm
<cfset sURL = "http://checkip.amazonaws.com">
 <cfhttp method="get" url="#sURL#>
 <cfdump var="#cfhttp.filecontent#">

IN JAVA
------------
create a class IPAddress.java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;

public class IPAddress {

    public static String getIp() throws Exception {
        URL whatismyip = new URL("http://checkip.amazonaws.com");
        BufferedReader in = null;
        try {
            in = new BufferedReader(new InputStreamReader(
                    whatismyip.openStream()));
            String ip = in.readLine();
            return ip;
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
   
    public static void main(String[] args) {
        // TODO Auto-generated method stub

        try{
        System.out.println(getIp());
        }
        catch(Exception e){
            System.out.println("exception:"+e.getMessage());
        }
    }
   
}


compile this file on your machine and run you will get the External ip.