Is it possible to use the After Effects 'Create Shapes from Vector Layer' functionality from within a script (Adobe ExtendScript)? - scripting

I am attempting to create a script for Adobe After Effects. Part of what I am attempting to accomplish will require converting layers imported from Illustrator into After Effects shape layers.
I am having trouble finding any info on how this can be accomplished in ExtendScript. Is it possible?

Any menu commands in After effects are available to extendscript, even if they're not included in the API. To invoke a command as you would with a menu you use
app.executeCommand(1234);
Where 1234 is the number of the command you want. To find this magic number there is a function
app.findMenuCommandId("Full text of command as it appears in the menu");
It's kludgy, and there's no guarantee that adobe will stay consistent with the numbers between releases, but it's all we have. More details and a list of magic numbers here

Related

How to programmatically remove PDF layers?

I know about Doc.SetOCGOrder() and the likes, but apparently the Acrobat API does not provide means to remove layers (aka optional content groups, ocgs), only to hide them from users while leaving them accessible via scripting.
I'm not forced to use Acrobat, in fact I'd prefer a FOSS-solution (or at least freeware) using e.g. pypdf2 or pdftk. edit There is another post using abcpdf, which is unfortunately not free. Is there any way to port that behaviour to Acrobat's JS or pypdf2? Essentially the answer seems to loop through every page's content, which seems to include the layers.
(Concerning merging, I notice pdftk does remove layers when merging multiple files, so one can simple pdftk A=input.pdf B=input.pdf cat A1-end output output.pdf.)
My approach so far: For the relevant layers obtained via GetOCGs() set locked=true and both initState=false and state=false. Then use SetOCGOrder() to remove the layer from the layers view. Unfortunately this is not perfect, since at least in Acrobat DC I can still select "show all layers" in the layers panel, which still shows the layer. One could merge all layers now, but neither did I find an option to achieve that programmatically nor do I believe that would actually remove the hidden layer's elements.
You can't do it programmatically but you can create an Action that will process a folder full of PDF files using Adobe Acrobat. Set the Action to use the PDF Optimizer to discard hidden layers and flatten visible ones. See the graphic.

Photoshop jsx image grid

