Quantcast
Channel: Adobe Community : Popular Discussions - JavaScript
Viewing all 12130 articles
Browse latest View live

How can I add form field value to the file name in save as dialog box

$
0
0

I do not want the form to be saved automatically, just want the form to auto populate the "file name" only.

 

A little background on the forms I want to use:  My company has 70 retail outlets, I'll use one of our pdf forms called an "Incident Report" as an example.  I would like for a store manager to be able to complete the form, then email the form to the main office (I already have javascript to add field values and form name to the email subject line), once the main office receives it, I want for them to be able to file the pdf electronically on our server.  We have mutliple forms that we use so I do not want any of the forms to automatically save anywhere, (at this time anyway) I just want the office personnel to be able to click "save as" (or whatever they will need to click) and the form automatically add certain field values from the pdf they have received, of which will be different each time the form is sent to the office (Date, store #, employee name etc.) in addition to the name of the form in the "File name" of the "Save As" dialog box.  The main office employees will decide into which server file the pdf should be saved.

 

I'm using Acrobat 8 professional, the stores and office personnel use Adobe reader.

 

One little note:  We currently print and file a lot of paper on a daily bases, as soon as I can get this to work, we are going green.

 

Me and a lot of trees in this will really apprecitate any help you can give with this!  :-)


Auto Printing PDF docs in FTP folder

$
0
0

Ok so here is the deal,

 

I have an FTP folder set up in a Windows 2003 server environment. I will be recieving PDF docs into an FTP file a few times a day and I would like to know if there is a way for me to make it so that the PDF documents print automatically once they get to my FTP folder.

 

Any ideas? I have seen some software around the internet that does something like that but I think there has to be another way.

Classic 'Flatten PDF' question

$
0
0

So I have created a fairly complex fillable form in Acrobat Pro (10.1.8)... I have saved it for use by other users in Adobe Reader. (File>Save As>Reader Extended PDF>Enable Additional Features...)

 

The users can open file in Adobe Reader just fine, all formulas work, all values display correctly, life is grand.

 

Now all I want is for the user to save a 'flattened' version of the pdf to their machine, either to print or email at a later date. If the user saves the document from Reader all fields can still be edited on next use. If I use a "lock all field" button like this:

 

for (var i=0; i<this.numFields; i++) {

    var f = this.getField(this.getNthFieldName(i));

    if (f!=null && f.type!="button")

        f.readonly = true;

}

 

 

When I open the saved, field locked document, I lose all the formatting in my fields. (ie. no $ symbols, or commas in numbers, etc. )

 

And of course, there is no "print to pdf" option when you try and go that route... which of course, would make life too easy, wouldn't it?

 

So. Does anyone have a solution for what I can only imagine is a fairly common problem? I've searched high and low to no avail.

Combo box with multiple variables pre populating multiple fields and max value validation script help

$
0
0

I am creating a pdf form that will be used as a calculator, and my javascript knowledge is pretty rudimentary. I can do the simple things, some of what I need to do is over my head.

 

1. I believe I need to use a combo box to pre populate certain fields. I have 13 variables in the dropdown to choose from, and whatever the client chooses will pre populate three other fields (and each of the 13 variables will populate those three fields differently). I'm not exactly sure how to go about doing this. Is it custom keystroke script or does it require a document script? Also, I'm guessing that whatever script will be a series of if/then statements, correct?

 

2. Once all the fields have been populated (be it pre population or filled in by the customer), I need to calculate the answer which is not my main problem—I already have the proper calculations in place and they work. The problem is that the answer has a maximum value even if the actual value goes over that max number. So, the actual answer is 14 but the max value can only be 12. How do I get the calculation to replace that actual number (14) with the max number (12)? Is that in the validation tab or should that go elsewhere?

 

I feel like I know just enough to be dangerous but not terribly effective. Any help is appreciated.  

Thanks!

Acrobat Forms - javascript to hide/unhide text box if any one of a number of radio buttons is enable

