|
What the raw json looks like.
BASE64DOC":"\u0000œ"mJVBERi0xLjcgCiXi48/......
-----Original Message-----
From: RPG400-L <rpg400-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of
(WalzCraft) Jerry Forss
Sent: Friday, May 23, 2025 8:41 AM
To: RPG programming on IBM i <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: External Base 64 PDF Encode
CAUTION: This email originated from outside of the organization. Do not
click links or open attachments unless you recognize the sender and know
the content is safe.
Hi All
First, Thank you to Marco to getting me to this point!
I need to take a PDF on the IFS, convert it to a Base64 and return it back
through a web service.
I am getting the Base64 and looks correct but when it is sent back to the
service it is adding weird characters to the beginning of the field.
Variable length info? The field is NOT defined as a variable length field.
When converting back to a PDF it fails because of the garbage characters.
What the H.....eck am I doing wrong?
Relevant PRG code
//
===================================================================================
// Data Stuctures
//
===================================================================================
Dcl-DS Response Qualified Template Inz;
Base64Doc_LENGTH Int(10);
Base64Doc Char(1000000);
End-Ds;
//
===================================================================================
// Input Parameters
//
===================================================================================
Dcl-pr WOMDocDspR;
Envir Char(2);
CustNo Packed(8 : 0);
Order Char(7);
DocSeq Packed(9 : 0);
Responses LikeDS(Response);
Fail Char(100);
End-pr;
Dcl-pi WOMDocDspR;
Envir Char(2);
CustNo Packed(8 : 0);
Order Char(7);
DocSeq Packed(9 : 0);
Responses LikeDS(Response);
Fail Char(100);
End-pi;
//
===================================================================================
// Global Variables
//
===================================================================================
Dcl-S Base64 SQLType(CLOB : 1000000);
Dcl-S DocPath VarChar(200);
EXEC SQL SET OPTION COMMIT = *NONE;
exec Sql VALUES QSYS2.BASE64_ENCODE((SELECT LINE FROM TABLE(
QSYS2.IFS_READ_BINARY(PATH_NAME => :DocPath ))))
INTO :Base64;
Responses.Base64Doc_LENGTH = %Len(%Trim(Base64));
Responses.Base64Doc = Base64;
From debug
EVAL Base64
BASE64_LEN OF BASE64 = 278400
BASE64_DATA OF BASE64 =
....5...10...15...20...25...30...35...40...45...50...55...60
1 'JVBERi0xLjcgCiXi48/TIAoxIDAgb2JqIAo8PCAKL1R5cGUgL0NhdGFsb2cg'
61 'Ci9QYWdlcyAyIDAgUiAKL1BhZ2VNb2RlIC9Vc2VOb25lIAovVmlld2VyUHJl'
121 'ZmVyZW5jZXMgPDwgCi9GaXRXaW5kb3cgdHJ1ZSAKL1BhZ2VMYXlvdXQgL1Np'
181 'bmdsZVBhZ2UgCi9Ob25GdWxsU2NyZWVuUGFnZU1vZGUgL1VzZU5vbmUgCj4+'
What is returned
"RESPONSES": {
"BASE64DOC":"oe"mJVBERi0xLjcgCiXi48/TIAoxIDAgb2JqIAo8PCAKL1R5cGUgL0NhdGFsb2cgCi9QYWdlcyAyIDAgUiAKL1BhZ2VNb2RlIC9Vc2VOb25lIAovVmlld2VyUHJlZmVyZW5jZXMgPDwgCi9GaXRXaW5kb3cgdHJ1ZSAKL1BhZ2VMYXlvdXQgL1NpbmdsZVBhZ2UgCi9Ob25GdWxsU2NyZWVuUGFnZU1vZGUgL1VzZU5vbmUgCj4+IAo+PiAKZW5kb2JqIAo1IDAgb2JqIAo8PCAKL0xlbmd0aCAzMzMyIAovRmlsdGVyIFsgL0ZsYXRlRGVjb2RlIF0gCj4
Subject to Change Notice:
WalzCraft reserves the right to improve designs, and to change
specifications without notice.
Confidentiality Notice:
This message and any attachments may contain confidential and privileged
information that is protected by law. The information contained herein is
transmitted for the sole use of the intended recipient(s) and should "only"
pertain to "WalzCraft" company matters. If you are not the intended
recipient or designated agent of the recipient of such information, you are
hereby notified that any use, dissemination, copying or retention of this
email or the information contained herein is strictly prohibited and may
subject you to penalties under federal and/or state law. If you received
this email in error, please notify the sender immediately and permanently
delete this email. Thank You
WalzCraft PO Box 1748 La Crosse, WI, 54602-1748 www.walzcraft.com<
http://www.walzcraft.com> Phone: 1-800-237-1326
--
This is the RPG programming on IBM i (RPG400-L) mailing list To post a
message email: RPG400-L@xxxxxxxxxxxxxxxxxx To subscribe, unsubscribe, or
change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.
Subject to Change Notice:
WalzCraft reserves the right to improve designs, and to change
specifications without notice.
Confidentiality Notice:
This message and any attachments may contain confidential and privileged
information that is protected by law. The information contained herein is
transmitted for the sole use of the intended recipient(s) and should "only"
pertain to "WalzCraft" company matters. If you are not the intended
recipient or designated agent of the recipient of such information, you are
hereby notified that any use, dissemination, copying or retention of this
email or the information contained herein is strictly prohibited and may
subject you to penalties under federal and/or state law. If you received
this email in error, please notify the sender immediately and permanently
delete this email. Thank You
WalzCraft PO Box 1748 La Crosse, WI, 54602-1748
www.walzcraft.com<http://www.walzcraft.com> Phone: 1-800-237-1326
--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.