u/DaveTheNGVet

I built a SVG to PNG rasterizer in pure APEX

I built a SVG to PNG rasterizer in pure APEX

Did you know...that you can make pdfs in Salesforce with images?

While in and of itself, that isn't that big of a deal, but when you look at heap limitations of Salesforce you quickly realize that 6MB (sync) isn't a whole lot of pictures, in fact neither is 12MB (async).

They are however vital to produce high quality documents. Salesforce's new blob.topdf() upgrade unlocked some really cool things that allowed us to put in a bunch of images by referencing them in relative URLs that are accessible via the server. Because they are already on the server, no heap is used to use those images.

Knowing that we could do this we decided to take it one step further. What if we could create the images on the fly? And that is what we did, we built a charting engine that is accessible through merge tags. In order to make it look crisp we draw the charts using SVG. Unfortunately Salesforce doesn't process SVG files so we had to take it one step further. We had to build a SVG to PNG rasterizer. So we did...in pure apex.

We can literally make art on the fly and have it show up on your outputted pdf.

Here's the flow:

0.) Install Portwood DocGen https://portwood.dev

1.) Put Merge Tags in Template

2.) SVG Generation from tags

3.) Apex Rasterizer does it's work

4.) PDF Renders

Here are the results:

https://preview.redd.it/swc6vg037i2h1.png?width=1350&format=png&auto=webp&s=a5fb4db6829a00d234151ba5e944f1506159d77e

https://preview.redd.it/25lwzi037i2h1.png?width=1280&format=png&auto=webp&s=641bab7b243465c9e182824dc5328b9770a50a69

https://preview.redd.it/3ebvsh037i2h1.png?width=1402&format=png&auto=webp&s=e5e17ba658661bc4ae498d90cf43cf05b3999ff0

https://preview.redd.it/h3xwrh037i2h1.png?width=1362&format=png&auto=webp&s=2a9ab5d5a41147a7594114c77c2593cc6bf4a900

https://preview.redd.it/rp8skh037i2h1.png?width=1344&format=png&auto=webp&s=477b5a2e73dd6416b983a301ea87a1e77113f688

https://preview.redd.it/rs14hh037i2h1.png?width=1394&format=png&auto=webp&s=261ec290be2d688f46c11f344c23d9255070dc08

https://preview.redd.it/h0a4zh037i2h1.png?width=1280&format=png&auto=webp&s=9409994957f8088cb3309556fc936eb27629d7ca

https://preview.redd.it/8dbjfh037i2h1.png?width=1566&format=png&auto=webp&s=2ed26826d871158863eebf88e84aac5adffbed3b

Disclaimer and pricing: 100% Free, 100% Native, 100% Open Source, I am affiliated with Portwood, but there is no cost for the app...$0. You are able to buy service or implementation but those are 100% optional.

reddit.com
u/DaveTheNGVet — 1 day ago

Document Generation with Charting Capabilities!?!?

Employee Engagement Survey Demo

Hey everyone, Dave here.

I thought this feature was kind of cool so I figured I would share.

For those of you who don't know me, I am the creator of Portwood DocGen the 100% free, 100% native, 100% open source document generation tool for Salesforce.

Beyond being able to go from Word->PDF or Webpage(Google Docs)->PDF, we've developed some pretty cool functionality. Like this example of having surveys, their questions, and their results.
Here was the Template Used in this video to produce the results on the pdf.

I would be glad to answer any questions, take any feedback as all of it helps make the product just a little bit better every day.

Disclosure: This is a product which is 100% free $0.00. There are paid services available for implementation and support which are 100% optional and can be read about here.

reddit.com
u/DaveTheNGVet — 4 days ago