BarlaeDC
Community Expert
BarlaeDC
Community Expert
Activity
Jul 16, 2018
08:22 AM
HI, The code works for me without changes, although I believe you need to keep the counter -= 1, as this would be required if the user changes their mind, and therefore goes below the limited number of checkboxes. Can I check a simple thing, how many checkboxes do you have? is it 101? Regards Malcolm
... View more
Jul 16, 2018
07:58 AM
Hi, As you appear to be using the field multiple times, your code might be easier to use if it looks like this, // as we use the value multiple times, just get it once. var totalFieldValue = this.getField("Type of Contract").value; var fieldValueToUse = this.getField ("Total Contract Value").value; if(totalFieldValue =='Construction (10% Goal)') { event.value=fieldValueToUse*0.10; } else if( totalFieldValue=='Non-Construction (3% Goal)') { event.value=fieldValueToUse*0.03; } else { event.value=0; } Hope this helps Malcolm
... View more
Jul 16, 2018
07:52 AM
1 Upvote
HI, Just to add to the points above, this line doesn't look correct - var style = app.documents.paragraphStyles.item("PM_aP1"); Where is the i used to get the reference to the document specified? and as you already have it declared why not use "curDoc" ? like var style = curDoc.paragraphStyles.item("PM_aP1"); Just wanted to point it out, in case it was something simple, Regards Malcolm
... View more
Jul 13, 2018
12:06 PM
2 Upvotes
HI, I am assuming you are using a date picker but it is no real problem if you are not, if you use the code below then the Date object will cope with all the leap years and such. // this is where I get the date from ( a standard date picker) var myDate = this.getField("Date3_af_date").valueAsString; // I make the string an actual date var myDateValue = new Date ( myDate); // get the years and add 10 myDateYears = myDateValue.getFullYear() + 10; // get the months myDateMonths = myDateValue.getMonth(); // get the days myDateDays = myDateValue.getDate(); // using the values above, create a new date, this should automatically deal with leap years and such var myDate = new Date ( myDateYears, myDateMonths, myDateDays); // put the returned value into a text field to see. this.getField("Text4").value = myDate.toString(); Hope this helps Malcolm
... View more
Jul 13, 2018
11:23 AM
2 Upvotes
Hi, To use the selected Page items, means you could select multiple items and if they have tables they should be changed. although if there is an easy rule to stop a table from being processed that might be easier to build into the script, for example: if table contains an image, do not change. but here is the code, works for the simple 2 table sample document I used for testing. var myDoc = app.activeDocument; var mySelectedPageItems = myDoc.selectedPageItems; // replaced to allow for the selected page item //var myRows = app.activeDocument.textFrames.everyItem().tables.everyItem().rows.everyItem().getElements(); for ( var k = 0; k < mySelectedPageItems.length; k++) { var curPageItem = mySelectedPageItems ; var myRows = curPageItem.tables.everyItem().rows.everyItem().getElements(); for ( var i = 0; i < myRows.length; i++) { var myCells = myRows.cells; for ( var j = 0; j < myCells.length; j++) { if ( j === 0) { myCells .height = myCells .height -1 ; } else { myCells .height = myCells[0].height; } } } } app.activeDocument.textFrames.everyItem().tables.everyItem().recompose; Hope this helps Malcolm
... View more
Jul 13, 2018
01:31 AM
Hi, I can't believe I never spotted that problem before here is updated code for that problem. var myDoc = app.activeDocument; var myRows = app.activeDocument.textFrames.everyItem().tables.everyItem().rows.everyItem().getElements(); for ( var i = 0; i < myRows.length; i++) { var myCells = myRows.cells; for ( var j = 0; j < myCells.length; j++) { if ( j === 0) { myCells .height = myCells .height -1 ; } else { myCells .height = myCells[0].height; } } } app.activeDocument.textFrames.everyItem().tables.everyItem().recompose; It is possible to run it on a selected table, I will try and get a chance to create a sample for that today if possible. Regards Malcolm
... View more
Jul 12, 2018
12:02 PM
Hi, This is the code I use to resize cells in a table, there may be better ways but I find this works pretty consistently. var myCells = app.activeDocument.textFrames.everyItem().tables.everyItem().cells.everyItem().getElements(); for ( var i = 0; i < myCells.length; i++) { myCells.height = myCells.height -1 ; } app.activeDocument.textFrames.everyItem().tables.everyItem().recompose; Please note that once you get to a certain cell height, the cell wont get any smaller. Hope this helps. Malcolm
... View more
Jul 12, 2018
10:05 AM
1 Upvote
HI, I have refactored the code a little to solve the problem, based on the sample document, comments are in the code so you can see what I have done, as always any question just ask away. var curDoc = app.activeDocs[0]; var pageArray=[]; var repeat = 0; var dataCode = ""; var startPage = pageArray[0]; var startPageNumber = 0; var lastPageNumber = curDoc.numPages; lastPageNumber--; // This part gets all the page numbers from the document as before for (var p = 0; p < curDoc.numPages; p++) { for(var n = 0; n< curDoc.getPageNumWords(p); n++) { if(curDoc.getPageNthWord(p,n)=="PPNO") { dataCode=curDoc.getPageNthWord(p,n+1) ; pageArray.push(dataCode); break; } } } // This bit has been refactored to stop the need to go through all the pages again // it also uses the ability of insertPages to insert more than one page at a time. for ( var i = 1; i < pageArray.length; i++) { var endPageNumber = i - 1; // if we have a match, AND we are not the last page, keep going if (( startPage === pageArray) && ( i !== lastPageNumber)) { exportFile = false } // if we are the last page, we don't care about a match anymore. else if ( i === lastPageNumber) { // catch if we are at the end of the document exportFile = true; endPageNumber = i; } // we are not the last page, and we are not a match for the pages we are looking for else { // catch when we have passed the current page exportFile = true; } // once we have some files to process. if ( exportFile) { d = app.newDoc(); // call insert pages once with the page range to insert. d.insertPages ( { nPage: d.numPages -1, cPath: curDoc.path, nStart: startPageNumber, nEnd : endPageNumber, }); // remove initial page d.deletePages(0); // set up for the next run startPage = pageArray; startPageNumber = i; } } Hope this helps Malcolm
... View more
Jul 12, 2018
06:15 AM
1 Upvote
Hi, I know this is not a scripting solution but in CC 2018 (I haven't checked other versions) if you use quick apply - it defaults to the align options when you have 2 or more objects selected, that is just Cmd(Ctrl) + Return and then type or click to get the one you want, I don't' see a script making it much faster than that, but it maybe someone on here has a faster solution. Regards Malcolm
... View more
Jul 12, 2018
06:05 AM
HI, When you say you have cells of differing heights, is that per row, i.e. one row of cells is 5mm and another is 4 mm? Regards Malcolm
... View more
Jul 12, 2018
05:55 AM
Hi, You could even just use the menu item "Combine Files into single PDF", then just select all the files you want to combine, and one PDF would be created. Or you could script Acrobat to do the work, you could probably add that to a folder action, copy all 15 PDFs to one location, and an automated script could combine them and create a single PDF. If as mentioned above you have the 15 indd files, you could just create a book for those files and then export the book, could even be done through a script, but it would be a lot of work to place 15 PDF files into an indd document and then export it. Regards Malcolm
... View more
Jul 12, 2018
05:49 AM
Moving to Premiere Pro SDK forum. Malcolm
... View more
Jul 11, 2018
07:20 AM
Hi, Creating a plug-in for Adobe Reader is not just a case of writing the plug-in, it described here - Acrobat DC SDK Documentation. It is a two stage process, there is the actual development of the plug-in and the contractual tasks which need to be done, before your plug-in can be used in the Adobe Reader. (and Adobe can say no ) I am not sure this is easier than using the AEM forms product to enable the functionality in your PDF, that is something that only you could really decide. here is more information about it - AEM forms * Configuring Acrobat Reader DC extensions Regards Malcolm
... View more
Jul 10, 2018
02:07 PM
HI, You can just call d.saveAs ( "/path/to/save/location/" + dataCode + ".pdf"); just after the d.deletePages(); line Hope the helps Malcolm
... View more
Jul 10, 2018
03:54 AM
Hi, I meant the original form, not filled in with any data, just blank, is that possible? if not there is not a lot we can do to help, there are many ways to break a password, brute force, lucky guess, and so on. Without the form and the code that you are running to make the password field and checkboxes show, it is not really possible for us to diagnose the problem. Regards Malcolm
... View more
Jul 10, 2018
02:05 AM
Hi, Can you share the document using a file sharing service? That way we can investigate the form and see how the fields became visible. Regards Malcolm
... View more
Jul 10, 2018
01:55 AM
1 Upvote
Hi, Well we don't know if it is issue with the documentation or with Acrobat JavaScript, it could be supposed to work and not. There doesn't appear to be a way to log a bug against the Acrobat SDK, the form for feature request/bugs only has the main products listed. Feature Request/Bug Report Form Regards Malcolm
... View more
Jul 09, 2018
05:50 AM
Hi Good to know, I knew they had added the Save As functionality but I didn't think that had made it through to the JavaScript, nice. Regards Malcolm
... View more
Jul 09, 2018
04:50 AM
HI, In both cases you are calling what is a "Save" function, these are only available in the Reader if you have extended the document before opening in Reader. This can be seen as a simple example in Acrobat DC, you can select from the user menu "File -> Save As Other -> Reader Extended PDF -> Enable More Tools (includes Form fill-in and Save ....)" Although depending on your use case you may need to investigate the AEM server product for how to enable the forms. Hope this helps Malcolm
... View more
Jul 09, 2018
02:55 AM
2 Upvotes
HI, There is but it would be a lot of work, as you would have to try and work out when a value is to be calculated, and then if the total field is edited, stop the calculation, but what if something in one of the calculated fields is changed, do we then run the calculation again, and then the user would have to enter the discount again, and then we have to stop the calculation again, and so on and so on. It would be tricky to get this right, a much easier option is the one mentioned by try67 which is to have a field that would be included in the sum to introduce the discount, although there is no need to call it "discount' you woundn't even have to name it you could just have a blank empty field, which is a discount when it has a value of nothing when it doesn't. Regards Malcolm
... View more
Jul 09, 2018
02:46 AM
2 Upvotes
HI, Although the property is marked as read/write in the documentation, changing it appears to have no effect on the 3D annot itself, where as changing it for a rect annotation, has the required effect. This looks like either a bug in the documentation, the property should be read only, or a bug in Acrobat, the rect should be changable but isn't. I can't think of any other way of changing the location using scripting. We could probably create a plugin using the Acrobat SDK that would be able to move the annotation, not sure if that would be an option, but wanted to include for your information Regards Malcolm
... View more
Jul 09, 2018
02:16 AM
HI, It looks like Uppercase and Lowercase if statements are working as expected, as you have added a space, the strings do not match, and therefore it would always be the else that is fired. The regex is checking that the string contains the characters and therefore it is matching, as it should. If you want to include the space you need to include that in the IF statements as well. something like var testString= "СоФиЯ "; // small and capital letters + one space if ( testString.toUpperCase() == "СОФИЯ ") { alert("UpperCase works") } else { alert("UpperCase doesn't work") } if ( testString.toLowerCase() == "софия ") { alert("LowerCase works") } else { alert("LowerCase doesn't work") } if ( testString.match(/софия/i) != null ) { alert("Regex works") } else { alert("Regex doesn't work") } Or you could use a function or similar to remove any whitespace from your string before you start something like this would work. function trim (aString) { return aString.replace(/(^\s*)|(\s*$)/g,""); } this removes whitespace from the string, allowing you to compare just the characters. Hope this helps Malcolm
... View more
Jul 09, 2018
02:11 AM
1 Upvote
HI, I am not sure what you are trying to achieve, the field can be editable that is not a problem, but if we run a 'custom calculation script', this will run every time a field is exited, included the total field. This would mean that the user would edit the field, and then click or tab to another field, the calculations would run and then whatever they typed in would be overwritten. I am sure this is not what you want to happen. Regards Malcolm
... View more
Jul 07, 2018
04:26 AM
Hi, I believe you should be able to use the Automater (application) to have this done for you automatically. If you create a new workflow in Automater. Select "Folder Action" Then Drag "Run AppleScript" from the second list Then place this Applescript in the area that appears, changing the path name to match your folder location ( this might be computer specific in which case we can revisit, but best to check it works first) tell application "Adobe Acrobat" set myIndex to "" set myResult to "" do script "myIndex = catalog.getIndex('/PATH/TO/INDEX/FILE/HERE.pdx)" do script "myResult = myIndex.build('', false)" end tell That should rebuild the index every time a file is added to the folder, Hope this helps, sorry about the delay took me longer to get to it than I expected. Malcolm
... View more
Jul 07, 2018
03:26 AM
Hi, try67, you are correct I should test the code, I wrote that while traveling, and got a bit too confident. No excuse really. Regards Malcolm
... View more
Jul 07, 2018
03:23 AM
1 Upvote
Hi, Using the following code I am able to get 2 documents created. PPNO: 0158K PPNO: 9090V are both created as separate files. // Using the active document ( i only have one document open, made testing easiser) var curDoc = app.activeDocs[0]; var pageArray=[]; var repeat = 0; var dataCode = ""; for (var p = 0; p < curDoc.numPages; p++) { for(var n = 0; n< curDoc.getPageNumWords(p); n++) { if(curDoc.getPageNthWord(p,n)=="PPNO") { dataCode=curDoc.getPageNthWord(p,n+1) ; pageArray.push(p); break; } } for (var p2=p+1; p2 < curDoc.numPages; p2++) { for (var n2=0; n2<curDoc.getPageNumWords(p2); n2++) { if(curDoc.getPageNthWord(p2, n2)=="PPNO") { // This if is why we only get two files as a result, // because we can only get to the else if we don't match, but for the last // number in the document we will never have a page that doesn't match if(curDoc.getPageNthWord(p2, n2+1)==dataCode) { repeat++; break; } else { if (pageArray.length > 0) { var d = app.newDoc(); for (var x=0; x<pageArray.length; x++) { d.insertPages( { nPage:d.numPages-1, // changed to use the curDoc cPath: curDoc.path, // as we are importing 1 page at a time. nStart: pageArray , }); } d.deletePages(0); } // reset so we get only the new pages. pageArray = []; } } } break; } } There are a couple of changes to the code, the main ones where the changes I mentioned, the other is to make sure we reset the page array so that we don't included the pages we found on the first run through of the loop on the second loop. Hope this helps. Malcolm
... View more
Jul 05, 2018
12:32 PM
HI, Ok, something like this should solve the problem // Custom calculate script (function () { var sStart = getField("fill_9").value; var sEnd = getField("fill_10").value; var dStart, dEnd, diff; if(sStart && sEnd) { dStart = util.scand("dd/mm/yyyy", sStart); dEnd = util.scand("dd/mm/yyyy", sEnd); if ( dEnd < dStart) { app.alert ( " end date must be after start date"); event.value = ""; } else { diff = dEnd.getTime() - dStart.getTime(); event.value = Math.floor(diff / 864e5)+1; } } else { event.value = ""; } app.alert ( " end date must be after start date"); } })(); Just re-ordered your code a little. Regards Malcolm [EDITED: to correct errors mentioned later in forum post ]
... View more
Jul 05, 2018
12:29 PM
HI, I haven't had a chance to properly test your code but looking at it there are a couple of things that don't look right, so I will list them and you can see if you agree and make the changes and then see where we stand. 1. In the document you have the text "NO" and in the code you compare that to "PPNO", guessing that is just a type when you made the forum post, but thought I should mention it. 2. When you go to add the pages you use the following code for (var x=0; x<pageArray.length; x++){ d.insertPages( { nPage:d.numPages-1, cPath: dataCode + ".pdf", nStart: pageArray , nEnd:pageArray , }); } There are a couple of issues, cPath, is set to dataCode.pdf, but cPath should be the device independent path to the file you want to get the pages from, not the file you are placing the pages into, so this should be the full path to the original file. and you are passing nStart and nEnd as the same page, this is not necessary, as if you just want one page, just pass nStart and that will be the only page that is included. Hope this helps Malcolm
... View more
Jul 05, 2018
12:01 PM
Hi, If you check a field value against "" that is what they normally return when they have not been filled in, if I understand your instructions you don't want the code to run until fill_9, and fill_10 have all got a value, so you could add a check at the start of your script. var sStart = this.getField("fill_9").valueAsString; var sEnd = this.getField("fill_10").valueAsString; if ( ( sStart != "") && ( sEnd != "")) { // your code goes here and will only be run when both fill_9 and fill_10 have values } In order to test against today just use the new Date() to gets todays date and then you can test against that exactly as you test the two dates your are currently working with. Hope this helps Malcolm
... View more
Jul 05, 2018
11:55 AM
Hi, The easiest way to manage this would be to use toLowerCase() or toUpperCase(), before your comparison, written out in fulll to make it easy to follow it would look something like : var testString = this.getField("fill_20").valueAsString; if ( testString.toUpperCase() == "SOFIA") { this.getField("fill_30").value = 100; } else { this.getField("fill_30").value = 30; } Hope this helps Malcolm [Edited to correct typo]
... View more