I'm trying to print from a html/javascript AIR app.
The code I'm using is:
var pjob = new window.runtime.flash.printing.PrintJob;
if (pjob.start()) {
var poptions = new window.runtime.flash.printing.PrintJobOptions;
poptions.printAsBitmap = true;
pjob.addPage(window.htmlLoader, null, poptions);
pjob.send();
}
I copied it from this blog here which claims to have a working app: http://anirudhs.chaosnet.org/blog/2008.02.15.html
In both my own code and the example code on the blog, when I run the functions to print it pops up the Page Setup box and when I click OK in this, adl outputs the following error to the console:
2009-04-28 22:00:33.950 adl[19891:10b] ERROR
It still goes on to launch the final print dialog though, but when I click Print it only prints out the top left quarter of the application's window. Both apps I've tried do the same thing, produce the error and then crop the output.
I'm using the CLI development tools on a mac. I know the mac doesn't support vector printing but I'm choosing the Bitmap option. What does this error mean and why is it cropping the print job to the first few hundred pixels x and y ?
I'm not an expert, and am struggling with the print job for some other reason, but try giving the print rectangle (the second parameter to addPage)
Related
My project is to catch certain error message that can possibly show on website using robot framework and selenium. such as 400 - 500 error messages.
ex: 404. page not found
But we cannot catch empty page like white screen or black screen.
Is there a way for robot/selenium to tell if the page is just all white or all black ? whith no text visible or any element visible.
Thanks
Just get the source and check any unique text or tag and use it in the place of "application-footer". In my case i used application-footer which is available in my source. So Use this below code to find blank page, this is the workaround I used
${Source}= Get Source
Log ${Source}
${Blank_status} = Run Keyword And Return Status Should Contain ${Source} application-footer
Run Keyword If "${Blank_status}" == "False" FAIL Displayed Empty Page
If you want to Handle Failure in your own way, then instead of FAIL keyword write your own keyword to Handle and call the keyword
Run Keyword If "${Blank_status}" == "False" Error_Handle
*** Keywords ***
Error_Handle
# write your handling code
I have a test setup that opens a program and does a test on loop.
I want to have the program take a snapshot / screenshot of the program (only) after a test, inside the loop.
Is this possible?
Below is my test suite run:
So it is fine, and I can run through the full test, but I can't see the results, unless I have Ranorex open. This is not sufficient, if I run this on another PC or VM.
NOTE: All the blanked out boxes, are my variables.
To take a screenshot of the app under test, 3 simple steps:
Create a repo item of the application (using Ranorex Spy).
Drag n Drop the repo item in a recording.
Select the "Capture Screenshot" action.
Hope this helps (even though you have solved the issue!)
Just for clarification.
Ranorex Support team helped me by giving me some C# code to help save screenshots to a location on my PC.
Add a Code Module to the Action Screen, then add the following code:
public void SaveScreenshot(string savelocation)
{
//Take a screenshot of a specific element
Bitmap image = Imaging.CaptureImageAuto(repo.program.SSTabCtlWndClass);
//Name and path to store the screenshot
String imageName = String.Format(varNumber1 + "_" + varNumber2 + ".jpg");
String pathImageName = Path.Combine(#"C:\temp\Screenshots\", imageName);
//Save the screenhot in your specific folder
image.Save(pathImageName, System.Drawing.Imaging.ImageFormat.Jpeg);
}
My Sencha Touch 2 application has an 'Export' button, which creates an Excel file with the data of the selected offer.
After the user clicks the button, i want the (server side) export process to be started, and, once completed, the user to be prompted to select a filename and location, OR that the file is automatically downloaded. How do i do that? Does anyone have an example?
For Excel specifically I'm not 100% sure, but this might help you get started or if a CSV is acceptable...
I'm sure you could pass the file reference to a var instead of the string but I have yet to try it.
If you paste the js below into the console you can see how this works. Pretty basic. Maybe try the returned value from the server to see if that works then if it does you can build a function around it to happen when needed.
csvHeading = 'HA, HB, HC, HD \n';
csvData = 'r3a, r3b, r3c, r3d \n' +
'r2a, r2b, r2c, r2d';
CSVFile = csvHeading + csvData;
window.location = 'data:text/csv;charset=utf8,' + encodeURIComponent(CSVFile);
I want to copy the content of the current seleced slice in my photoshop cs3 document to a new document using an own written script/plugin.
Currently, I do this manually: I select the slice, press ctrl+c (copy), create a new document and then I press ctrl+v (paste).
What I have so far is the automation plugin example 'MakeNew' that creates a new document:
static SPErr MakeNewDocument (void)
{
SPErr error = kSPNoError;
PIActionDescriptor descriptor = NULL;
error = sPSActionDescriptor->Make (&descriptor);
...
}
Any Idea how I can access the current selected slice and copy the content to the new document?
Thanks for hints.
Looks like there is no way to get the slices even via SDK in CS3.
I'm using Crystal Reports 11's RDC (COM) API to print. My code looks like this:
HRESULT res = m_Report->SelectPrinter(b_driver, b_device, b_port);
if (FAILED(res)) return res;
// For these calls, the #import wrapper throws on error
m_Report->PutPrinterDuplex(dmDuplex);
m_Report->PutPaperSize(dmPaperSize);
m_Report->PutPaperSource((CRPaperSource)pdlg->GetDevMode()->dmDefaultSource);
if (m_Report->GetPaperOrientation() == crDefaultPaperOrientation)
m_Report->PutPaperOrientation(crPortrait);
VARIANT vfalse;
VariantInit(&vfalse);
vfalse.vt=VT_BOOL;
vfalse.boolVal=0;
res = m_Report->PrintOut(vfalse);
However, at the end of all this, crystal reports still shows its own printer selection dialog - but only for some reports, it seems. Why does crystal reports show a print dialog even when I pass false for promptUser? And how, then, can I suppress crystal reports' internal printer selection dialog and force it to use my values?
Edit: Whoops, CR11, not CR9.
Some further information:
The reports that work properly (ie, do not show the print dialog) are generated internally using the RDC API; we create a new report object, import subreports into it, then print the result. No problem there.
The reports that do not work properly (ie, force the print dialog to open) have been created with a previous version of crystal reports; however, opening and saving the report does not seem to help.
Sample reports in the Crystal Reports installation directory show the same problem.
I tried reproducing with VBScript; however, the result was that nothing was printed at all (no dialog, no nothing):
Set app = CreateObject("CrystalRuntime.Application.11")
Set report = app.OpenReport("C:\Program Files\Business Objects\Crystal Reports 11.5\Samples\en\Reports\General Business\Inventory Crosstab.rpt")
report.PrintOut(True)
rem Testing with a True parameter to force a print dialog - but no printout and nothing appears (no error either though)
First, let me preface that I'm not a C/C++ programmer, so I'm not able to test the code--my interaction w/ the SDK has been with the VB and .Net interface over the years.
I found the following code from BO's devlibrary:
// A dummy variant
VariantInit (&dummy);
dummy.vt = VT_EMPTY;
HRESULT hr = S_OK;
// Specify the path to the report you want to print
_bstr_t ReportPath("c:\\Program Files\\Business Objects\\Crystal Reports 11.5\\Samples\\En\\Reports\\General Business\\Inventory.rpt");
_variant_t vtEmpty(DISP_E_PARAMNOTFOUND, VT_ERROR);
// Instantiate the IApplication object
m_Application.CreateInstance("CrystalRuntime.Application.115");
//Open the Report using the OpenReport method
m_Report = m_Application->OpenReport(ReportPath, dummy)
//Print the Report to printer
m_Report->PrintOut(dummy, dummy, dummy, dummy);
Does it work? It should print the report with its 'default' printer settings and without prompting.
You wrote:
However, at the end of all this,
crystal reports still shows its own
printer selection dialog - but only
for some reports, it seems.
Generally speaking, I've found that Crystal tends to ignore commands to suppress dialogs if it thinks something is missing. I've found this to be true with the parameter dialog. Perhaps it apply to this situation as well. I would ask what is different about the reports that cause the dialog to be generated. There is a 'no printer' option that can be set. Perhaps this is the common thread.
Do you have access to the VB6 IDE? If you write the equivalent commands using VB6's interface, does the prompting occur?
You might also investigate using the CRPE32.dll instead of the report-designer control. To be honest, I don't know if the RDC wraps the CRPE DLL or is an entirely-separate code base.
Turns out it was a bug in my code after all - I'd previously put in a wrapper for the RDC API to fix certain other bugs we were having; due to the large number of methods in the IReport interfaces, I wrote a script to generate pass-through stubs for the methods I wasn't interested in. Turns out that script was passing in bogus values for parameters with default values. Oops! Fixing the wrapper code fixed the bug here.