Problem creating document from Byte ARray

Problem creating document from Byte ARray

Forum member · Jul 26, 2007
I am using this code to get a PDF using an XMLHttp request, converting the response to a byte array, and trying to call PDFDocument.LoadPDF with the byte array, but I keep getting this error: "DynamicPDF error '80131500' Please pass a proper file path or Byte Array or if encrypted pass proper password." Here is the code I'm using. I've stepped through and responseText is a PDF file. Function Convert2ByteArray(strInput) Dim intCounter Dim arrChar ReDim arrByte(Len(strInput) - 1) For intCounter = 0 To Len(strInput) - 1 Dim charStr charStr = Left(Right(strInput, Len(strInput) - intCounter), 1) arrByte(intCounter) = CByte(Asc(charStr)) Next Convert2ByteArray = arrByte End Function Dim req Set req = Server.CreateObject("MSXML2.ServerXMLHTTP") req.open "GET", "http://" & "localhost" & "/Products/LTC/BuildPDF.aspx?client=" & l_ClientID & "&agent=" & "LTCPA000001" & "&model=1" , False req.send Dim LastPageDoc Set LastPageDoc = Server.CreateObject( "DynamicPDF.PDFDocument" ) Dim x x = Convert2ByteArray ( req.responseText ) LastPageDoc.LoadPDF x IsArray(x) returns true, TypeName(x(0)) returns "Byte". Any ideas?

Re: Problem creating document from Byte ARray

Support · Jul 27, 2007
Hello, The error you are getting is most probably because the PDF you are using is encrypted and you will have to supply the password to decrypt the PDF. You will have to use the LoadPdf method which takes the password also as a parameter. Thanks, ceTe Software Support Team.