$
0
0
I have a form which I am designing in Acrobat 9 which has a section where there are three questions, each with a pair of radio buttons - one for 'yes' and one for 'no'. They are in the style of a check box (with a tick). I need some help to write some code which will unhide a single field (or multiple fields if I need to use something similar at a later date) if any one of the 'yes' radio buttons is checked. So if all three radio buttons were checked, the field would be hidden but if you then changed your mind and clicked a yes button, the field would be visible.

I am new to this so any help would be greatly appreciated. Many thanks in advance! I hope that i have explained this clearly btw.

Javascript/ Batch Processing - Query (Please assist/advice)

$
0
0

Hi

 

Where can I find on the internet a JavaScript that will do the following for BATCH PROCESSING:

 

 

-Combine single PDF files

-Crop the pages

-Check the sequence of the pages that it goes from 1,2,3 and so on

-ad metadata to the PDF

-set view

-add bookmarks based on the content page's major headings (e.g. Regulars)

-Making single PDF files over 1.5 MB smaller

-Fix white lines

-Make the final file as a PDF that is compatible with Acrobat 5 or later

 

Thanks

 

 

this.print(pp) with interactive type silent or automatic does not work after upgrade acrobat reader 9 to acrobat reader 11

$
0
0

After an upgrade of acrobat reader 9 to acrobat reader 11 the automatic printing of a pdf. The pdf is opened, but the print does not happen. With acrobat reader 9 it works. But with acrobat reader 11 the printing does not happen.

I discovered when you specify pp.constants.interactionLevel.full it works on acrobat reader 11. But when you specify pp.constants.interactionLevel.silent or pp.constants.interactionLevel.automatic it does not work on acrobat reader 11. But with the full option we have a dialog  print box

we do not want.

 

 

In our jsp we load a pdf document and create a message handler to detect the print events of a pdf document that is in an <object> tag.

In the pdf document we add

 

package be.post.lpo.util;

 

import org.apache.commons.lang.StringEscapeUtils;

import org.apache.commons.lang.StringUtils;

public class AcrobatJavascriptUtil {  

 

    public String getPostMessageToHostContainer(String messageName, String messageBody){

        return "var aMessage=['"+messageName+ "', '"+ messageBody+"'];this.hostContainer.postMessage(aMessage);";

    }

    public String getAutoPrintJavaScript(String interactiveType, String printerName,String duplexType) {    

        String interactiveTypeCommand = "";

        if (StringUtils.isNotBlank(interactiveType)){

            interactiveTypeCommand = "pp.interactive = " + interactiveType + ";";

        }

        String duplexTypeCommand = "";

        if (StringUtils.isNotBlank(duplexType)){

            duplexTypeCommand = "pp.DuplexType = " + duplexType + ";";

        }

    

        return "" + // //

                "var pp = this.getPrintParams();" + // //

                // Nointeraction at all dialog, progress, cancel) //

                interactiveTypeCommand + //

                // Always print to a printer (not to a file) //

                "pp.printerName = \"" + StringEscapeUtils.escapeJavaScript(printerName) + "\";" + //

                // Never print to a file. //

                "pp.fileName = \"\";" + //

                // Print images using 600 DPI. This option MUST be set or some barcodes cannot //

                // be scanned anymore. //

                "pp.bitmapDPI = 600;" + //

                // Do not perform any page scaling //

                "pp.pageHandling = pp.constants.handling.none;" + //

                // Always print all pages //

                "pp.pageSubset = pp.constants.subsets.all;" + //

                // Do not autocenter //

                "pp.flags |= pp.constants.flagValues.suppressCenter;" + //

                // Do not autorotate //

                "pp.flags |= pp.constants.flagValues.suppressRotate;" + //

                // Disable setPageSize i.e. do not choose paper tray by PDF page size //

                "pp.flags &= ~pp.constants.flagValues.setPageSize;" + //

                // Emit the document contents. Document comments are not printed //

                "pp.printContent = pp.constants.printContents.doc;" + //

                // printing duplex mode to simplex, duplex long edge, or duplex short edge feed //

                duplexTypeCommand +

                // Print pages in the normal order. //

                "pp.reversePages = false;" + //

                // Do the actual printing //

                "this.print(pp);";

    }

}

 

 

 

 

