ACC Tips & Tricks, Adobe Campaign

How To Convert Base64 to PDF attachment

Adobe campaign tips and tricks

In this article, I will provide a simple trick for converting Base64 encoded data to PDF using JSAPI in Adobe Campaign Classic. Due to AC’s inability to attach Base64-encoded files directly to emails, this method can prove to be highly useful.

Base64 data format that would be easy to use when supperted by Adobe Campaign Classic:

data:applcation/pdf;base64, iVBORw0KGgoAAAANSUhEUgAAAAUA
    AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
        9TXL0Y4OHwAAAABJRU5ErkJggg=="

To accomplish this task, we must first decode the incoming file using a memory buffer and save it as a file. Once saved, we can then reference the file while attaching it dynamically for each recipient.

While there may not be many practical examples of the functions outlined in the JSAPI documentation, with some online research, I was able to locate a helpful example for using a memory buffer.

A memory buffer is a data structure that is used to store data temporarily in computer memory. It is a contiguous block of memory that can be accessed and manipulated like an array, but its size can be dynamically adjusted as needed.

Memory buffers are commonly used in programming languages like JavaScript to manipulate and process binary data such as images, audio files, and PDFs.

var memBuff = new MemoryBuffer(),
    f = new File("path/to/export/test.pdf");

memBuff.appendBase64('JVBERi0xLBzb ... Cg==');

f.open("a");
f.writeln(memBuff.toString());
f.close();

This script creates a new memory buffer object called “memBuff”. It also creates a new file object called “f” and assigns it the file path “path/to/export/test.pdf”.

The script then appends Base64 encoded data to the memory buffer using the “appendBase64” method.

Next, the file is opened with the “open” method in “append” mode (“a”), which means the data will be added to the end of the file. The memory buffer is then converted to a string using the “toString” method and written to the file using the “writeln” method. Finally, the file is closed using the “close” method.

In summary, this script reads Base64 encoded data from a memory buffer and writes it to a file in PDF format.

Oh hi there đź‘‹
I have a FREE e-book for you.

Sign up now to get an in-depth analysis of Adobe and Salesforce Marketing Clouds!

We don’t spam! Read our privacy policy for more info.

#JavaScript #jsapi #programming
Marcel Szimonisz
Marcel Szimonisz
MarTech consultant As a marketing automation consultant, I specialize in solving problems, automating processes, and driving innovation in my clients' marketing platforms.

I hold certifications in Adobe Campaign v6 (3x certified) and Salesforce Marketing Cloud (5x certified).

Additionally, I serve as a community advisor for Adobe Campaign, offering expert insights and guidance.

In addition to my professional pursuits, I also enjoy exploring various programming languages, CMSs, and frameworks, further enhancing my technical expertise and staying at the forefront of industry advancements.
Take a look at our subscription offering in case you are looking for a Marketing Automation Consultant.

Leave a comment

Your email address will not be published. Required fields are marked *

Similar posts that you may find useful

Adobe Campaign Classic Automate Publishing File Resources With Workflow
Adobe Campaign, Marketing Automation

Automate publishing file resources with workflow

2 minutes read

Sometimes, you will reach a point where you want to upload file resources from a script. Although there are hints on the Experience League, even with those, this problem has caused me some troubles. However, challenges and troubles are what I seek. I have decided to map this functionality, which can become handy once in […]

Continue reading
Adobe Campaign Classic tips
ACC Tips & Tricks, Adobe Campaign, Marketing Automation

Sending SMS with Unicode Characters in adobe campaign

1 minute read

Are you planning to send SMS messages with Unicode characters? If so, you may be wondering why your messages are split into multiple messages even though they don’t exceed the character limit. Here’s what you need to know about sending SMS messages with Unicode characters. What are Unicode Characters? Unicode is a character encoding standard […]

Continue reading
Adobe Campaign Classic tips
ACC Tips & Tricks, Adobe Campaign, Marketing Automation

Load the first workflow in campaign view

less than a minute read

Every campaign manager, sooner or later, finds their way into marketing automation tools like Adobe Campaign Classic. However, one common challenge is encountered when loading campaigns and their workflows. By default, the system loads the first-added workflow, which can lead to confusion. Many users have inadvertently made changes to older versions of campaign workflows or […]

Continue reading
Spawn workflows programatically
Adobe Campaign, Marketing Automation

Deploy workflow templates with JavaScript in Adobe Campaign

3 minutes read

Adobe Campaign is a powerful tool for creating and managing marketing campaigns. One of its most useful features is the ability to create automated workflows. In this post, we will walk you through the process of “spawning” workflows in Adobe Campaign. What is spawning a workflow? And why and where we can it be useful […]

Continue reading
Adobe Campaign Classic tips
ACC Tips & Tricks, Adobe Campaign, Marketing Automation

Mastering Email Template Proofing for Multiple Variants

1 minute read

Imagine having to proof all the possible variants of a delivery template, where there could be numerous end variations. How can we effectively proof such an email template? There is a simple yet powerful workaround for proofing all the variants, and here’s how to achieve it: Moreover, to differentiate between variations, you can include your […]

Continue reading