Page 1 of 1

ReportToPDF: Parameter is not Valid

Posted: Wed May 11, 2016 2:14 pm
by tgoldber
Hey,

I try to use the ReportToPDF dll and cs file.
It works perfectly fine for one Testsuite.
But it did not work for any other testcase. I get the error ReportToPDF: Parameter is not Valid
The only different is that I DONT use Global Variables in the first Tastcase. But I cannot imaging that this is the problem.

The error comes in line 94 of the original file
"Ranorex.PDF.Creator.CreatePDF(input, PDFReportFilePath, xml, details);"

and is catched at line 62.

There is no hint what might be wrong with the variable or what variable is the not valid one.
Is there any way of finding out what the actual problem is?
While debugging, I couldn't find anything unusual, in fact except for the file name the the parameters have the same value as in the Testcase where the convertion is working!

I changed the Framework from 3.5 to 4.0

I even tried to just generate the *.rxzlog file end generating the pdf with ReportToPDF.exe.
With the same result.

Could it really be that the global parameters are messing with the report?

Thanks for the help!!

Re: ReportToPDF: Parameter is not Valid

Posted: Fri May 13, 2016 7:15 am
by tgoldber
ANYTHING?? I Really would need help here!!

Re: ReportToPDF: Parameter is not Valid

Posted: Fri May 13, 2016 8:48 am
by Support Team
Hello tgoldber,

May I ask you to send a *.rxzlog to [email protected]? This would help us in analyzing your issue.

Looking forward to hearing from you.

Sincerely,
Robert

Re: ReportToPDF: Parameter is not Valid

Posted: Fri May 13, 2016 2:10 pm
by Support Team
Hello all,

A customized "RanorexReport5.png" caused the issue. It's possible to modify the icons etc. within this png in order to personalize the generated Ranrorex report, but the name of the png file must not be changed.

Sincerely,
Robert

Re: ReportToPDF: Parameter is not Valid

Posted: Fri Jul 08, 2016 3:25 pm
by rezme
The person who posted this seemed to have a similar issue to mine. I’m attempting to get a copy of the report as the last step in the test suite. Using the information I found in http://www.ranorex.com/forum/save-repor ... t5904.html I was able to get a cached copy of the report that is saved to a “.tmp” extension in the execution directory. I’m able to zip it successfully using report.zip, and I’ve tested that it converts properly, by renaming the resulting rxzlog file to a “.zip” file extension and extracting it. Its contents are identical to the RXLog file following extraction. The problem I run into is when I attempt to convert it to PDF. I get a “parameter is not valid” error message, without any real detail. I’ve tried inserting a break point in the code at the point I generate the PDF, but Ranorex skips past that to the end without stopping at the break point.

Here's the code I'm using:

Code: Select all

//build path names for relevant files
        	string ReportDirectory = @"c:\RanorexReports\";
        	string PDFFilename = ReportDirectory + varReportFilename + ".pdf";
        	string ZippedReportLogFileName = ReportDirectory + varReportFilename + ".rxzlog";
        	string ReportLogFileName = ReportDirectory + varReportFilename + ".rxlog";
        	string XMLFilename = ReportDirectory + "style.xml";
        	string XMLArchiveFilename = ReportDirectory + "style.zip";
	   		string StyleXMLURL = "http://www.ranorex.com/blog/wp-content/uploads/2015/07/style.zip";
        	
	   		//check for the reports folder, if it doesn't exist, create it.
	   		Report.Info("Checking for reports folder");
        	if(!Directory.Exists(ReportDirectory))
    	   	{
        		Report.Info("Creating " + ReportDirectory);
    	   		Directory.CreateDirectory(ReportDirectory);
    	  	}
        	
        	//check for style.xml, if it doesn't exist, download and extract it.
        	if(!File.Exists(XMLFilename))
        	{        		
    	   		Report.Info("Downloading style xml from " + StyleXMLURL);
    	   		HTTPHandler.DownloadFile(StyleXMLURL,XMLArchiveFilename);
    	   		Report.Info("Extracting style xml");
    	   		ZipHandler.UnZipFiles(XMLArchiveFilename,ReportDirectory,true);
        	}
        	
        	//get the temp report file from the execution directory, and copy it to the reports folder.
        	Report.Info("Getting current directory");
        	string ExecutionDir = Directory.GetCurrentDirectory();
        	Report.Info("Current directory: " + ExecutionDir);
        	Report.Info("Getting list of files in " + ExecutionDir);
        	string[] ExecutionFiles = Directory.GetFiles(ExecutionDir);
        	string TempReportFilename = string.Empty;
        	Report.Info("Finding temp report file");
        	foreach (string ExecutionFile in ExecutionFiles) 
        	{
        		Report.Info("Checking " + ExecutionFile);
        		if(StringHandler.GetLastXCharactersOfString(ExecutionFile,14).Contains("rxlog.data_tmp"))
        		{
        			Report.Info(ExecutionFile + " is the temp report file.");
        			TempReportFilename = ExecutionFile;
        			break;
        		}
        	}
        	Report.Info("Copying " + TempReportFilename + " to " + ReportLogFileName);
        	File.Copy(TempReportFilename,ReportLogFileName,true);
        	
        	//zip the report
        	Report.Info("Zipping report to " + ZippedReportLogFileName);
        	ReportEnvironment EarlyReportEnvironment = ReportEnvironment.Create(ReportLogFileName,ReportDirectory,string.Empty);
        	Report.Zip(EarlyReportEnvironment,ReportDirectory,ZippedReportLogFileName);

			//create the PDF
        	Report.Info("Creating PDF");        	
        	Ranorex.PDF.Creator.CreatePDF(ZippedReportLogFileName,PDFFilename,XMLFilename,"all");
        	
        	
        	Report.Info("Converting PDF");
        	ReportToPDF.ReportToPDF.ConvertReportToPDF(PDFFilename,XMLFilename,"all") ;
I'm sure it's something silly I'm missing, but the error info doesn't indicate which variable is the invalid parameter, and I've been unable to puzzle it out myself. I've attached the report files and style xml. I'm hoping you can help me, as you helped the OP

Re: ReportToPDF: Parameter is not Valid

Posted: Fri Jul 08, 2016 7:37 pm
by rezme
Side note: I just tried the executable converter with the files I supplied, and I get "parameter is not valid" there as well. Something's hinky with those report files, but I didn't change anything about reporting from the default. No custom icons as the previous poster had going on, no changes to the report structure I'm aware of. I'm at a loss as to what might be causing this.

Re: ReportToPDF: Parameter is not Valid

Posted: Fri Jul 08, 2016 8:36 pm
by rezme
Disregard, I figured the problem out. For anyone else having this issue here's what happened.

A: I was using the wrong report. I was trying to use the temp report sitting in the execution directory, which is apparently incomplete. That was the reason for "parameter invalid" exceptions. I resolved this by using the following code to get the report:

Code: Select all

TestReport.ReportFilename = ReportLogFileName;
TestReport.SaveReport();
Subsequently, I got an "invalid PDF filename" error, but solved that by supplying only the filename, without the path. The PDF was then saved to the same directory I specified for the report log filename. Great library, thanks for putting it together!