In Sikuli, can we search an image in UI webpage with a word/text that is displayed in the image content? - selenium

I am using Serenity with Selenium to automate a webpage having images (list of large thumbnails). I am checking if there is an option to search in the UI with a text/word that is displayed in the image content.
For example: I want to find if the image exists in the UI having the text.
I want to find if the image exists in screen having this word "Pexels".

Yes, it does not matter for Sikuli whether that's a printed text or a part of an image. What you have to take into account though is the enclosing region you are going to look for this text in as this might affect the result you are getting. Internally Sikuli is using Tesseract OCR which can be sensitive to text placement within a region. So if you see you are getting inconsistent results, first of all make sure what is actually being detected within the selected region and then try to change it to focus on the specific area of the test if possible.

Related

Scale text to fit in a text box in illustrator using scripts(javascript)?

I have been trying to figure out how to get a font to shrink to fit in to its text box, but it needs to scale down the font size. I want to be able to do it to multiple text boxes at once. I dont have any coding right now. I know a little JavaScripting but not 100% sure how to do if for illustrator.
You can use the code snippet in my LinkedIn article: Dealing with Overset Text.
The Illustrator scripting API gives one some control over the paragraphs, lines, words, characters and arbitrary text ranges of an Illustrator text frame. One upgrade my script could use though is to incorporate text-on-a-path - maybe someday soon I'll fix it up and update my article.
As for using the snippet, just run it however you choose to run scripts (put into App scripts folder or use File > Scripts > Other Scripts. When you run it, any overset text boxes which are area text will have their font shrunk to no longer be overset. You can use this same snippet with Illustrator variable data to ensure a batch process will not have oversets.

Determine the Text that can Display in Multiline PDTextField

Is there a way to determine the text that will actually display in a PDTextField when the PDF prints? If I call setValue and then getValue, it returns all of the text even though it will not all display.
I am trying to fill out a form with a limited size multiline text field that has the notation to attach another page for more details. I would like to limit the text to that which will display and generate the added detail page.
Thanks for indulging a PDFbox newbie.
There is no direct way to find that out as the details of the text layout such as line breaks, padding, line spacing are hidden inside the non public class PlainTextFormatter inside the org.apache.pdfbox.pdmodel.interactive.formpackage. So you'd need to replicate that code.
PDFBox tries to resemble the calculations done by Adobe Acrobat and Adobe Reader but the details of such calculations are not part of the PDF specification. So doing your calculation is only valid for a similar layout model. Other form filling applications might have a slightly different layout model and as a result your results will not apply to these.
In addition to that Acrobat (and PDFBox) place text although it might be partially clipped. Look at the results of the AlignmentTest.javaunit test to see what I mean. So one might have a different expectation to what 'fitting' really means.
As I've thought about passing the information about which text fitted back to the calling application anyway I've opened an enhancement request https://issues.apache.org/jira/browse/PDFBOX-3413 for that.

Possible to control PDF layout with iText?

I'm writing some logic to build a large single PDF file that our users can print at their convenience. I'm using Java's iText library (through Clojure's clj-pdf).
I'm trying to have the PDF show the same exact template form on every single page, however I can't seem to find any documentation or indication that one can have PDF content "fit to a page".
The text in these forms varies a little bit, so there's a chance it might require more of fewer text lines per page. This means that the content has a chance of spilling over to the next page, or being too short, making the next page creep up into the previous one, breaking the requirement of "one form per page" for the rest of the document.
I'm trying to figure out if my option is pretty much only to manually check the length of the text on each page and potentially crop it by hand if I goes over n lines, or if the PDF format somehow supports a smart way of having paragraphs+tables+headings all fit in one page. Some UI systems allow you to control how spill-over is handled, anywhere from cropping to resizing the font, so I'm curious if PDF supports anything of that sort.
Edit: ended up going with pagebreaks for simplicity, wasn't aware of that option when I wrote this question.
If you want to take control over the space taken by text, for instance to fit it on a single page, the way to go would be to create a ColumnText object and to add the content in simulation mode. If the text fits the page, add it for real. If it doesn't, use a smaller font size. This is demonstrated in the MovieAds example where snippets of text are fitted into AcroForm fields.

Extract screenshot or picture of portion of PDF using VBA or VB and Adobe SDK

I am currently using an excel macro (although I will switch to VB.NET if necessary) to loop through all of the text in a PDF and populate an array with certain portions of the text in the PDF (via the Adobe SDK and getPageNthWord). This part is working just fine, but now what I want goes a step further.
There are certain portions of the PDF where just grabbing the text isn't giving the full picture, and I'd like to see what more I can get. This is exactly the screenshot or snippet I am trying to get:
So, I know that I could use getPageNthWordQuads to find the coordinates for the words "Compliance Warning" and I could figure out a way to find the bottom right of the screen as well, but my problem starts there. After I get those coordinates what would I do with them? Can I zoom in the PDF to only see that portion and then take a screenshot? I already have the code for a screenshot of the activewindow, but I don't know how to scroll or zoom on a PDF.
Any help would be greatly appreciated. A fresh approach would be welcome as well. Thanks!
There are probably a number of approaches that would work - I don't know enough about your environment / constraints to know for sure which would work best. I'm assuming you are talking to Acrobat through OLE here.
1) You can open a window, get its AVPageView and ask it to zoom and move to where you want it to do your thing.
2) You can open a PDF document in one of your own windows using OpenInWindowEx and then grab the contents of that window (the advantage being that this window could be off screen).
3) You can use the DrawEx method (in AcroExch.PDPage) to render a specific portion of a page into your own window and then process that.

Adjust size of File Upload Button

I want to adjust the size of the "Browse" section seen in the file upload button in HTML. When I try to adjust the size using "size" or "width" attributes, only the whole size is reduced. But I want only the size of the "Browse" button part to be reduced and not the textbox part which displays file path. Can I do this without using CSS? If yes , how?
The file input element is notoriously difficult to style. One of the problems is that it's really a single element, even though it renders as two elements.
One approach is to obscure the entire element behind the scenes and present the user with custom elements instead. Here's an article about it. Basically the file input element is hidden and some custom elements backed by some JavaScript are handling the UI and passing the necessary information to the file input.
It is very difficult to change the appearance of the Browse button as it is typically hardwired into the browser.
However, at Quirksmode.org|Styling an input type="file", there is a long post that discusses complex CSS techniques for changing the appearance of file input elements.