BASE64 Decode and Blanks
Posted: Mon Mar 17, 2025 7:44 pm
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;
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;