Converting base64 string to PDF in memory

malkishtini at gmail.com malkishtini at gmail.com
Wed Mar 30 02:23:54 UTC 2022


Hi Scotte,

Thank you for sharing your idea.
It is a good one to experiment when using oBrowser in a desktop app.

For now, I need to do the conversion in a JS client (that runs directly in a
browser) and render the pdf into an Html control.
But I'll keep your approach in mind in case I can get it to work with the
Html control.

Thank you,
Mayada

-----Original Message-----
From: omnisdev-en <omnisdev-en-bounces at lists.omnis-dev.com> On Behalf Of
Scotte Meredith
Sent: Tuesday, March 29, 2022 5:22 PM
To: OmnisDev List - English <omnisdev-en at lists.omnis-dev.com>
Subject: Re: Converting base64 string to PDF in memory

Hi, Miyada -- 

I've only played with this a little, but here is an area to explore.

You can force HTML directly into the oBrowser component using $setdataurl.

Create the html as a string or binary and for the images or PDF you should
be able to uuencode it as an in-line image or embedding as you would for a
webpage.

Here is an example with simple html, using both the character and binary
options.

On a window with an oBrowser component named xBrowser:

Calculate ibnURL as chartoutf8('<html><body><p>Something
here</p></body></html>') Do
$cinst.$objs.xBrowser.$setdataurl(ibnURL,'text/html')
## or
Calculate icURL as '<html><body><p>Something here</p></body></html>'
Do $cinst.$objs.xBrowser.$setdataurl(icURL,'text/html')


> On Mar 29, 2022, at 10:52 AM, malkishtini at gmail.com wrote:
> 
> Hi Andrew,
> Thank you for your feedback.
> I'm afraid that we might end up doing the same thing if we cannot find 
> another solution in Omnis.
> 
> I was wondering if Brainy data has a plug in to help with this 
> conversion, as we do use their driver to create the pdf in memory.
> 
> We found a way to do the conversion in Javascript, 
> https://base64.guru/developers/javascript/examples/decode-pdf, but not 
> sure yet how to make this work with the JS client and the html object. 
> Need to do more digging.
> 
> Thank you & best regards,
> Mayada
> 
> -----Original Message-----
> From: omnisdev-en <omnisdev-en-bounces at lists.omnis-dev.com> On Behalf 
> Of Andrew Stolarz
> Sent: Tuesday, March 29, 2022 12:41 PM
> To: OmnisDev List - English <omnisdev-en at lists.omnis-dev.com>
> Subject: Re: Converting base64 string to PDF in memory
> 
> Mayada,
> 
> I was looking to do something similar a number of years ago. It's my 
> understanding that with the JS client, you need to save the PDF to 
> disk before being able to display it in a JS form.
> 
> We ended up placing the PDF's into a temp location and cleared them 
> out after.
> 
> 
> Andrew
> 
> 
> On Tue, Mar 29, 2022 at 11:24 AM <malkishtini at gmail.com> wrote:
> 
>> Hello $list,
>> 
>> I have a project to convert a base64 string (which I get from an 
>> external REST API) to a PDF and display in a JS form without saving 
>> any file to a disk (i.e., convert it to a PDF in memory and display 
>> it in an HTML object in the JS form (Studio 8.1.7)).
>> I have not done this before, so the first thing I thought about was 
>> to post a question to the list to see if anyone has done something 
>> similar before and could kindly share some ideas with me.
>> 
>> Thank you in advance for any hints/thoughts.
>> 
>> Best regards,
>> Mayada
>> 
>> 
>> 
>> _____________________________________________________________
>> Manage your list subscriptions at https://lists.omnis-dev.com Start a 
>> new message -> mailto:omnisdev-en at lists.omnis-dev.com
>> 
> _____________________________________________________________
> Manage your list subscriptions at https://lists.omnis-dev.com Start a 
> new message -> mailto:omnisdev-en at lists.omnis-dev.com
> 
> _____________________________________________________________
> Manage your list subscriptions at https://lists.omnis-dev.com Start a 
> new message -> mailto:omnisdev-en at lists.omnis-dev.com



Scotte Meredith
spomacguy at gmail.com
509/998-0991




_____________________________________________________________
Manage your list subscriptions at https://lists.omnis-dev.com Start a new
message -> mailto:omnisdev-en at lists.omnis-dev.com 



More information about the omnisdev-en mailing list