Posts tagged "Adobe"

New life for old PostScript printers using CUPS

I have the good fortune to own a Xerox DocuColor 3535 printer. In its day, it was a workhorse, delivering oversized tab pages in full color at blazing speeds (for the early 2000s).  Mine happens to be the one with the embedded Fiery Controller, which had a lot of features, but wasn’t considered as robust as the external Fiery EX3535 or the Creo Spire RIPs that were available at the same time. Nevertheless, this machine is a trooper, producing high quality output year after year.

Unfortunately for me but also very understandably, Xerox stopped supporting this printer a long, long time ago. As a result, the last supported MacOSX version that works with the printer is 10.5. Yikes! Fortunately for me, the Fiery Command Workstation Java app still works, and it allows me to download PostScript and PDF files to the printer. The result is a clunky workflow that requires me to print to PS files on my desktop, as PDF jobs above the Acrobat 5 days will fail due to transparency and other issues, and then manually load them to the printer. This workflow was acceptable, and since it let me eke another few years out of the printer, I was not complaining.

Until yesterday, when I needed to print an XFA PDF from Acrobat. What the heck is an XFA PDF, you ask? Well, let’s gather ’round the fire for a moment and we’ll talk about it.

All PDF files aren’t created equally. Acrobat and Reader are very good at hiding this from you, which is by design. From Adobe’s perspective, the user shouldn’t need to worry whether a digital document was made using traditional PDF methods such as Distiller, a print driver, using a PDF library, or some other standards compliant method. For most applications, PDF is a way to describe the content and geometry of a document. Its roots are in PostScript, so it is no surprise that PDF is often viewed as synonym for digital paper. Over time, PDF evolved to include many interactive features such as the ability to play video, run JavaScript, and even play Flash content. Even with the interactive features of a rich PDF, however, PDF is really the closest we can get to Harry Potter paper. The pages all have a definite size, the fonts don’t change when you reorient the reading application, and the experience is definitely not responsive like a web page. This is OK, though, as PDF in its current form for most people is really about paper replacement, and as such there is no equal to PDF.

Now, Adobe gave PDF to the world as a standard in 2007 as ISO 32000-1 to promote the broader adoption of the format and to encourage companies to build solutions that can consume PDF built using traditional methods. You can purchase a PDF of the PDF Standard at the ISO 32000-1:2008 specification download page or download a free PDF version of the PDF Spec at the Adobe Developer Connection. Kind of meta, right? Also included in the PDF specification is a section about forms. As you are likely aware, PDF files can also behave like forms, and there is a forms editing capability in Acrobat that’s designed to help convert a paper form into a digital form. Using Acrobat’s built-in tools, you can take a picture of or scan a paper form, prepare the form, type on it to complete it, and then send it for electronic signature. Pretty awesome, if all you want to do is replicate a paper process.

Now, deep in the PDF specification is a section about XFA, or XML Forms Architecture. XFA is a PDF variant that is the basis of JetForms’ Accelio’s Adobe’s  LiveCycle solution, which is now known as Adobe AEM Forms. The idea is that a document could be written not as something based on a page description like a sheet of digital paper, but rather as a structured array of content that could be rendered on the fly by Acrobat or other rendering technology. It was designed for forms, because in many cases, form responses were longer or larger than the space provided. With XFA, the form can just magically get longer to accommodate. It also allowed forms designers to include interactive and design features for the person who completes the form, such as buttons to add and delete sections or fields to a form, network connections to database solutions so that the form can have up-to-date content, and much more. This all sounds amazing, right?

