How to generate pdf from 2005 rdl report files from command prompt?
Hi All, I have a scenario like this, i have 10 rdl reports, which needs to run on a job basis with out any user interaction. Tell me is there any way to generate the pdf from command prompt using existing 2005 rdl files. Your help is more appreaciated!! Thanks, Sarvesh M Sarvesh
April 29th, 2010 12:28pm

Hi Sarvesh, If the reports are deployed to report server, we can use the Delivery extension to deliver the reports to specified format(e.g. PDF). However, if you just want to export the reports to PDF using command prompt, we can use the RS utiltiy. The rs utility is a script host that processes script you provide in an input file. You can define scripts to administer a report server, copy report server database content to another database, publish reports, and so forth. The script must be written in Microsoft Visual Basic® .NET code, and stored in a Unicode or UTF-8 text file with a .rss file extension. You cannot debug scripts with the rs utility. To debug a script, run the code from within Visual Studio. Below is a code snippet about exporting reports to specified, for your reference: Dim reportPath As String = vReportPath Dim format As String = vFormat Dim fullPathOfOutputFile = vFullPathOfOutputFile Public Sub Main() ' Authenticate to the Web service using Windows credentials rs.Credentials = System.Net.CredentialCache.DefaultCredentials Dim report As Byte() = Nothing Dim deviceinfo As String = Nothing Dim parameters As ParameterValue() = Nothing Dim historyID As String = Nothing Dim credentials As DataSourceCredentials() = Nothing Dim showHideToggle As String = Nothing Dim extension As [String] = String.Empty Dim encoding As [String] = String.Empty Dim mimeType As [String] = String.Empty Dim warnings As Warning() = Nothing Dim reportHistoryParameters As ParameterValue() = Nothing Dim streamIDs As String() = Nothing Dim execInfo As New ExecutionInfo() Dim execHeader As New ExecutionHeader() rs.ExecutionHeaderValue = execHeader execInfo = rs.LoadReport(reportpath, historyID) Try report = rs.Render("PDF", deviceinfo, extension, mimeType, encoding, warnings, streamIDs) Dim fs As New FileStream(fullPathOfOutputFile, FileMode.Create) fs.Write(report, 0, report.Length) fs.Close() Catch ex As Exception Console.WriteLine(ex.Message) End Try End Sub For more information, please see: rs Utility: http://msdn.microsoft.com/en-us/library/ms162839.aspx Subscription and Delivery (Reporting Services): http://msdn.microsoft.com/en-us/library/ms159762.aspx Please feel free to ask, if you have any more questions. Thanks, Jin ChenJin Chen - MSFT
Free Windows Admin Tool Kit Click here and download it now
May 3rd, 2010 12:42pm

Hi Jin, Your answer is very helpful, but I can't get to first base. RS won't authenticate my localhost userID. I get the message ""Could not connect to server: http://localhost/ReportServer/ReportExecution2005.asmx" I've tried every SQL Server UserID and password that's valid on my local instance and also my Novell/Windows UserID. First I deployed my RDL to my localhost/ReportServer. From your example, with some changes at the beginning, I built a UNICODE script file to render an RDL of mine to a PDF and tried to execute it in my Widowx XP SP3 command window. My syntax may be messed up, so here are the first 4 lines of my RSS file (no other changes from yours). Public Sub Main(vReportPath String, vFormat String, vFullPathOfOutputFile String) Dim reportPath As String = vReportPath Dim format As String = vFormat Dim fullPathOfOutputFile As String = vFullPathOfOutputFile Here is my command: rs -e Exec2005 -i publish080d.rss -s http://localhost/ReportServer -u "MyCPU\Les Walker" -p mypswrd s -v vReportPath="/PolicyDB_DW local .51/ACT080d",vFormat="PDF",vFullPathOfOutputFile="C:\Documents and Settings\Les Walker\My Documents\0 Spinn Other\RS\act080d.pdf" Until I named the 3 parameters as in Main() and connected their values by commas in the command string, I kept getting messages like this: "Unrecognized argument vFormat=PDF" Now I'm not getting those messages but I'm back to the original problem I've had with every version of RSS script that I've tried. I can't get past the initial authentication. And the only way I know how to debug a script in Visual Studio is from Word in the Macro debugger. Maybe I can debug this script in BIDS but I'm not sure how. Thanks for any help you can give me. Les Walker
August 27th, 2010 6:44pm