snippets for java code that adds

 

package be.post.lpo.util;

 

import org.apache.commons.lang.StringUtils;

 

import com.lowagie.text.Document;

import com.lowagie.text.DocumentException;

import com.lowagie.text.pdf.PdfAction;

import com.lowagie.text.pdf.PdfDestination;

import com.lowagie.text.pdf.PdfImportedPage;

import com.lowagie.text.pdf.PdfName;

import com.lowagie.text.pdf.PdfReader;

import com.lowagie.text.pdf.PdfWriter;

 

import java.io.IOException;

import java.io.InputStream;

import java.io.OutputStream;

import java.util.ArrayList;

import java.util.Iterator;

import java.util.List;

 

 

 

public class PdfMergerUtil{

 

    private static final PdfName DID_PRINT = PdfName.DP;

    private static final PdfName WILL_PRINT = PdfName.WP;

 

    

    private List<PdfActionJavaScriptHolder> actionJavaScripts = new ArrayList<PdfActionJavaScriptHolder>();

 

    private class PdfActionJavaScriptHolder{

    

        private final PdfName actionType;

        private final String javaScript;

    

        public PdfActionJavaScriptHolder(PdfName actionType, String javaScript) {

            super();

            this.actionType = actionType;

            this.javaScript = javaScript;

        }

    

        public PdfName getActionType(){

            return this.actionType;

        }

    

        public String getJavaScript(){

            return this.javaScript;

        }

    

    }

 

   

    public void writePdfs(OutputStream outputStream, List<InputStream> documents, String documentLevelJavaScript) throws Exception {

        Document document = new Document();

        try {          

          // Create a writer for the outputstream

          PdfWriter writer = PdfWriter.getInstance(document, outputStream);

          document.open();      

      

          // Create Readers for the pdfs.

          Iterator<PdfReader> iteratorPDFReader = getPdfReaders(documents.iterator());

                        

          writePdfReaders(document, writer, iteratorPDFReader);

          if (StringUtils.isNotBlank(documentLevelJavaScript)){

              writer.addJavaScript(documentLevelJavaScript);

          }

          addAdditionalActions(writer);

      

          outputStream.flush();      

      

        } catch (Exception e) {

            e.printStackTrace();

            throw e;

        } finally {

            if (document.isOpen()){

                document.close();

            }

            try {

                if (outputStream != null){

                    outputStream.close();

                }

            } catch (IOException ioe) {

                ioe.printStackTrace();

                throw ioe;

            }

        }

    

    }

 

    public void addAdditionalDidPrintAction(String javaScript){

        actionJavaScripts.add(new PdfActionJavaScriptHolder(DID_PRINT, javaScript));   

    }

 

    public void addAdditionalWillPrintAction(String javaScript){

        actionJavaScripts.add(new PdfActionJavaScriptHolder(WILL_PRINT, javaScript));   

    }

 

 

 

    private void writePdfReaders(Document document, PdfWriter writer,

            Iterator<PdfReader> iteratorPDFReader) {

        int pageOfCurrentReaderPDF = 0;      

          // Loop through the PDF files and add to the output.

          while (iteratorPDFReader.hasNext()) {

            PdfReader pdfReader = iteratorPDFReader.next();

            // Create a new page in the target for each source page.

            while (pageOfCurrentReaderPDF < pdfReader.getNumberOfPages()) {

              document.newPage();

              pageOfCurrentReaderPDF++;          

              PdfImportedPage page = writer.getImportedPage(pdfReader, pageOfCurrentReaderPDF);

              writer.getDirectContent().addTemplate(page, 0, 0);          

            }

            pageOfCurrentReaderPDF = 0;

          }

    }

 