While Acrobat can make a form using form fields, these Acrobat-made form fields are fixed on the page in location and dimension, and the average user can’t modify the layout of the page to accommodate more content. Acrobat can’t make an XFA form, but it can read, display and  XFA forms. In order to make XFA forms, you need to use the Adobe LiveCycle Forms Designer or make it through automation using AEM Forms. LiveCycle Designer was previously included as a component of LiveCycle and in other desktop software bundles, but it is now only available to LiveCycle and AEM Forms customers. Why, you ask? XFA is used heavily by Insurance, Financial Services, Health Care and Government customers who use the business process, security, digital signature, document automation, system integration, and other capabilities of LiveCycle or AEM Forms. In addition, while XFA is included in the PDF specification, few other companies have invested resources in developing solutions around XFA PDF. This includes reading and viewing and interacting with an XFA PDF, so the only way to read, view and interact with an XFA PDF is to use Acrobat or Reader on a desktop computer. This is just fine when the intent is to enable workers in an Enterprise to engage with Enterprise business process using complex forms, but for the general user, it’s overkill.

This doesn’t mean that companies don’t use LiveCycle Designer to make standalone forms, which takes us back to the original premise. The Boy Scouts of America uses LiveCycle Designer to produce a the forms that Scouts use to manage and make the final reports for their Eagle Scout project. This form is great, because the Scout can use it as a notebook for their project. It includes fields with text, tables and photographs, and it allows the Scout to add and remove fields as necessary to accommodate the details of their project. For my son, this document grew to 34 pages and over 30 MB due to the inclusion of many photographs of his project. Now, even though the form is electronic, the local group that reviews the Eagle Rank Advancement wants a printed binder that includes these 34 pages as well as some other content, which is why I needed to print the PDF in the first place.

Printing the PDF proved to be very challenging. My usual method of uploading the PDF to the Fiery didn’t work, since the Fiery doesn’t support XFA PDF. I knew this ahead of time, so I tried to convert to PostScript from Acrobat. This also didn’t work. I knew that I could print to my inkjet printer without issue, so I decided to see if I could print to the 3535.

I remembered that Apple’s printing system is based on CUPS, their open source *nix printing architecture. I also know that it supports a wide array of network connections and adheres to the PostScript Printer Description model of defining the capabilities and limitations of a printer. I knew that while the printer has a built-in AppleTalk server and a built-in port 9100 server, neither of these connections work with modern Mac OS. I also remembered that the printer makes a Windows printer, and I was unsuccessful in printing to this printer.

I wanted to look at the options for the printer, which means either using the embedded web server (which doesn’t support anything beyond Internet Explorer on a Mac. Seriously.) or using Command Workstation 5. The Printer Setup utility requires the Apple-provided Java 6, so I needed to install that in addition to Java 8 (which I use for other applications, including Adobe Experience Manager). Now that I had Java 6 installed and Command Workstation 5 installed, I found the LPD and IPP options buried under the Service2 tab of the Network Setup. Nice! I ensured that these were enabled and went back to my Mac to try an add the printer. With the proper PPD in hand (I downloaded the software installer from Xerox), I opened up System Preferences and then the Printers & Scanners option, then clicked the + button to add a printer. I tried first with IPP, and I was unable to add a printer. I next tried with LPD, and again was unable to add a printer. In both cases, you need to specify the IP address, the queue you want to target (in my case I want the hold queue), and the PPD. Then I remembered that the printing system is CUPS, and that CUPS has a console.

The web interface to CUPS is off by default. You can enable it by going to Terminal and running the command “cupsctl WebInterface=yes”

Now that the CUPS web interface is enabled, open http://localhost:631 and you will see CUPS in all its 1994-styled glory, complete with buttons and hyperlinks that all tell you exactly what they will do. This interface is designed to be USEFUL, not pretty, so don’t go all UX on me now. You want the Administration tab, so click it and then click on Add Printer under the Printers section. You will need to enter your administrator’s user name and password, which is expected. You will now see several sections, including your installed printers, printers that CUPS can see, and also a the bottom, the Other Network Printers section. You want to click the radio button (I told you it was antique) next to LPD/LPR Host or Printer, then click the Continue button.

Select LPD/LPR

Select LPD/LPR Host or Printer

