Javascripting PDF files

greets to all.

would anyone know if it is possible to disable the print and save buttons in a pdf document once it is opened from a weblink.

(i know that a copy gets saved to the cache anyway. This is gonna be used for intranet PDF files.)

i found this code but i'm not sure on the correct usage...

app.hideMenuItem("filename"),app.hideToolbarButton("Save"),app.hideToolbarButton("print");

like this:

<script src="js/lockout.js" type="text/javascript"></script>
<script language="JavaScript" type="text/JavaScript">
function pdfDOC()
{
window.open('pdffile.pdf', null,'top=100,left=200,width=740,height=580,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes');
}
</script>

or:

<script language="JavaScript" type="text/JavaScript">
function pdfDOC()
{
app.hideMenuItem("HHPolicy1.pdf"),app.hideToolbarButton ("Save"),app.hideToolbarButton("print");
window.open('pdffile.pdf', null,'top=100,left=200,width=740,height=580,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes');
}
</script>

TIA
[1272 byte] By [esk] at [2007-11-19 19:27:22]
# 1 Re: Javascripting PDF files
would anyone know if it is possible to disable the print and save buttons in a pdf document once it is opened from a weblink.
No. You can't do this. The source code that you copied is Visual Basic and possibly VBScript. It is not JavaScript.
PeejAvery at 2007-11-8 0:22:35 >
# 2 Re: Javascripting PDF files
would anyone know if it is possible to disable the print and save buttons in a pdf document once it is opened from a weblink.Not sure if you can do that with javascript embedded into the web page with the link, but you can add different security measures when creating the pdf document. Here's an article that might help; Securing Your Documents in Adobe Acrobat 7 (http://www.heathrowecs.com/default.asp?view=display&ID=178).

The source code that you copied is Visual Basic and possibly VBScript. It is not JavaScript.To me it seems like valid JavaScript (or ECMA script). One thing with JavaScript is that its dependant on its host/environment. When running a script in a web browser the global object is called window, and let you access different properties related to the browser window. When running javascript within a PDF document the global object is called app and allows you to access properties and functions that's meaningful within a PDF document.

For more click Acrobat JavaScript Scripting Guide (http://partners.adobe.com/public/developer/en/acrobat/sdk/AcroJSGuide.pdf).

- petter
wildfrog at 2007-11-8 0:23:43 >
# 3 Re: Javascripting PDF files
To me it seems like valid JavaScript (or ECMA script).
Well, if you look at the last post ( http://www.vbforums.com/archive/index.php/t-282140.html) of this thread at VBForums you will see that it is Visual Basic.
PeejAvery at 2007-11-8 0:24:39 >
# 4 Re: Javascripting PDF files
Ok, but I thought that

1.

var sPlatform = app.viewerVariation;
VBScript use Dim to declare variables, Javascript use var.
VBScript use newline to terminate statements, Javascript use semicolon.

2.

if (sPlatform == "Reader") {
sPos = "3";
}
VBScript use a single '=' to compare values, JavaScript use '=='.
VBScript use Then/End If to determine scope in an if statement, JavaScript use '{' and '}'.

3.

function TestMe() {
...
VBScript use Function/End Function to declare a function... I'm still not convinced that this is VBScript. :confused:

If you read RobDog888s other posts in that discussion you'll see that he mentions 'JavaScript' several times.

- petter
wildfrog at 2007-11-8 0:25:45 >
# 5 Re: Javascripting PDF files
Okay. I see now. I guess I read through it too quickly. It is JavaScript.

Still, I don't see how JavaScript can alter another application unless it is a plugin to the browser.
PeejAvery at 2007-11-8 0:26:40 >
# 6 Re: Javascripting PDF files
Still, I don't see how JavaScript can alter another application unless it is a plugin to the browser.Javascript can be used in any application as long as the application supports javascript ;). Typical examples are ofcourse web browsres. Then you got web servers. Other examples are 'voice browsers' running CCXML/VoiceML to route phonecalls and handle IVR stuff. In our case we got javascript embedded into PDF documents. And I'm sure there are many other javascript enabled applications out there...

If you wan to embed JavaScript/ECMAScript into your own application you can implement an engine yourself by digging into the ECMAScript Language Specification (http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf) or simply embed Mozillas SpiderMonkey or Rhino (http://www.mozilla.org/js/).

- petter
wildfrog at 2007-11-8 0:27:39 >