PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV (précédentes versions) → [WD11] reading pdf to byte array
[WD11] reading pdf to byte array
Débuté par Yaroslav, 10 aoû. 2010 14:18 - 2 réponses
//hostimage.webdev.info/avatars/default.gif
Posté le 10 août 2010 - 14:18
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
//hostimage.webdev.info/avatars/default.gif
Posté le 01 août 2013 - 23:11
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
//hostimage.webdev.info/avatars/default.gif
Posté le 01 août 2013 - 23:12
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