On the next screen,  enter the complete URI for your printer, including protocol and queue. For me, I used “lpd://192.168.1.22/hold” There are three queues available on this device: “lpd://192.168.1.22/direct” “lpd://192.168.1.22/hold” and “lpd://192.168.1.22/print” Enter your URI, then click the Continue button.

Enter your URI with protocol and print queue

Enter your URI with protocol and print queue

On the sext screen, enter a name and description for the printer. The name needs to be web friendly, so no spaces or slashes or hashes. If you want, you can also share the printer so others in your house or work group can access the printer. If you do, then your computer will become a print spooler for the Xerox machine, so be prepared for network activity if you’re in a company or group with several folks who’ve been jonesing to print to your 3535. IN addition, you will need to go back to the CUPS Administration page and enable the “Share printers connected to this system” option, which will force a restart of CUPS on your computer. When you’ve finished debating the pros and cons of becoming a print server, click the Continue button.

Add a name and description to your printer.

Add a name and description to your printer.

Now, this is the part where you need your PPD. Click the Choose File button, and browse to your languishing PPD from the turn of the century.  Once you’ve selected click Create Printer.

The final step is to add your PPD.

The final step is to add your PPD.

Voila! You now have a functional printer that prints to the Xerox 3535 embedded Fiery hold queue. You should see a page asking you to set the default options for the printer, which are defined by the PPD. These will apply to every job you send if you do not override the defaults, so it’s a good idea to browse through the settings one by one and tune them to your specific setup. Once satisfied, click the Set Default Options button.

Set the default printer options for your printer

Set the default printer options for your printer

After you set the default options, you should send a test page. Return to the CUPS page and click on the Printers tab, then on your newly minted printer. You should see two drop-down menus under the printer status line. Click Maintenance and then choose Print Test Page. This will send a test page to your 3535’s hold queue. You’ll need to go to Command Workstation to verify that the page was sent, but can get instant satisfaction if you built a printer that points to the print queue instead of the hold queue.

Be sure to print a test page to validate your setup.

Be sure to print a test page to validate your setup.

All of this work was to print an XFA PDF, remember?  Heading back to Acrobat, I was able to print a copy of my son’s Eagle Scout paperwork lickety split on my very old, out of support PostScript laser printer. If you’ve got one of these or other older seemingly unsupported PostScript printers lying around, power them up and see if you can use CUPS and a PPD to get them back in service again.

Share on Facebook

Many ways to make content for Adobe DPS 2015

I presented a talk entitled Creating Content for Mobile Apps with Adobe Digital Publishing Solution at Adobe MAX 2015, and the recording is available here.

While the Adobe Digital Publishing Suite is a magazine platform that had many Enterprise applications, the Adobe Digital Publishing Solution (DPS 2015) is an Enterprise platform that can be used for magazines. Magazines are one of many use cases for which DPS 2015 is appropriate, and in this session, we see how to use a number of content sources in addition to InDesign to make articles for DPS 2015. These include but are not limited to Adobe Experience Manager, Adobe Muse, Adobe Dreamweaver, Adobe Captivate, Adobe FrameMaker and even Adobe Acrobat.

It is clear that content producers have more choices than ever when it comes to making, managing and deploying content to readers on tablet and mobile devices. Adobe DPS 2015 offers Enterprises a flexible, measurable and cross-platform solution for a wide range of communications use cases.

Share on Facebook

Succeeding with Creativity in the Enterprise

I recently presented a talk entitled Succeeding with Creativity in the Enterprise at Adobe MAX 2015. The recording is now available here.

The complexity of modern marketing puts stress on Enterprise Creatives, and Adobe Creative and Marketing Clouds can help mitigate stress through Connected Assets and Creative Sync, Workflows, Analytics and Automation. This talk explores the causes of the Creatives’ stress and demonstrates how Enterprises can engage with external freelancers while maintaining Enterprise control over the process. We also see how Adobe Experience Manager (AEM) provides insight into the relationships between assets, enhancing brand compliance and simplifying license management for licensed content.

