Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

problem with applyusagerights

Not applicable
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
4 Replies
Not applicable
hi,



I face the same problem, too.

Would this problem be settled?

I built a server with WEBLOGIC.



Please teach it if settled.

Any help would be appreciated.
Not applicable
Hi Friends!!!



I'm in a serious trouble and trying to solve the same issue for last 3-4 days. Did you guys were able to successfully apply the rights on PDF. Its coming as null for me.
pobame
Level 1
Level 1

Hi,

I'm having the same problem.  When I try to apply usage rights, the byte array that's supposed to contain the unlocked PDF comes back null.  Was this problem ever solved.  Thanks in advance for your help.

STerry79
Level 1
Level 1

You need to use httpwebrequest on the url property of the returned object.