What I am ultimately trying to do is to create a grid of images for print that are minor variations of the same thing (different text is all). Looking through online resources I was able to create a script that changes the text and exports all of the images necessary (several hundred). What I am trying to do now is to import all of these images into a new photoshop document and lay them all out in a grid and I can't seem to find any examples of this.
Can anyone point me in the right direction to place a file at a specific coordinate (I'm using CS5 and have the design suite so if there is a way in illustrator to do this quickly...)?
Also, I'm open to other ideas on how to do this (even other programs) easily. It's for labels so the positioning on the sheet has to be pretty precise...
The art layer object has a translate() method that takes delta x and y params. You'll need to open each image, copy it to the target document, get its current location (using artLayer.bounds) and do the math to find the deltas to position it where you want it. Your deltas can be in pixels so you'll get plenty of precision.
Check out your 'JavaScript Scripting Reference' pdf in your Adobe install directory for more details.
Ok I'm marking Anna's response as the answer because though I didn't fully test it, it seems like it should work and answers the original question with jsx. However I'm also leaving my final solution in case anyone else runs across this with the same issue and may prefer this method as well.
What I ended up doing instead is using InDesign. I figured out that it has a grid option that lets you import a number of files and place them all in an equal grid in a single command. This is almost exactly what I was looking for, except that it leaves a small border/margin in between the columns and grids and mine were designed to meet exactly.
I couldn't figure out how to make it not have the border (I have very little experience with InDesign, it may be possible). However I was able to select all my images and scale them uniformly to be the correct size, then I just selected each column and dragged it over to snap to the adjacent column and the same with rows...

GUI automation with clicking on text

There are many GUI automation tools that allow clicking on a specified image (well-known Sikuli, for example). Is there any way to click on the specified text, not image? This way the tool will:
make screenshot
recognize text on it
find text position (somehow)
send click event to this position
It would be much easier to write tests using this approach (many interfaces have text button, inputs etc.) rather than make screenshots for every single element.
I've seen some OCR feature in Sikuli but it didn't work for me (I tried invoking click('some-text-here').
Sikuli built-in OCR features are pretty buggy and unstable. All (or at least most of) the related issues are listed in this BUG. However there are few possible workarounds which are, however, not also always applicable..
If the text is known, you can take a screenshot of the text and then look for it as a screenshot. For example if you know exact font of this text, you can automatically generate such text on the screen and use it as a pattern to locate it elsewhere.
The built-in tesseract based OCR, performs significantly better when the font is bigger, "fatter" and in Grayscale (usually). Hence you might do some background image processing before attempting the actual recognition. I used ImageMagick to resize and filter the images for better recognition. It can be in the background as a command line tool. For example:
convert -filter spline -resize 100x -unsharp 10x20 -type Grayscale
I am aware that this does not answer your question directly but these are steps you might consider taking towards the final solution.
I'm a developer at Deskover company and we are currently developing an application, UiPath Studio that meets your needs.
We provide text recognition on various technologies with 100% accuracy, ability to find specific text in an area on screen, a control or an entire window, and also ability to click text or controls.
You can execute different actions, sequentially by creating workflows.
We at Deskover are big fans of Sikuli project. We actually use the same image recognition engine in UiPath Studio.
UiPath Studio is a visual tool that helps you create workflows easily, but you can also use the underlying API and implement an application that extracts text and clicks on it.
You can find more details about the UiPath library here.

How to create switchable multi-language pdf form?

I want to create a pdf form for two language (Chinese/English) UI, and there's a button(s) or somethings on the form for language switch, is there anyway can make it? and how to do?
thanks!
Thanks for all reply!
Actually I got a sample like this,
PDF Sample
there're two checkbox on the top-left of the form, one is for English UI, the other is Chinese, I just want to know how to make PDF like that sample? (and I don't see any layers on the sample...)
thx
mkl's comment (which he should turn into a full answer, really) already hinted at the option to use different page templates residing in the same file.
Another option you could explore is this:
put the two language versions into 2 different layers (or 'optional content groups' in PDF parlance)
make the visibility of the two layers toggeable
let the user activate that layer which he/she needs.
Layer activation can be handled through normal Acrobat Reader user interface elements.
The layer switching can be made accessible via a "button" on the PDF page too -- but that requires additional JavaScript to be embedded in the PDF (something many people are not particularly keen about).
As Kurt proposed, I make my comment on Frank's answer an answer in its own right:
Actually there is a pdf feature seldomly used nowerdays, page
templates. Thus, those two forms can reside in the same file in
different page templates, and based on some initially present buttons
("English version", ...) the desired form is spawned.
Unfortunately I don't know how to create page templates using some easy-to-use tool, I only came a cross them in the context of integrated PDF signatures (depending on the signature type, page template instantiation is a document change not breaking the signature) and tested them with low-level tools.
Essentially page templates are PDF objects just like page dictionaries of the normal pages, they are not XFA stuff. They merely are not referenced in the pages tree but instead in the name tree.
There is a JavaScript command which creates a visible page based on such a template --- I don't know which anymore; I may be able to find out when I'm back in office next week. This command would have to be bound to the inital language selection button in the file.
The problem will be in switching the static text - PDF does not allow this.
If I were you, I would split the document into two identical forms in the respective languages. You can use bookmarks and links on the first page to navigate to the right part of the document.
Note that it is possible to assign the same field names to the Enlgish/Chinese versions of your fields. This will make it easier to process the submitted form data because the process path would be independent of the chosen language. It will also simplify any JavaScript (validation, summing, etc.) you plan to add.

PDF Outline Text - Automation of Acrobat Sequences

I have built an application that automates the filling out of form fields inside a pdf. It then takes various assets and combines them together to generate a "print ready" product. All of this is accomplished using the magic of iTextSharp. When form fields are populated, they are then flattened to text. The problem is that even with the fonts embedded they aren't really attached to the form fields in a meaningful way (like straight text elements are) and the printers are complaining that the pdf is generating licensing errors due to this. I researched this a bit and it just seems to be the nature of how form fields are.
The artists we are working with requested that we research a way to "outline" the text that is created from flattening the form fields. I found that running the PDF Optimizer with a custom preset allows for Text Outlining in Acrobat, and even better I can generate an Acrobat Sequence that runs this command on the pdf. The problem is that Sequences can not be automated, at all.
I found a plug-in called AutoBatch that allows for the execution of Sequences on the command line through a batch file. The downside is that this would require installing Acrobat Pro and the Plug-in on the server this application will be running on. Further it seems like an overkill solution just to outline the text in the pdf. For all I know at this point iTextSharp may allow me to do this programmatic, but searching for such a thing on google returns little results and nothing relevant.
So the question: Is there a better way to outline text in a pdf than the current solution I have implemented or am I kind of stuck?
TLDR; PDF is generated w/ non-standard fonts. I need to "outline" this text to send it to the printer. Currently using AutoBatch Acrobat Plug-In to execute Acrobat Sequence from the Command Line. Seems excessive, wondering if anyone knows a better way to automate font outlining.
I am also in a printing environment and have used forms for "Box Covers" plenty of times to shorten the code used to produce box covers.
I simple us "pdfStamper.FormFlattening = true;" and the printers (Xerox DP180 and DC5000) has no problems in using the PDF.
The moment I leave out FormFlattening the printer gives a lot of errors regarding the PDF.
If you are using FormFlattening then check if the printer has the font locally installed in order for it to reference the font from the print engine instead of the PDF resources.