Share on Facebook

InDesign Server questions and answers

Customers often ask me about InDesign Server. InDesign Server? Yes, it’s true. InDesign is available as a server, which makes document automation possible for many kinds of businesses. It offers InDesign functions as a service, accessible through SOAP or other communication protocols. It is not the desktop version of InDesign available in a browser.

Companies have successfully used InDesign Server as part of workflows that:

  • Make greeting cards
  • Produce mutual fund documentation
  • Generate personalized mail pieces
  • Assemble and print on-board schedules on a cruise ship
  • Render InDesign documents as PDF for online delivery
  • Layout quarterly catalogs for industrial parts suppliers

These are but a few of the use cases for which InDesign Server is appropriate. In all cases, InDesign Server is part of a larger business process, usually driven by a web site or a Digital Asset Management (DAM) solution such as Adobe Experience Manager (AEM) Assets. InDesign Server is also included as a component of many commercial Variable Data Publishing (VDP) and Print on Demand (POD) solutions, but those servers are licensed only for use with those commercial solutions. You can learn more about InDesign Server partners at the InDesign Server Partner Guide.

InDesign Server is a service, really, that responds to questions like:

  • “Hey, InDesign Server. If I give you this InDesign template, can you merge this XML file onto it and then give me back a print-ready PDF?”
  • “Hey, InDesign Server. Here’s an InDesign Document. Can you extract all of the text frames as RTF files and re-link them back to their original frames and then save InDesign file as a new document with _relinked added to its name?”
  • “Hey, InDesign Server. Can you make a new document, import the style sheets from this other document, then import all of the images in this folder, each on a new page, and apply the object style ‘image’ to each image and put a metadata caption with the copyright data in the lower right hand corner of each image, and then export each page as a new PDF with the file name corresponding to the filename of the image placed onto it?”

Of course, those questions must be written as scripts in one of four languages: Adobe ExtendScript, JavaScript, AppleScript or Microsoft Visual Basic. AppleScript and VisualBasic are only available when the server is running in an Apple or Windows operating system, respectively. There is an SDK and many examples available at adobe.com/devnet. There’s really no limit to what you can do with InDesign Server, so long as you have coders who can ask the right questions and so long as you have enough capacity to process the volume of jobs you expect to handle. There are many companies who use InDesign server to build photo books and greeting cards from customer-supplied photos, for instance. They create web sites to help customers design their books and cards online, and the actual print-ready files are made by InDesign Server. They process thousands of jobs per day, so they need to have enough capacity to keep up with their demand. How, then, do you architect an InDesign Server application from the perspective of the servers themselves?

Here’s three questions you need to ask to help scope an InDesign Server application, and then some more detail about InDesign server.

  1. Will your use case allow internal and external users to access the InDesign Server directly? If you use InDesign Server to render an InDesign document as a jpg or pdf and then post the jpg or pdf on your web site, the end user does not have direct access to InDesign server. If you make a web form that lets your end user customize a document and deliver it to them on demand, they do have direct access to the InDesign server.
  2. What is your failover or disaster recovery requirement? The deployment architecture allows for both multiple dedicated servers as well as multiple instances on servers with multiple cores. The licensing will depend therefore on how you mix dedicated servers and instances on those servers.
    The deployment architecture will also depend on maximum expected throughput. We usually look at the peak demand per minute or quarter hour or hour, depending on the use case, as well as the end user tolerance for delay between requests and results.
  3. How do you plan to support development for InDesign Server applications? Deployments typically have one or more development instances, and then two or more dedicated production servers with multiple instances available on each server to provide fault tolerance.

InDesign Server is available as an add-on to a managed services instance of AEM. Customers can also purchase InDesign Server on their own from their channel partner or from Adobe directly, depending on their relationship with Adobe. 60-day Trials are available at http://www.adobe.com/cfusion/tdrc/index.cfm?product=indesign_server

