Friday, December 9, 2011

Pdf To Post Script

Write this function in a Java Script file and save this file into JavaScript Folder inside Adobe(C:\Program Files\Adobe\Acrobat 9.0\Acrobat\Javascripts) with js extension.

function pdftops()
{
var pp = this.getPrintParams();

var path = this.path;
path = path.replace("/\//gi", "");
path = path.replace("/%20/gi", " ");
path = path.replace("/\\/gi", "\/");

var PdfName = path;
var iDotIndex = PdfName.indexOf(".");
PdfName = PdfName.substring(0,iDotIndex);

var OutputFilePath = this.documentFileName;

pp.fileName = PdfName + ".ps";
pp.printerName = "";
this.print(pp);
}

Or you can download java script file from this path

PdfToPs

Now call this function from VB .Net in this way

Private Sub ConverToPostScript(ByVal InputFilePath As String)
Dim gApp As Acrobat.CAcroApp
Dim gPDDoc As Acrobat.CAcroPDDoc
Dim jso As Object
Dim PsFilePath As String


gApp = CreateObject("AcroExch.App")
gPDDoc = CreateObject("AcroExch.PDDoc")
If gPDDoc.Open(InputFilePath) Then

jso = gPDDoc.GetJSObject

PsFilePath = System.IO.Path.ChangeExtension(InputFilePath, "ps")

If (System.IO.File.Exists(PsFilePath)) Then
System.IO.File.Delete(PsFilePath)
End If

jso.pdftops()
}

Before start coding in .Net you need to add Arobat dll reference from com component(Adobe Acrobat 9.0 Type Library)

Complete Setup Here Distiller

No comments:

Followers

Link