These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Add acrobat javascript into c#.net windows application

dkataria
Registered: Jun 13 2008
Posts: 15
Answered

Hi

1. How can i add acrobat java script into c# windows application.

2. How can i group several pdf files into single pdf.

3. How can i convert pdf file into ps using adobe javascript or c#.net.

Please tell from where should i start.

Thanks in advance.

Regards,
Deepak Kataria

My Product Information:
Acrobat Standard 8.0, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
1. How can i add acrobat java script into c# windows application.

The same way you would run JS from a VB app. Get the documentation here:
http://www.adobe.com/devnet/acrobat/interapplication.php

You'll be acquriing the JSO object from the PDDoc object.


2. How can i group several pdf files into single pdf.

Append them together, wrap them in PDF Package, or just make them file attachments. There's a menu item for this on the "File" menu


3. How can i convert pdf file into ps using adobe javascript or c#.net.

Print the PDF to a file using a null printer, like this:

var pp = this.getPrintParams();
pp.fileName = "/c/temp/myDoc.ps";
pp.printerName = "";
this.print(pp);

I copied this code from the Acrobat JavaScript Reference. Example #3 for the doc.print() fucntion.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

andrew17
Registered: Jun 23 2008
Posts: 3
Hi
But how can i call or write javascript in my vb.net.

Please help me on this.
dkataria
Registered: Jun 13 2008
Posts: 15
Hi Thomp,

I read the documentation but i didn't find any way that how to call my javascript into my application.

Here is my C# code:-

AcroApp gApp = new AcroApp();
AcroAVDoc acroAVDoc = new AcroAVDoc();
acroAVDoc.Open(@"C:\test.pdf","output");


CAcroPDDoc acroDoc = (CAcroPDDoc)acroAVDoc.GetPDDoc();
acroDoc.Open(@"C:\test.pdf");

gApp.hide();
Object jso = acroDoc.GetJSObject();


And here is my Javascript:-

var pp = this.getPrintParams();
pp.fileName = "/c/testoutput.ps";
pp.printerName = "";
this.print(pp);

Now how can i call my javascript into my application.

Thanks in advance.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Please take a look at the JavaScript examples in the IAC documentation. You'll find examples of how to use the JSO

The jso object is a bridge to the Acrobat JavaScript context. You can use it to call any function in the context of the open document, which includes folder level functions.

I would suggest creating a folder level function for your code. Then calling this function from the JSO.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

dkataria
Registered: Jun 13 2008
Posts: 15
Hi Thomp,

When i converting pdf into ps. It doesn't pick fonts.

Pls guide me how can i get actual font.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
I'm sorry, I don't know anything about how the fonts get into the PS. It's not a JS issue. You would do better asking this on one of the other forums, like "Printing and PrePress" or "PDF Creation"

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script