InDesign Server is licensed based on use case and deployment architecture, and it is available as an annual subscription like Creative Cloud. Enterprise customers can license in three year terms as part of an Adobe Enterprise Term Licensing Agreement (ETLA). Other customers can purchase annual subscriptions from their favorite Adobe reseller. Consult the Indesign Server Buying Guide for more information.

Across the use case axis, there is Limited and Premium.

  • Limited allows a customer to use InDesign Server for an application that only their employees can access. It does not allow the customer make an interface that exposes the InDesign Server to any external user. They would purchase Single- or Multiple-Instance licenses depending on how many documents they would process per day, hour or minute.
  • Premium allows a customer to use InDesign Server for an application that external users could access as well as internal users. Consider the photo book use case where they have a web site that allows customers to upload their photos and buy a photobook. The book is made using InDesign Server driven by a web application. Again, volume would determine whether you would choose Single- or Multiple-Instance licenses.

The deployment architecture axis has two options as well: Single-Instance or Multiple-Instance.

Single-Instance allows one instance of IDS per server per license, and Multiple-Instance allows multiple instances of IDS per server per license. There is no CPU counting required, as the Multiple-Instance license includes an unlimited number if instances on the same server hardware. For instance, if a customer has a 16 core dedicated server with 32 GB of RAM, they could use one IDS Multiple-Instance license and kick off 15 simultaneous instances of IDS at a time (InDesign Server is single-threaded and uses a single core per instance and ideally 2GB of RAM). Other customers choose to deploy many Single-Instance servers on different hardware for fault tolerance and disaster recovery. InDesign Sever has a job queue manager, but many customers choose to build their own queue manager and load balancer. Adobe Experience Manager includes an InDesign Server load balancer and queue manager as part of its integration with InDesign Server. Some customers choose to deploy many Single-Instance servers, while others choose to deploy few Multiple-Instance servers, based on their requirements and available server resources.

How do you decide whether to choose Single- or Multiple-Instance architecture? It is common for high volume use cases to have at a minimum of two Multiple-instance servers, each that can process multiple simultaneous jobs. Two servers provides for fault tolerance, but it does not account for disaster recovery, which would include another instance in a different data center. The number of servers is usually determined by the typical job characteristics measured in seconds to process a typical job, divided by the number of available instances, and compared against the maximum number of jobs that are expected to be processed in a meaningful time interval, usually one minute to an hour. If you are running a financial services company that is generating three hundred complex proposals per hour, and each proposal takes 15 seconds to process, and you have 3 cores available on your server, then your server can handle 3 jobs/15 seconds * 3600 seconds/hour =  720 jobs per hour. Since you need to process 300 jobs per hour, per proposal type, you have enough capacity. But, if you need to know if you can handle the volume at the end of the trading day, when you only have 15 minutes and not an hour to get the proposals out, then your server will fall short and you should likely add another server or two to the cluster.

The last consideration is how you plan to develop and test your applications. You should have at a minimum of one development server that matches your deployment configuration, and there is a Development license available with the same use case and architecture considerations. Developers use their development tools of choice. It is common to use the ExtendScript Toolkit, which is part of Creative Cloud. Using ExtendScript Toolkit, developers can connect to a desktop InDesign to test and debug their scripts. Once they are satisfied with the performance and results, those scripts would either be moved to the InDesign Server Scripts folder or would reside in the web application or DAM, which would send the scripts as part of their job payload.

InDesign Server offers customers document automation capabilities that can provide brand consistency, high volume document creation and even new business opportunities. Whether part of a commercial solution or part of a custom application, InDesign Server delivers performance, flexibility and quality to automated document processing.

 

Share on Facebook

AEM Assets workflow for automatic PDF generation from InDesign files

