QTP not able to fetch Text property when the Text is too large - automation

I'm facing an issue in which QTP is not fetching text property of a WinObject when the Text is too large. In other cases it's properly fetching the Text property.
Note: It's not fetching Text property in Object Spy as well as at run time using method GetROProperty.
See the below screen print in which it's working fine because the Text is not too large.
But in Response Tab the text is too large & so it's not able to fetch the Text property. See the below screen print.

QTP had this limitation in version 9.0 on text length to be about 16,383 characters.
I am not sure whether this limitation exists in current versions as well.

I had come across this recently, to read all text from WinObject use the following piece of code (this worked for me),
bLargetext=Parent().Child().WinObject("objectname").Object.Document.text

Related

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

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.

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.

PDFtk and number formatted PDF form field

I'm using pdftk to fill in the form with the generated fdf.
In the PDF form, the form field is configured as a number field with 2 decimal point, and the negative value will be showing with parentheses, for example, -4444 will become (4444.00)
Using any PDF viewers and changing the value on form did make the form display the value correctly with the behaviour explained above (negative value will become value with parentheses)
Tested also with the FDF (by importing to the form), the negative value will be displayed correctly as well.
But when using the pdftk fill-form action, the negative value remains as it is without changing the display, which is still showing -4444 and not (4444.00)
Is anyone experienced this before / has a solution for this?
Update #1
I've also tested Apache PDFBox, it has the same issue :(
And now I'm trying to achieve this by using the PDF's javascript, any clue that this way will works?
Update #2
came across this thread How to refresh Formatting on Non-Calculated field and refresh Calculated fields in Fillable PDF form and so gave it a try with iText as well. However still unable to make it works
Finally, i've found some ways to get the formatting works in the PDF form fields.
Approach #1
Requirements
pdftk
PDF form with javascript
In the PDF, create a "Document Javascript" (see how) and re-assign the form's value to make it dirty as mentioned by Denis in the thread of Update #2. The script could be as simple as below:
var text1 = this.getField('text1');
text1.value = text1.value;
Downside
Javascript will only be triggered when you open the PDF, and if you would like to set the PDF with some ownerPassword to prevent user edit the file, the javascript will just failed because of read-only form fields. Otherwise, imagine you have 100 form fields in the PDF, re-assign each of them is a nightmare.
Approach #2
iText
PDF form
I personally will prefer this approach. The powerful iText already has the API to set the form field and at the same time formatting the field display (see how). The generated PDF is ready to print as well with the correct format.
Downside
Either using the iText API to find out the existing format of the form field, or you will hard code the format in your codes. Require more efforts than using the pdftk.
I'm using a simpler version of ChinKang's #1.
In Tools -> Document Javascripts:
this.calculateNow();
One thing to check is in Tools -> Set field calculation order that any calculations are ordered appropriately.
I then use https://github.com/ccnmtl/fdfgen and pdftk to fill the forms in.
The only gotcha is that you cannot flatten the PDF

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.

characters missing when printing

We have a WPF application which can perform either a report preview or a report print.
Both requests use the same code.
Call the report service which gets the report from Microsoft Report Services.
Convert the report into the desired format (in this case PDF).
Then return the report as a byte array.
The result is then written to a temporary file as a binary stream, and either popped into a window to preview or start a Process to print.
In both cases the temporary file is passed.
Print Preview works flawlessly! But Print Report will print with all occurances of 'ti' disappearing. I see there is a printer escape sequence of ESC t NUL/SOH and I assume that if, for some reason, an escape character gets into that stream that ti will result in an ignored print sequence. Thus the missing characters.
My first question is if anyone has ever experienced this with generated PDF reports?
My second question (obviously) is if anyone knows of a utility I can use to view the binary data in the file being printed, to see what is in the file just before every 'ti' sequence?
After a great deal of searching I came across a post on the Adobe forum that states that version 8 had a bug where it was not printing character combinations. Once I dug deeper it seems that it has returned and the suggested workaround fixed our issue.
Workaround: Do a print as image.
Adobe seems to be unable to do the most basic of what their software must do, print the exact content!
Answer for your second question:
First, do one of the following two things:
Set the Windows print spooler properties to not delete printed jobs.
Pause the target print queue.
Then, grab the spool file from the Windows printspool directory (which location that is you can find out by looking at the (right-click) 'Properties...' dialog of the 'Printers and Faxes' folder).
I realize this is an old post but I wanted to add some updated info from the above comment stating that it's a problem with Acrobat 8. We are using Acrobat 10.1.6 and still have the same problem. From what I've read, it's a problem with the adobe product itself. The only real fix I've seen (actually work around) is to print as an image. LAME
Surprisingly this bug is still there in 2021. Adobe cannot be relied upon printing documents properly. This takes away all the allure of features it had if it cannot do the most basic stuff it is required for.
Printing as image reduces the quality and blur the document.
Simply open the document with Safari or Chrome and print from there. E
I had a similar problem while printing directly from the firefox (acrobat reader within). I downloaded the file and then printed. The problem was solved.