PC SOFT

PROFESSIONAL NEWSGROUPS
WINDEVWEBDEV and WINDEV Mobile

Home → WINDEV (earlier versions) → [WD11] reading pdf to byte array
[WD11] reading pdf to byte array
Started by Yaroslav, Aug., 10 2010 2:18 PM - 2 replies
Posted on August, 10 2010 - 2:18 PM
Hi all,

I'm trying to read a pdf file into a byte array. On wlanguage, after several trial/error, found that hte buffer variable is the one that matches byte array. Here is my code where sdocumentTitle has the filename of a pdf file.

sAuxis string
sDocumentTitleis string
MyBufferis Buffer
sDocumentTitle= fExtractPath(sAux,fFileName)
MyBuffer= fLoadText(sAux)
fSaveText("_PDF_TEST.pdf",myBuffer)


As can be seen on the code, I save the buffer variable to a file with pdf extension and after that I can read that file without errors on any pdf reader.

My problem is: after all these steps I need to send the buffer (byte array) variable as parameter to a webservice. And the webservice is answering back:

Invalid PDF File. Cross-reference table not found.

But the file created from the buffer variable is correctly opened so I can not guees where the problem is...any advice, tip or correction to the code?

Thanks in advance,
Yaroslav
Posted on August, 01 2013 - 11:11 PM
MyBuffer is Buffer = fLoadBuffer("MyFile.bin")

// Now you can slice the buffer f.i.

slice is Buffer = MyBuffer [[1 TO 8]] // read the first 8 byte



// OR ...if you prefer an byte array



n is int = Length(MyBuffer)

fileArr is array of n Byte

FOR i = 1 TO n

fileArr[ i ] = MyBuffer[[ i ]]

END
Posted on August, 01 2013 - 11:12 PM
Yaroslav a écrit :
Hi all,

I'm trying to read a pdf file into a byte array. On wlanguage, after several trial/error, found that hte buffer variable is the one that matches byte array. Here is my code where sdocumentTitle has the filename of a pdf file.

sAuxis string
sDocumentTitleis string
MyBufferis Buffer
sDocumentTitle= fExtractPath(sAux,fFileName)
MyBuffer= fLoadText(sAux)
fSaveText("_PDF_TEST.pdf",myBuffer)


As can be seen on the code, I save the buffer variable to a file with pdf extension and after that I can read that file without errors on any pdf reader.

My problem is: after all these steps I need to send the buffer (byte array) variable as parameter to a webservice. And the webservice is answering back:

Invalid PDF File. Cross-reference table not found.

But the file created from the buffer variable is correctly opened so I can not guees where the problem is...any advice, tip or correction to the code?

Thanks in advance,
Yaroslav



MyBuffer is Buffer = fLoadBuffer("MyFile.bin")

// Now you can slice the buffer f.i.

slice is Buffer = MyBuffer [[1 TO 8]] // read the first 8 byte



// OR ...if you prefer an byte array



n is int = Length(MyBuffer)

fileArr is array of n Byte

FOR i = 1 TO n

fileArr[ i ] = MyBuffer[[ i ]]

END