Many of my Enterprise customers ask how they can use Adobe Experience Manager (AEM) to automate the production of common derivative files from their InDesign files. Derivative files, you ask? InDesign files often represent the “source of truth” for many business documents, from manuals to data sheets to publications and many more types. These documents must be transformed from InDesign into something else (hence the term derivative) in order to be made available on a web site, for instance. The usual method is to export a PDF from InDesign and then upload the PDF as a new asset into the repository. This puts added burden on the author of the InDesign file as well as introducing the possibility of error due to incorrectly set PDF job options. This gets even more complicated if the author must make versions suitable to send to a commercial printer as well as a version that’s optimized for reading online as a PDF. This article provides techniques to automate the production of a web-optimized and print-optimized PDF from any InDesign file that appears in AEM Assets.

This article assumes that you have access to Adobe Experience Manager Assets and InDesign Server. In this example, I use AEM 6.1 and InDesign CC Server 2015, but the technique should work with AEM 5.6.1 and higher and ID Server CS6 and higher. You need to ensure that you have configured your AEM Author environment to work with InDesign server according to the documentation found here. The foundation of any successful integration (beyond configuration!) is the combination of Scripts, Workflow Models, and Workflow Launchers.

You can download a package that contains the scripts and a workflow model you can use today. When you install the package, you will have new scripts located at /etc/dam/indesign/scripts and /etc/workflow/scripts. You will also see a new Workflow Model located at /etc/workflow/models/dam/. The Workflow Launcher must be reconfigured, since I didn’t want to disrupt your existing workflows after you install the package.

Scripts

Scripts tell AEM or external applications what to do, and they form the basis of any InDesign Server-based solution. There are two sets of scripts used here: one set for InDesign Server to generate the PDFs and the other for AEM to move the resulting files. First, let’s look at the JavaScript to tell InDesign Server what we want it to do and how we want it to respond to the request.

There are a number of InDesign Server scripts included in the basic AEM installation, and I’ve modified /etc/dam/indesign/scripts/PDFExport.jsx to request specific kinds of PDF from InDesign Server.  In addition, the script writes the new PDF files into the InDesign file’s /renditions node. These two scripts are located at /etc/dam/indesign/scripts/PDFExport_Print.jsx and at /etc/dam/indesign/scripts/PDFExport_Web.jsx. I could have easily combined these two operations into one script, but I wanted to leave you the option to easily enable or disable each one according to your requirements. You can also combine them yourself or make them fancier, responding to properties you set on the InDesign file in AEM (via XMP) and read out with InDesign Server. Here is the code for PDFExport_Web.jsx, which is almost identical to PDFExport_Print.jsx. The difference is in the value of pdfExportPreset in line 31, the filename set in line 56, and the function return value set in line 57.

//==============================================================================
// Export any Indesign document as PDF
//==============================================================================

//==== get soap arguments ====
if (app.scriptArgs.isDefined("credentials")) {
 var credentials = app.scriptArgs.getValue("credentials");
} else {
 throw "CQ host credentials argument is missing";
}
if (app.scriptArgs.isDefined("cqHost")) { 
 var host = app.scriptArgs.getValue("cqHost");
} else {
 throw "cqHost argument is missing";
}
if (app.scriptArgs.isDefined("resource")) { 
 var resourcePath = app.scriptArgs.getValue("resource");
} else {
 throw "resource argument is missing";
}


