push pdf's out to SSRS Report Server

I have some pdf's that are not part of SSRS, but I would like to display them on the Report Server web site.  I was hoping I could automatically ftp them each night, but so far I haven't been able to properly connect to the report server.  I also know there is an upload button, but can't find a way to automate that either.

Does anyone know if this can be done?
Who is Participating?
ValentinoVConnect With a Mentor BI ConsultantCommented:
Yes, it can be done!  More precisely, you can use the RS utility (rs.exe) to automate the deployment of items to the report server.

I've created the RSS script for you here:

'The following global variables need to be passed in through the rs command:
'Dim name As String = "CatalogItem.pdf"
'Dim parent As String = "/Test"

Dim reportFile As String = "scripts\resources\" & name

Public Sub Main()
	Console.WriteLine("Running script DeployPDF.rss")

	Dim overwrite As Boolean = True
	Dim fileContent As Byte() = Nothing
	Dim warnings As Warning() = Nothing

	'Common CatalogItem properties
	Dim descprop As New [Property]
	descprop.Name = "Description"
	descprop.Value = ""
	Dim hiddenprop As New [Property]
	hiddenprop.Name = "Hidden"
	hiddenprop.Value = "False"

	'PDF-specific property
	Dim mimeTypeProp As New [Property]
	mimeTypeProp.Name = "MimeType"
	mimeTypeProp.Value = "application/pdf"

	Dim props(2) As [Property]
	props(0) = descprop
	props(1) = hiddenprop
	props(2) = mimeTypeProp

		'Read file from disk
		Dim stream As FileStream = File.OpenRead(reportFile)
		fileContent = New [Byte](stream.Length-1) {}
		stream.Read(fileContent, 0, CInt(stream.Length))

		Dim item As CatalogItem 
		item = RS.CreateCatalogItem("Resource", name, parent, overwrite, fileContent, props, warnings)

		If Not (warnings Is Nothing) Then
			Dim warning As Warning
			For Each warning In warnings
				Console.WriteLine("Warning: {0}", Warning.Message)
			Next warning
			Console.WriteLine("CatalogItem: {0} published successfully with no warnings", name)
		End If

	Catch e As IOException
	Catch e As SoapException
		Console.WriteLine("Error : " + e.Detail.Item("ErrorCode").InnerText + " (" + e.Detail.Item("Message").InnerText + ")")
	End Try
End Sub

Open in new window

Save the above to a file called DeployPDF.rss

You'll need a batch file to call the script, so here it is:

@echo off

::Script Variables
SET REPORTSERVER=http://YourServer/ReportServer

::default location on 32-bit machines -> SET RS="C:\Program Files\Microsoft SQL Server\100\Tools\Binn\RS.EXE"
::default location on 64-bit machines -> SET RS="C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\RS.EXE" 
SET RS="C:\Program Files\Microsoft SQL Server\100\Tools\Binn\RS.EXE"

SET LOGFILE="SSRS_DeployLog.txt"

::Clear Log file
IF EXIST %logfile% DEL %logfile%

ECHO Starting deployment to %REPORTSERVER%

::Write Log Header
ECHO Starting deployment at %DATE% %TIME% >>%LOGFILE%
ECHO RS             = %RS% >>%LOGFILE%

::Run Scripts

ECHO ...deploying catalog items...

%RS% -i "%SCRIPTLOCATION%\DeployPDF.rss" -s %REPORTSERVER% -l %TIMEOUT% -e %ENDPOINT% -v name="SomePDF.pdf" -v parent="/Test" >>%LOGFILE% 2>&1

ECHO Finished deployment at %DATE% %TIME% >>%LOGFILE%

ECHO Deployment finished!  See %LOGFILE% for details.

Open in new window

Save that to a file with a .cmd extension.

Follow these guidelines to set up the folder structure as expected by the script:

1. create a folder called PDFDeploymentProject (can be something else)
2. put the .cmd in this folder
3. create a subfolder called \scripts
4. put the .rss file in \scripts
5. create a subfolder in \scripts called \resources
6. put your .pdf file in \resources

Also note that you'll need to customize the .cmd a bit.  The SET REPORTSERVER = line expects your Report Server URL.

Some additional explanation on this line:

%RS% -i "%SCRIPTLOCATION%\DeployPDF.rss" -s %REPORTSERVER% -l %TIMEOUT% -e %ENDPOINT% -v name="SomePDF.pdf" -v parent="/Test" >>%LOGFILE% 2>&1

Open in new window

The name parameter expects the name of your PDF.
The parent parameter expects the folder on the report server in which the file needs to get deployed.

You can repeat that line multiple times for different PDFs.

More info: ReportingService2010.CreateCatalogItem Method

I know it's a lot of info so if something is not clear let me know!
cindyfillerAuthor Commented:
Wow - thank you for the massive response.  You deserve a million points for this.  I may not be able to try it today - but will tomorrow for sure.
ValentinoVBI ConsultantCommented:
You deserve a million points for this.

That would be awesome! ;)
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

cindyfillerAuthor Commented:
I'm sorry for the long delay in testing this out - I had a critical project that was due.  I have followed your instructions and am getting an error.  I think I changed the specifics that need changing, but I'm not understanding this log well enough to fix it.  

Starting deployment at Thu 03/27/2014  8:55:20.14
REPORTSERVER   = http://bbre2/ReportServer 
TIMEOUT        = 60
ENDPOINT            = "Mgmt2010"
RS             = "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\RS.EXE"
The specified script failed to compile with the following errors:
E:\Business Intelligence\PDFDeploymentProject> "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\vbc.exe" /t:exe /main:MainModule /utf8output /R:"System.dll" /R:"System.Xml.dll" /R:"System.Web.Services.dll" /R:"C:\Program Files\Microsoft SQL Server\100\Tools\Binn\rs.exe" /out:"C:\Documents and Settings\Administrator.UNDALUMNI\Local Settings\Temp\1\z5atsfwx.exe" /debug-  "C:\Documents and Settings\Administrator.UNDALUMNI\Local Settings\Temp\1\z5atsfwx.0.vb" "C:\Documents and Settings\Administrator.UNDALUMNI\Local Settings\Temp\1\z5atsfwx.1.vb"

Microsoft (R) Visual Basic Compiler version 8.0.50727.3053
for Microsoft (R) .NET Framework version 2.0.50727.3649
Copyright (c) Microsoft Corporation.  All rights reserved.

C:\Documents and Settings\Administrator.UNDALUMNI\Local Settings\Temp\1\z5atsfwx.1.vb(44) : error BC30451: Name 'reportFile' is not declared.

        Dim stream As FileStream = File.OpenRead(reportFile)
Finished deployment at Thu 03/27/2014  8:55:22.85
cindyfillerAuthor Commented:
BTW, the RSS script I started at the Public Sub Main and did not include this section at the top.  That may be part of the problem.

'The following global variables need to be passed in through the rs command:
'Dim name As String = "CatalogItem.pdf"
'Dim parent As String = "/Test"

Dim reportFile As String = "scripts\resources\" & name
cindyfillerAuthor Commented:
I added the dim reporfile as string and THIS NOW WORKS BEAUTIFULLY!

Thank you again for your wonderful code above.  I still wish I could give you the trillion points.
cindyfillerAuthor Commented:
This was by far one of the best answers I've ever received. It was above and beyond - provided me with the scripts needed to accomplish this!!!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.