Sorry, meant to reply to my previous post, not propose it as an answer to itself. Here's my answer to my question. ' BAT script to build a directory to house the PDF and RS command to render it using the vb.net script below 'mkdir "C:\Documents and Settings\Les Walker\My Documents\0 Spinn Other\0Claims\ReplacementPDFs\%2" 'rs -e Exec2005 -i SPinnDailyReport.rss -s http://localhost/ReportServer -v vReportPath="/Report Project1/%1" -v vFormat="PDF" -v vFullPathOfOutputFile="C:\Documents and Settings\Les Walker\My Documents\0 Spinn Other\0Claims\ReplacementPDFs\%2\%1.pdf" -v vStartDate="%2" -v vEndDate="%3" ' SPinnDailyReport.rss Dim reportPath As String = vReportPath Dim format As String = vFormat Dim fullPathOfOutputFile As String = vFullPathOfOutputFile 'Declare the StartDate and EndDate parameters (8 Byte dates like 20101014) Dim StartDate8 As String = vStartDate Dim EndDate8 As String = vEndDate Public Sub Main() ' Authenticate to the Web service using Windows credentials rs.Credentials = System.Net.CredentialCache.DefaultCredentials Dim report As Byte() = Nothing Dim deviceinfo As String = Nothing Dim historyID As String = Nothing Dim credentials As DataSourceCredentials() = Nothing Dim showHideToggle As String = Nothing Dim extension As [String] = String.Empty Dim encoding As [String] = String.Empty Dim mimeType As [String] = String.Empty Dim warnings As Warning() = Nothing Dim reportHistoryParameters As ParameterValue() = Nothing 'parmString Dim streamIDs As String() = Nothing Dim execInfo As New ExecutionInfo() Dim execHeader As New ExecutionHeader() 'Reformat StartDate and EndDate Parameters into 10/14/2010 format compatible with Reporting Services DateTime parms: Dim StartDate As String = StartDate8.SubString(0,4)&"/"&StartDate8.SubString(4,2)&"/"&StartDate8.SubString(6,2) Dim EndDate As String = EndDate8.SubString(0,4)&"/"&EndDate8.SubString(4,2)&"/"&EndDate8.SubString(6,2) Dim parameters(1) As ParameterValue parameters(0) = New ParameterValue() parameters(0).Name = "StartDate" parameters(0).Value = StartDate parameters(1) = New ParameterValue() parameters(1).Name = "EndDate" parameters(1).Value = EndDate rs.ExecutionHeaderValue = execHeader execInfo = rs.LoadReport(reportpath, historyID) rs.SetExecutionParameters(parameters, "en-us") Try report = rs.Render("PDF", deviceinfo, extension, mimeType, encoding, warnings, streamIDs) Dim fs As New FileStream(fullPathOfOutputFile, FileMode.Create) fs.Write(report, 0, report.Length) fs.Close() Catch ex As Exception Console.WriteLine(ex.Message) End Try End Sub
Free Windows Admin Tool Kit Click here and download it now
October 15th, 2010 1:51am

I am trying to use the above to render in PDF, and getting errors which suggest that I am missing a reference or import for the lines listed below. Could someone help me? Dim parameters As ParameterValue() = Nothing Dim credentials As DataSourceCredentials() = Nothing Dim warnings As Warning() = Nothing Dim reportHistoryParameters As ParameterValue() = Nothing Dim execInfo As New ExecutionInfo() Dim execHeader As New ExecutionHeader() rs.ExecutionHeaderValue = execHeader execInfo = rs.LoadReport(ReportPath, historyID)
November 24th, 2010 12:49pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics