Hi,
I recently downloaded the new eval JBOSS server from the adobe web site and I'm trying to assign reader extension rights to a pdf file via a web service call, as demonstrated in the following example:
http://livedocs.adobe.com/livecycle/es/sdkHelp/programmer/sdkHelp/wwhelp/wwhimpl/js/html/wwhelp.htm?...My crendential alias is called "test", and it's pointing to the .pfx file I got with the download. I was able to successfully create it using the administration console.
In my .net code, I am using the following code, like in the example:
Dim objOutputBlob As New BLOB
objOutputBlob = objReaderExClient.applyUsageRights(objInputBlob, "test", "the_password_I_received", objReaderExtensionsOptionSpec)
This function is supposed to return a byte() representing the output pdf file, but for some reason it is always returning a null array.
Here's my entire code. Any help would be appreciated.
Thanks.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim objBinaryWriter As BinaryWriter
Dim objFileStream2 As FileStream
Try
Dim sInputFileName As String = "C:\test.pdf"
Dim sOutputFileName As String = "C:\test1.pdf"
'Create a ReaderExtensionsServiceService client object
Dim objReaderExClient As New ReaderExtensionsServiceService()
objReaderExClient.Credentials = New System.Net.NetworkCredential("administrator", "password")
'Create a BLOB to store the PDF document to which usage rights are applied
Dim objInputBlob As New BLOB()
'Get the length of the file stream
Dim objFileInfo As New FileInfo(sInputFileName)
Dim lNumBytes As Long = objFileInfo.Length
'Specify the PDF document, open a file stream, read into a binary reader, and place into a
'byte array. then, assign value of the byte array to a blob.
Dim objFileStream As New FileStream(sInputFileName, FileMode.Open, FileAccess.Read)
Dim objBinaryReader As New BinaryReader(objFileStream)
Dim objByteArray As Byte() = objBinaryReader.ReadBytes(CInt(lNumBytes))
objBinaryReader.Close()
objInputBlob.binaryData = objByteArray
'***I DID AN OUTPUT OF THE UBOUND(objByteArray) here, and it IS correct
'Create a UsageRight object and specify usage rights
Dim objUseRights As New UsageRights()
objUseRights.enabledComments = True
objUseRights.enabledFormFillIn = True
objUseRights.enabledDigitalSignatures = True
'Create a ReaderExtensionsOptions object
Dim objReaderExtensionsOptionSpec As New ReaderExtensionsOptionSpec()
objReaderExtensionsOptionSpec.usageRights = objUseRights
objReaderExtensionsOptionSpec.message = "This is a Rights-Enabled PDF Document"
'Apply usage rights to a PDF document
Dim objOutputBlob As New BLOB
objOutputBlob = objReaderExClient.applyUsageRights(objInputBlob, "cyril_test", "I6ta8e==VI", objReaderExtensionsOptionSpec)
'Populate a byte array with BLOB data
Dim objOutputByteArray As Byte()
objOutputByteArray = objOutputBlob.binaryData
'***WHEN I CHECK THIS objOutputByteArray, IT IS NULL ***
'Create the new file .pdf file
objFileStream2 = New FileStream(sOutputFileName, FileMode.OpenOrCreate)
'Create a BinaryWriter object
objBinaryWriter = New BinaryWriter(objFileStream2)
objBinaryWriter.Write(objOutputByteArray) '***NULL REFERENCE
objBinaryWriter.Close()
objFileStream2.Close()
Catch Ex As Exception
Log.writeLog("Error: " & Ex.ToString())
End Try
End Sub