try {
 //==== create a temporary folder under InDesign server tmp directory to fetch and export ====
 // added randomness to the folder name
 var exportFolder = new Folder("tmp-" + (new Date().getTime() - Math.floor((Math.random()*10000)+1) ));
 exportFolder.create();
 fileName = resourcePath.substring (resourcePath.lastIndexOf ('/'), resourcePath.lastIndexOf ('.'));
 var sourceFile = new File(exportFolder.fullName + fileName + '.indd');
 var outputFile = new File(exportFolder.fullName + fileName + '_web.pdf');
 var pdfExportPreset = "[Web Preset]" // Set your PDF Web-ready Export Preset (joboption) here.
 // You can use any joboption file installed in InDesign Server


 app.consoleout('Fetching resource from CQ: '+resourcePath);
 fetchResource (host, credentials, resourcePath, sourceFile);

 var document = app.open(sourceFile);

 with (app.pdfExportPreferences) {
 viewDocumentAfterExport = false;
 }
 var myPDFExportPreset = app.pdfExportPresets.item(pdfExportPreset);
 document.exportFile(ExportFormat.pdfType, outputFile,myPDFExportPreset);

 // close the document
 document.close(SaveOptions.no);
 
 //==== remove the original resource and send the export back to CQ ====
 sourceFile.remove();

 //==== send file to CQ ====
 var target = resourcePath.substring (0, resourcePath.lastIndexOf ('/')) + "/renditions";
 app.consoleout('Posting this file to CQ: '+outputFile);
 app.consoleout('Posting to location: ' + target);
 putResource (host, credentials, outputFile, fileName + '_web.pdf', 'application/pdf', target);
 returnValue = "PDF for Web exported and posted successfully";
} finally {
 //==== remove the temp folder ====
 cleanup(exportFolder);
}
app.consoleout('Finished PDF for Web export using '+pdfExportPreset+' joboptions');

To use these scripts, you need to have a PDF Joboptions file installed in InDesign Server to export your PDF. When you install the package, you will find a new folder at /content/dam/InDesign Server joboptions that contains two PDF Export Presets for InDesign Server. Move these two files to Applications/Adobe InDesign CC Server 2015/Resources/Adobe PDF/settings/mul and then restart InDesign Server to load the new settings.

Now that we have the InDesign Server pieces in place, let’s look at the AEM script. This is an ECMA script, which is very much like JavaScript, and it’s located at /etc/workflow/scripts/move-pdf-renditions.ecma. I’ve written it as a function that’s called twice, once for each PDF rendition, so it’s easy to add or remove other renditions as you see fit. This script will be called from the Workflow Model, which we’ll look at next. Here’s the script code.

var renditionExtension = "pdf";
var mimeType = "application/pdf";

var workflowData = graniteWorkItem.getWorkflowData();

movePDF("print");
movePDF("web");

function movePDF (renditionPostfix) {
 if (workflowData.getPayloadType() == "JCR_PATH") {
 var path = workflowData.getPayload().toString();
 var resourceResolver = graniteWorkflowSession.adaptTo(Packages.org.apache.sling.api.resource.ResourceResolver);
 var resource = resourceResolver.getResource(path);
 if (resource !== null) {
 var asset = Packages.com.day.cq.dam.commons.util.DamUtil.resolveToAsset(resource);
 if (asset !== null) {
 var name = Packages.org.apache.commons.lang.StringUtils.substringBeforeLast(asset.name, ".");
 var renditionName = name + "_" + renditionPostfix + "." + renditionExtension;
 var rendition = asset.getRendition(renditionName);
 if (rendition !== null) {
 var renditionResource = resourceResolver.getResource(rendition.path);
 var stream = renditionResource.adaptTo(Packages.java.io.InputStream);
 
 var targetPath = asset.adaptTo(Packages.org.apache.sling.api.resource.Resource).getParent().getPath() + "/" + renditionName;
 var assetManager = resourceResolver.adaptTo(Packages.com.day.cq.dam.api.AssetManager);
 assetManager.createAsset(targetPath, stream, mimeType, true);
 } else {
 log.debug("rendition " + renditionName + " cannot be found on asset " + path);
 }
 } else {
 log.debug("Item is not an asset: " + path);
 }
 } else {
 log.debug("Item does not exist: " + path);
 }
 }
}

Workflow Model

