Hello,
I am running into an issue with BASE64_DECODE, it is adding leading blanks before the first line. The string 'JVBERi0xLjQKMyAwIG9iago8PC9UeXBlIC9QYQ==' when decoded and written to the IFS directory add 3 extra spaces before the first line.
Any advice here would be great. As the string starts with spaces the printer throws the error invalid XREF when sent to print.
%PDF-1.4
3 0 obj
<</Type
H DFTACTGRP(*NO) ACTGRP(*NEW) BNDDIR('BASE64')
D PDFin s 100A varying
D PDFLen s 10U 0
D PDFOut s 164536A varying
DRW c 6
DR c 4
DOWNER c 64
D ifsPathName s 500a varying
d fd s 10i 0
/copy base64/qrpglesrc,base64_h
/copy base64/qrpglesrc,ifsio_h
pdfin = 'JVBERi0xLjQKMyAwIG9iago8PC9UeXBlIC9QYQ==';
pdfLen= base64_decode(%addr(pdfin:*data):
%len(pdfin):
%addr(pdfout:*data): %size(pdfout));
ifspathname = '/home/mohapaj/test.pdf';
fd = open( ifsPathName
: O_CREAT + O_WRONLY + O_INHERITMODE
+O_CCSID
: RW*OWNER + R
: 819 //same with other CCSID as well (1208)
:0
);
callp write(fd: %addr(pdfout): PDFLEN);
callp close(fd);
*INLR = *on;
RETURN;
BASE64 Decode and Blanks
Re: BASE64 Decode and Blanks
Looks to me as if
Should be
Without that you are writing the varlen's length as part of the data and it is probably translating as blanks.
P.S. Why are you bothering to code CallP? It is not needed.
Code: Select all
callp write(fd: %addr(pdfout): PDFLEN);
Code: Select all
callp write(fd: %addr( pdfout : *Data ): PDFLEN);
P.S. Why are you bothering to code CallP? It is not needed.
Re: BASE64 Decode and Blanks
Thanks @jonboy49. It worked, I was just testing a POC, and I will be -redesigning it!