    private void addAdditionalActions(PdfWriter writer) throws DocumentException{

        if (actionJavaScripts.size() != 0 ){

            PdfAction action = PdfAction.gotoLocalPage(1, new PdfDestination(PdfDestination.FIT), writer);

            writer.setOpenAction(action);

            for (PdfActionJavaScriptHolder pdfAction : actionJavaScripts ){

                if (StringUtils.isNotBlank(pdfAction.getJavaScript())){

                    action = PdfAction.javaScript(pdfAction.getJavaScript(), writer);

                    writer.setAdditionalAction(pdfAction.getActionType(), action);

                }

            }

        }

    }

 

 

 

 

    private Iterator<PdfReader> getPdfReaders(Iterator<InputStream> iteratorPDFs) throws IOException {

        List<PdfReader> readers = new ArrayList<PdfReader>();

          while (iteratorPDFs.hasNext()) {

            InputStream pdf = iteratorPDFs.next();

            PdfReader pdfReader = new PdfReader(pdf);

            readers.add(pdfReader);        

          }

        return readers.iterator();

    }

 

 

 

}

 

 

 

 

 

 

JSP code

<script type="text/javascript" src="<bean:message key="scripts.js.internal.jquery" bundle="app"/>"></script>

    <script language="javascript">

    function goToDidPrintUrl(){

        var url = "<%=didPrintUrl%>";

        window.location.assign(url);

    }

    function createMessageHandler() {

        var PDFObject = document.getElementById("myPdf");

        PDFObject.messageHandler = {

            onMessage: function(msg) {

                 if (msg[0] == "WILL_PRINT"){      

                    $("#printingTransitFeedBackMessage").text('<%=willPrintMessage%>');                   

                 }             

                 if(msg[0] == "DID_PRINT"){

                    $("#printingTransitFeedBackMessage").text('<%=didPrintMessage%>');               

                    setTimeout('goToDidPrintUrl()',4000);

                 }                            

            },

            onError: function(error, msg) {

                alert(error.message);

            }

        }

    }

    </script>

</head>

<body onLoad="createMessageHandler();">

<div id="printingTransitFeedbackArea">

  <div class="info" id="printingTransitFeedBackMessage"><%=documentOpenMessage%></div>

</div>

<object id="myPdf" type="application/pdf" width="100%" height="100%"  data="<%=toBePrintedUrl%>">

</object>

</body>


Keep Text in Uppercase

$
0
0

I am using Adobe Acrobat 9 Standard. I have script to change lowercase to uppercase in many form fields on a PDF. But if I return to the field that has already changed lowercase to uppercase, it goes back to lowercase until I exit the field again. These fields are used a lot to copy and paste into other applications and I want the fields to remain in uppercase once they are converted.

 

Please help!

 

I am using this to convert to uppercase: event.value = event.value.toUpperCase();

 

Thanks,

Brandy


Split PDF Files by Bookmarks

$
0
0
Can anyone please let me know how do I split PDF Files by bookmark using Java Script.

I am making a Visual Basic utility to read the bookmarks in PDF Files and split them based on the bookmarks. I am able to split the PDF Files by using Arts PDF Split Pro. However since I am already using Adobe Standard, I would like to do it with Adobe itself.

Thus, I pay license for only one software and not two.

Thanks
Rahul

Time and Date Stamp Format and User name

$
0
0

Hi All,

 

I am very new to adobe acrobat so forgive my ignorance.  I am trying to add a date and time stamp to pdf files using adobe acrobat so that when they are printed using adobe acrobat the print date will be automatically added.  First I have found the below script on the forum which is entered as a field, will this work using acrobat version 5 or version 7?  Also i believe that the date format is 10/01/2009.  How can I change this so that it will be in the 01 October 2009 and 24 hour clock format?  Finally how do I also add some descriptive text before the date and time i.e. 'print date' and 'not valid 24 hours after printing'?

 

var f = this.getField("today");