There will be a new Workflow Model in your Workflows list called DAM Update Asset with PDF move located at /etc/workflow/models/dam/update_asset_pdf/. It is similar to and derived from the standard DAM Update Asset workflow that comes with every AEM installation. I have changed one existing step (Media Extraction) and added a new step (a Process step called “Move PDFs from Renditions”).

These two workflow steps are different from the standard DAM Update Assets workflow

These two workflow steps are different from the standard DAM Update Assets workflow

The Media Extraction step is designed to convert InDesign documents to other formats required by AEM Assets for a number of key functionalities. These include generating sub-assets (images that are embedded within the InDesign file), page images, extraction of text, and metadata synchronization, among other things. Media Extraction sends the script (and a pointer to the InDesign file) as its payload to InDesign Server. InDesign Server then runs the script and returns something to AEM. It is important that you do not remove any of the existing scripts that Media Extraction launches, but you can always add additional steps. Here, we added two additional scripts to the workflow step: PDFExport_Print.jsx and PDFExport_Web.jsx

The Print and Web PDF Export scripts have been added to the Media Extraction Workflow Step.

The Print and Web PDF Export scripts have been added to the Media Extraction Workflow Step.

Immediately after Media Extraction, I added a new Process step that executes an ECMA script in AEM. For many users, they will access AEM Assets via their desktop using the AEM Assets Companion tool or the Creative Cloud Desktop tool, so this workflow ensures that they get the renditions they need in a place that’s easy to find. Also, users of AEM Assets will be able to search for these PDFs like any other asset under management. This script copies the PDFs from /renditions as new assets adjacent to the InDesign file. It is best to leave the PDFs in /renditions so that they can be used by components that might offer the PDF as a download, for instance.

Process_Step

The new Process step executes an ECMA script that copies the new PDF files so that they are accessible on the desktop.

Workflow Launcher

Lastly, it is necessary to change the Workflow Launcher that is triggered whenever a file appears in the repository or whenever a file is modified in the repository. I did not include this change in the package so that you can install the package with no impact on your running system. When you are ready and have tuned the scripts for your workflow, then you can enable the Workflow in the Workflow Launcher panel.

In your AEM Author instance, click on Tools>Workflow>Launchers or visit http://localhost:4502/libs/cq/workflow/admin/console/content/launchers.html (of course, point at your Author instance!). Select the /content/dam(/.*/)renditions/original that has no condition on it (see screenshot below) and click on View Properties, and then on Edit.

Select the proper Launcher and view its properties

Select the proper Launcher and view its properties

The Launcher is designed to run a workflow when a specific condition is met. This workflow looks for any file that appears in the repository and then runs the DAM Update Asset workflow on it. You need to change the workflow to DAM Update Asset with PDF Move and then Save the changes.

Change the workflow that is triggered by the Launcher

Change the workflow that is triggered by the Launcher

Once you’ve saved the Launcher, you are ready to test. Upload an InDesign document into AEM using your preferred method. You can use drag and drop in a Browser window, AEM Assets Companion, or CC Desktop Tool. If you happen to catch the InDesign Server console, you will see new entries that report on whether IDS was successful at exporting PDF renditions. In a short while, your new PDF  files will magically appear next to the InDesign file. Now, go ahead an edit that InDesign file and save it back to AEM Assets. Again, the workflow will run and new PDF files will replace the existing ones, ensuring that you always have access to the latest versions. And, since they are assets under management, you can always revert to earlier versions of the PDF by looking at the asset timeline in a browser.

Conclusion

This new workflow and the scripts that support it expose a new behavior for AEM Assets. While convenient for the user, since it automatically generates useful and necessary derivatives of the source InDesign asset, it enforces known good business processes by encapsulating approved PDF Export settings into he workflow. It also reduces errors by automating a task that otherwise would require several configuration steps in InDesign before they could export the PDF.

I hope that you find this useful, and that you use it as a starting point for further InDesign Server automation using AEM Assets.

Share on Facebook