StringUtil Base64 Encoding question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2013 02:09 PM
I am using the MID Server to generate a PDF using the itext API. I am building the PDF in memory using a ByteArrayOutputStream and then using the StringUtil.base64Encode(baos) to encode it to base64 so I can attach it to a ServiceNow record via the AttachmentCreator.
For sanity sake, I wrote the baos to an actual PDF file and used an online encoder to encode the PDF to base64, and it created a valid string I was able to use in the AttachmentCreator and generate the PDF I was expecting.
When using the base64Encode of the StringUtil class, the encoding looks almost identical, but just slightly different and does not create the PDF file I am expecting when I put the encoded string into my AttachmentCreator call.
The following online tools convert the PDF successfully:
http://www.motobit.com/util/base64-decoder-encoder.asp
http://www.webutils.pl/Base64
Does anybody have any suggestions? Thanks!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2013 12:48 AM
I'm guessing the problem is with base64encode of Service Now. I experienced similar issues when working with base64. Please check this post: Padding rn . Is this what is happening to your encode too?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2013 06:57 AM
Thank you for the response. Unfortunately, there are much bigger differences between the encoded strings than /r/n. Both strings have the same amount of characters, just different in places.
I was hoping the StringUtil API was available so I can see if there are any other methods I could possibly use.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-21-2016 02:07 PM
HI Grey,
We are trying to develop same thing in our company. Can you please respond to this post, so that I can ask you few questions on this task of using MID Server to generate a PDF using the itext API.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2016 06:59 AM
I wish I'd seen this two days ago. I am able to fill a PDF from a file on the MID server and attach the new file to the record, but I am trying to send the attachment to the MID script to update the existing file, then attach it back to the record. I have run into the encoding problem, and the data string from sysAttachment.getBytes() doesn't yield a valid PDF file. I guess I'll have to hold off on this until it (hopefully) gets fixed.