f.value = util.printd("mm/dd/yyyy

h:MM tt", new Date());

 

 

 

One last question is there a way to add a user stamp to a pdf so that when the document is printed out the user's name is printed i.e. 'printed by J Smyth'.

 

Many thanks,

John

Date Field in Adobe Acrobat X

$
0
0

I have a form that users fill in. One of the fields on this form is a date. Through the properties I have set the date format of dd/mm/yyyy. What I was hoping to be able to do next is, get it to auto populate. So when the field onFocus it executes something similar to the now() you can use in MS Access etc.

 

Is there a way of getting it to add the system date automatically if so, how?

 

Many thanks in anticipation of a speedy helpful response

 

Kindest Regards

 

Toni

Is there not a method to add a barcode field via Javascript?

$
0
0

I believe I've done a reasonably diligent search and I cannot find information as to how a barcode field can be added to a PDF via javascript.

 

My Excel-based application generates a series of PDF documents (following some user input) and I'd like to add a barcode field to some of them. I can't add the barcode field manually because the PDFs don't exist until initiated by the user.

 

I've considered adding the fields to my MS Word templates, but it appears there is not built-in support for that either.

 

So back to my question...is there not a way to add a barcode field to a PDF programmatically?

 

Thanks.

Dependent dropdown lists in Acrobat

$
0
0

Hi,

 

I am a first time poster and was looking for help with some scripting in a PDF form I have created.

 

I am basically looking to have a second dropdown list dependant on the value of the first but I'm not having any success.

 

I have tried the following as a calculation and as a MouseUp Javascript action but to no avail.

 

Basically, I'm looking for the following: If a user selects a School/Unit called Registry in dropdown 1, it will populate with 4 or 5 locations in dropdown 2. I need to do this for about 20 units. I think I'll be ok once I get one unit working but I can't get to that stage

 


// clear the dropdown displayed value and items
this.Value = null;
this.clearItems();


// repopulate the items based on the checkboxes
if(this.getField("School/Unit").Value == "Registry")
{
     this.addItem("Location 1");     this.addItem("Location 2");     this.addItem("Location 3");     this.addItem("Location 4");     this.addItem("Location 5");

}

Can anybody help me please?

 

Many thanks

Scott

Split/Extract pages by bookmarks

$
0
0

I have created a script which will successfully split the pdf at the first bookmark.

 

I need for the script to split all bookmarks from the pdf. 

 

I have modifed the script but the console reports the following error:

TypeError: bookmarkRoot.children[i] is undefined

 

Can someone please provide assistance to modify the script to split all bookmarks from the pdf?

 

Script to split the pdf at the first bookmark - this works!

 

if (this.bookmarkRoot.children!=null)
{
var bm = bookmarkRoot.children[0].execute();
var bmname = bookmarkRoot.children[0].name;
this.extractPages({nStart:bm, cPath: "/C/Temp/"+bmname+".pdf"});
}

 

Script to split all bookmarks in the pdf - this does not work!

 

if (this.bookmarkRoot.children!=null)
{
for (var i=0; i < this.bookmarkRoot.children.length; i++)

var bm = bookmarkRoot.children[i].execute();
var bmname = bookmarkRoot.children[i].name;
this.extractPages({nStart:bm, cPath: "/C/Temp/"+bmname+".pdf"});

}

 

Thank you!

Acrobat X Pro - Page Scaling Document Property

$
0
0

I have an archive of 1000's of PDF files and I want to change the Page Scaling property in each of them from "Default" to "None."  I would like to automate this process, but there doesn't seem to be any way to do this with the tools provided.

 

Without automation this is done by choosing File > Properties > Advanced tab > Page Scaling drop-down.  When the file is saved this set the default print-time page-scaling option to None.  My operators are having a hard time remembering to set that option when these files are printed and since this can actually be saved with each PDF file I would like to fine a way to automate setting this option for all of my PDF files.

 

I am not a javascript programer, but I'm pretty clever.  Does anyone have any input to offer on this option?  Googling has led me nowhere.


Hide/Show layers with Javascript

$
0
0

Hello,

 

I am trying to find a Javascript method for hiding/showing layers in a pdf document. I would like to be able to use an if/else statement to set the visibility of multiple layers.

 

Let's say I have 5 layers on a single page, all set to hidden by default. This page also has a field with 5 options relating to each of the 5 layers. Once an option is selected, an if/else will use this method to set the appropriate layer to visible.

 

Thank you!

Javascipt for Tri State Button Please Help

$
0
0

I'm editing my first adobe acrobat form and i'm shocked they don't have a tri state check box. The only feature the checkbox currently allows you to do is check and uncheck. Is there a script that will allow me to have three states? I want to be able to do three things, in this order when i interact(click) the box.*First Click* It checks it with a check mark. *Second click* it checks it with a cross this time-X-. *Third click* it returns to  blank state.

 

If anybody can help me with this i would greatly appreciate it. It's the last thing they've assigned me to do an intern and i really want to do a good job with this.

Printing a PDF via Acrobat Javascript

$
0
0

Hi -

 

I have a need to print a PDF programmatically, via Javascript.  The PDF is embedded in a Web page.  I use postMessage to communicate with the PDF.

 

I've created a simple HTML page with an embedded PDF, and a Javascript link to call my "Print" function. Here's a code snippet:

 

<body>

         <a href="javascript:doPrint();">Print</a>

         <object id="PDFObj" data="testPDF.pdf" type="application/pdf" width="400" height="400" />     
</body>

 

In the HTML document's HEAD, I've added the following Javascript which posts the message to the PDF:

 

<script language="JavaScript">
        function doPrint() {
            pdfObject = document.getElementById("PDFObj");
            alert("Hello from Javascript...");
            pdfObject.postMessage(["Print", "Print"]);
       }
</script>

 

Finally, I've added an Acrobat Javascript function in the PDF document to listen for the postMessage event:

 

function myOnMessage(aMessage)
{

    app.alert("Hello from the PDF");

       // print routines here

   
}

var msgHandlerObject = new Object();
msgHandlerObject.onMessage = myOnMessage;
msgHandlerObject.onError = myOnError;
msgHandlerObject.onDisclose = myOnDisclose;

function myOnDisclose(cURL,cDocumentURL)
{
return true;
}

function myOnError(error, aMessage)
{
app.alert(error);
}

this.hostContainer.messageHandler = msgHandlerObject;

 

Here's my problem: when I test this code and click the HREF Javascript link, I see "Hello from Javascript..." and "Hello from the PDF," so I know the postMessage event is working.  However, I've tried every print command I know in the myOnMessage function, and nothing seems to work:

 

app.execMenuItem("Print"); // doesn't seem to work

this.print(); // doesn't seem to work, even when I pass in all the params, etc

 

I've also tried getting print params and passing those in, nothing seems to work.  Am I missing something?  Environement is Acrobat 9 Pro, browser's tested include Chrome 2.0, IE6.  I've attached two files, the HTML bit and the PDF I'm trying to print.  Any help is greatly appreciated!

Custom JavaScript Help

$
0
0

I have 5 combo boxes with choices of Y, N and NA. When yes is selected the score will equal 3, when no is selected the score will equal 0, when NA is selected the score will show no score. I have a text box that will then show the final score from the 5 combo boxes, out of a possible 15. I have one last text field that will show a pass or fail. A pass would be 15 anything less than a 15 is a fail. I have custom JavaScript stating the following:

 

var aFields = new Array("6 Combo Box 1", "6 Combo Box 2", "6 Combo Box 3", "6 Combo Box 4", "6 Combo Box 5");

var aDefault = new Array();

for (var i = 0; i < aFields.length; i++){

     if (this.getField(aFields[i]).value == this.getField(aFields[i]).defaultValue){  //compares field value to default value which is empty

          aDefault.push(aFields[i]);  //this will create an array of fields not filled in

     }

}

 

var v = +this.getField("Model Call Score").value;

if (v>14) event.value = "Pass";

else event.value = "Fail";

 

 

//verify if aDefault contains at least one field

if (aDefault.length >0){

     event.target.display = display.hidden; 

//hide my value if a field is still empty

 

}

else{

     event.target.display = display.visible;

}

 

I understand that the last part of the code said to make the value hidden. I want a pass or a fail to show up only when all combo boxes are selected. I do not have knowledge of JavaScript. Could someone please help me correct my current code or come up with another suggestion. Attached is a link to my form. My above question is referring to the bottom section.

JavaScript and VBA: The Saga Continues - A JSObject Question.

$
0
0

The JavaScript code below, in concjunction with some VBA code, applies a PDF417 barcode image to the upper right hand corner of a PDF. Based on some clever suggestions by George Johnson and Gilad D I'm first adding a button field to the document, and then adding an icon to that button; the icon being a flattened PDF that contains the barcode image. The creation of the barcode image PDF is a whole other story, which I can post if anyone cares.

 

The JS code works well when I run it with a PDF open and I choose “Apply Barcode” from the newly created menu item. Incidentally, it also works when I run it from the console. Also, based on what I've read (thanks Karl Kremer), one can't call the "InsertPDF417Barcode" function directly from VBA, hence the creation of a new menu item and the reference to the intermediate function "myAdd417Barcode".

 

So, what I am working to do is to execute this script from a VBA sub, which is also listed below. But, when the “jso.myAdd417Barcode” line (in the VBA code) executes (or doesn't) I get an error – “doc is undefined”, which is clearly an Acrobat error being thrown.

 

Isn’t “doc” being “defined” by having “this” in my “app.addMenuItem” line? Suggestions?

 

Any help will be greatly appreciated.

 

Thanks.

 

My JS Code (in a folder-level script):

var InsertPDF417Barcode = app.trustedFunction( function(doc)

                {

                                app.beginPriv();

                                                var bcIconFileName = "/C/Temp/bcTmpImage.pdf";

                                                var t = doc.addField("bcFormID", "button", 0, [396, 756, 576, 720]);

                                                                t.display = display.visible;

                                                                t.buttonPosition = position.iconOnly;

                                                                t.buttonScaleHow = scaleHow.proportional;

                                                                t.buttonScaleWhen = scaleWhen.always;

                                                                t.buttonFitBounds = true;

                                                                t.setButtonIcon

                                                var x = doc.importIcon("myIcon", bcIconFileName, 0);

                                                var f = doc.getField("bcFormID");

                                                var i = doc.getIcon("myIcon")

                                                var y = f.buttonSetIcon(i);

                                app.endPriv();

                });

 

function myAdd417Barcode(doc)

                {

                                InsertPDF417Barcode(doc);

                }

 

var menuParent = (app.viewerVersion<10)? "DocumentProcessing":"Edit";

                app.addSubMenu({

                                cName:"myTools",

                                cUser:"My Custom Tools",

                                cParent:menuParent,

                                nPos:((app.viewerVersion<10)? 0:7)

                                });

                app.addMenuItem({

                                cName:"myPDF417Barcode",

                                cUser:"Apply Barcode",

                                cParent:"myTools",

                                cExec:"myAdd417Barcode(this);",

                                nPos:1

                                });

 

My VBA Code:

Sub BarcodeDoc_PDF417(pdfFileName As String)

    Dim AVDoc As Acrobat.CAcroAVDoc

    Dim PDDoc As Acrobat.CAcroPDDoc

    Dim myApp As Acrobat.CAcroApp

    Dim jso As Object

    Dim bcTmpFile As String

        bcTmpFile = "C:\Temp\bcTmpFile.pdf"

        Set myApp = CreateObject("AcroExch.App")

        Set AVDoc = CreateObject("AcroExch.AVDoc")

            If AVDoc.Open(pdfFileName, "") Then

                Set PDDoc = AVDoc.GetPDDoc

                Set jso = PDDoc.GetJSObject

                     jso.myAdd417Barcode

                     PDFSave PDDoc, bcTmpFile

                     myApp.CloseAllDocs

                     myApp.Exit

                Set AVDoc = Nothing

                Set jso = Nothing

                Set PDDoc = Nothing

                Set myApp = Nothing

            Else

                MsgBox "Document not found:" & vbCrLf & pdfFileName

            End If

End Sub

Viewing all 12130 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>