1

I am trying to generate a pdf file that opens another pdf file with this code

\usepackage[pdftex]{insdljs}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Main Script
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{insDLJS}{dljs}{Document Javascript}

doesitopen = app.trustedFunction (function() {
    var reffile1,openf;
    try {
        app.alert("trying c:/temp/existing.pdf",3);
        console.println('here');
        app.beginPriv();
            app.openDoc("/c/temp/existing.pdf");
        app.endPriv();
        openf = 1;
    }
    finally {
        e = null;
    }
    app.alert("diditopen",3);

});

doesitopen();
\end{insDLJS}

Here is my Lyx file - it's pretty vanilla --

#LyX 2.0 created this file. For more info see http://www.lyx.org/
\lyxformat 413
\begin_document
\begin_header
\textclass scrartcl
\begin_preamble
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Document product, type, number and title
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Conditional text
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% DO NOT ALTER AFTER THIS POINT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[pdftex]{hyperref}
\usepackage[pdftex]{eforms}
\input{jsfunctions_bare.tex}
\end_preamble
\use_default_options false
\maintain_unincluded_children false
\language english
\language_package default
\inputencoding auto
\fontencoding global
\font_roman times
\font_sans helvet
\font_typewriter courier
\font_default_family sfdefault
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 83
\font_tt_scale 100

\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize default
\spacing single
\use_hyperref false
\papersize default
\use_geometry true
\use_amsmath 1
\use_esint 1
\use_mhchem 1
\use_mathdots 1
\cite_engine basic
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\use_refstyle 0
\index Index
\shortcut idx
\color #008000
\end_index
\leftmargin 1in
\topmargin 0.75in
\rightmargin 1in
\bottommargin 1.25in
\headheight 0in
\headsep 0.5in
\secnumdepth 3
\tocdepth 3
\paragraph_separation skip
\defskip medskip
\quotes_language english
\papercolumns 1
\papersides 1
\paperpagestyle fancy
\bullet 0 2 14 -1
\bullet 1 2 5 -1
\bullet 2 2 9 -1
\bullet 3 2 21 -1
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header

\begin_body

\begin_layout Standard
\noindent
\align block

\series bold
Click below to test app.openDoc
\end_layout

\begin_layout Standard
\noindent
\align block
\begin_inset ERT
status open

\begin_layout Plain Layout


\backslash
raisebox{-1.3pt}{
\backslash
pushButton[
\backslash
CA{Export}
\backslash
A{
\backslash
JS{doesitopen();}}]{export14}{12mm}{11pt}}
\end_layout

\end_inset


\end_layout

\end_body
\end_document

My problem is that Adobe Refuses to execute my code despite having used app.trustedFunction and marked my code with app.beginPriv() and app.endPriv()

When I run Adobe Reader XI, I get this error in the JavaScript console :

Acrobat EScript Built-in Functions Version 11.0 Acrobat SOAP 11.0

NotAllowedError: Security settings prevent access to this property or method. App.trustedFunction:3:Document-Level:01 Document Javascript

NotAllowedError: Security settings prevent access to this property or method. App.trustedFunction:1:Document-Level:01 Document Javascript

NotAllowedError: Security settings prevent access to this property or method. App.trustedFunction:1:Document-Level:01 Document Javascript

  • 1
    Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – user31729 Jul 23 '14 at 19:44
  • Thanks! I'll work on that -- total noob and all I have are the lyx and tex files... – Matt Jul 23 '14 at 19:54
  • I am no JavaScript expert at all, but if is just opening another .pdf file in Acrobat, you could use a \href command from hyperref package. – user31729 Jul 23 '14 at 22:51
2

According to the JavaScript for Acrobat API Reference, the method app.trustedFunction is security restricted and only allowed in batch, console and application initialization events, that is, not in document level JavaScript.

On the other hand, app.openDoc() doesn't need to be called in a trusted environment.

Therefore,

\begin{insDLJS}{dljs}{Document Javascript}
  app.openDoc('c:/temp/existing.pdf');
\end{insDLJS}

should already work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.