Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to publish a PDF from a custom VB.Net app?

Status
Not open for further replies.

twist2099

Programmer
Mar 9, 2007
2
US
I have a custom VB.NET application that needs to publish PDF files to a Crystal Enterprise 10 server. The code that I have works fine for publishing Crystal Report files, but errors out when doing a PDF.

Here is the code:

'InfoStore object is created elsewhere in the code.
Dim pluginManager = InfoStore.PluginManager
ObjectPlugin = pluginManager.PluginInfo("CrystalEnterprise.Pdf")
Dim NewCollection = InfoStore.NewInfoObjectCollection
Dim NewObject = NewCollection.Add(ObjectPlugin)
NewObject.Files.Add(FileName)
NewObject.ParentID = ParentID
NewObject.Title = Name
InfoStore.Commit(NewCollection)
'end of code snipet

And here is the error I get:
Object reference not set to an instance of an object.

Thanks for the help!
 
I have figured out how to make it work. I needed to assign the NewObject.Files.Add method to an object.

Here is the working code:

'InfoStore object is created elsewhere in the code.
'FileName is the vaialble that has the path to the
' local PDF file.
'ParentID is the variable that defines the parent
' object for the PDF.
'Name is the vaiable with the name to be assisnged
' to the object.
Dim pluginManager = InfoStore.PluginManager
ObjectPlugin = pluginManager.PluginInfo("CrystalEnterprise.Pdf")
Dim NewCollection = InfoStore.NewInfoObjectCollection
Dim NewObject = NewCollection.Add(ObjectPlugin)
'** This is what changed:
Dim NewFile = NewObject.Files.Add(FileName)
'**
NewObject.ParentID = ParentID
NewObject.Title = Name
InfoStore.Commit(NewCollection)
'end of code snipet
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top