Dealing with attachments when converting emails, InfoPath forms and merging documents
When we create or update our popular range of PDF converters, we don’t just phone it in, we talk to our customers and really go the extra mile to make sure that our software works exactly how they want it to work.
Let’s take the topic of attachments as an example. For many years we have supported various file formats that may contain attachments, for example emails, InfoPath forms, and PDF files containing attached files. Historically, before release 10.0, we provided two options to deal with these attachments.
-
Convert all attachments to PDF, and merge them to the output PDF.
-
Or ignore all attachments.
This served most of our customers well, but from time to time our support desk reported ’ annoying customers who wanted something not supported by the product’, specifically in the area of how our software deals with attachments. We don’t like to disappoint our customers - which is why we get such great reviews - so as of version 10.0 of the Muhimbi PDF Converter for SharePoint (on premise), Muhimbi PDF Converter Services, and the Muhimbi PDF Converter for SharePoint Online, the following facilities are available to deal with attachments.
-
Convert attachments to PDF, and merge them - alongside the main document - into a single PDF (Legacy behaviour).
-
Convert attachments to PDF, but store them in the main PDF output file as PDF attachments.
-
Convert the main file to PDF, but store the attachments in their original format in the PDF.
-
Control how unsupported or corrupt attachments are dealt with, either fail the entire conversion, ignore the attachments, or store the attachment in its original file format in the output PDF.
-
Control how small images are filtered out of emails. Emails tend to have loads of small attachments (twitter logo, company logos etc). As of version 10.0 the converter filters out any image based attachments (excluding TIFFs) that are smaller than 150 pixels in width or height.
To illustrate how this functionality can be used in the real world, have a look at the following video created by our Clavin. He uses MS-Flow - but it works the same for our other supported platforms - to convert emails to PDF and control how the attachments are processed.
As our software is very flexible, this new behaviour can be controlled via several mechanisms. Details can be found below.
Conversion Service’s Config file
The conversion service’s behaviour can be controlled globally via its config file. Any changes made here apply to all operations unless overridden at the individual request level. For details about where to find, and how to edit, this config file, see this Knowledge Base article.
The relevant config settings are as follows:
For PDF source files containing attachments
<!-- Convert, and merge, files that are attached to the PDF? --> <add key="PDF.ConvertAttachments" value="False"/> <!-- What to do with attachments after conversion (Only used when PDF.ConvertAttachments is enabled). * RemoveAll - Convert and delete all files attached to the PDF, even file formats not supported by the converter. * RemoveSupported - Convert and delete all files supported by the PDF converter, but leave unsupported files attached. --> <add key="PDF.ConvertAttachmentMode" value="RemoveAll"/> <!-- How to deal with the automatic generation of 'Named Destinations' using the PDF's Bookmarks. The default value is 'None'. * None - Make no change to the named destinations defined in the document. * ClearAll - Remove all named destinations. (All bookmarks pointing to existing named destinations will be fixed up automatically) * Merge - Keep existing named destinations and add new ones based on the PDF's bookmarks. * Replace - Remove all existing named destinations and add new ones based on the PDF's bookmarks. --> <!-- How to deal with attachments if the source PDF contains any. * Default - Legacy behaviour, attachments are converted to PDF and merged into the main PDF. See PDF.ConvertAttachments and PDF.ConvertAttachmentMode. * Merge - Supported attachments are merged to the output PDF. Unsupported attachments are handled according to PDF.UnsupportedAttachmentBehaviour. * AttachAsPDF - Supported attachments are converted into PDF and attached to the output document. Unsupported attachments are handled according to PDF.UnsupportedAttachmentBehaviour. * AttachOriginal - All attachments are attached to the output document in their original format --> <add key="PDF.AttachmentMergeMode" value=""/> <!-- What to do with unsupported attachments (for PDF.AttachmentMergeMode = 'Merge' or 'AttachAsPDF'). The default value is 'Error' * Error - An error is raised when unsupported attachments are found. * Remove - The unsupported attachments are ignored and not included in the output file. * AttachOriginal - Unsupported attachments are attached in their original format. --> <add key="PDF.UnsupportedAttachmentBehaviour" value=""/> <!-- If 'true' then merging the attachments will return an error message in case any error occurs. If 'false' then error pages are added to the output document --> <add key="PDF.BreakMergeOnError" value=""/> <!-- Control which attachment types to include. Specify either an empty value to include all or specify values in a comma separated list using standard wildcard expressions (e.g. *.docx, tmp???.xls).--> <add key="PDF.IncludeAttachmentTypes" value=""/> <!-- Control which attachment types to exclude. Specify either an empty value to exclude all or specify values in a comma separated list using standard wildcard expressions (e.g. *.docx, tmp???.xls).--> <add key="PDF.ExcludeAttachmentTypes" value=""/>
For InfoPath forms containing attachments
<!-- Enable or disable the conversion of Infopath attachments. --> <add key="InfoPathConverterFullFidelity.ConvertAttachments" value="true"/> <!-- How to deal with attachments if the source InfoPath file contains any. * Default - Legacy behaviour. If InfoPathConverterFullFidelity.ConvertAttachments is true then attachments are merged into the output file and unsupported attachments are removed * Merge - Supported attachments are merged to the output PDF. Unsupported attachments are handled according to InfoPathConverterFullFidelity.UnsupportedAttachmentBehaviour * AttachAsPDF - Supported attachments are converted into PDF and attached to the output document. Unsupported attachments are handled according to InfoPathConverterFullFidelity.UnsupportedAttachmentBehaviour * AttachOriginal - All attachments are attached to the output document in their original format --> <add key="InfoPathConverterFullFidelity.AttachmentMergeMode" value=""/> <!-- What to do with unsupported attachments (for InfoPathConverterFullFidelity.AttachmentMergeMode = 'Merge' or 'AttachAsPDF'). The default value is 'Error' * Error - An error is raised when unsupported attachments are found. * Remove - The unsupported attachments are ignored and not included in the output. * AttachOriginal - Unsupported attachments are attached in their original format. --> <add key="InfoPathConverterFullFidelity.UnsupportedAttachmentBehaviour" value=""/> <!-- If 'true' then merging the attachments will return an error message in case any error occurs. If 'false' then error pages are added to the output document --> <add key="InfoPathConverterFullFidelity.BreakMergeOnError" value=""/> <!-- Control which attachment types to include. Specify either an empty value to include all or specify values in a comma separated list using standard wildcard expressions (e.g. *.docx, tmp???.xls).--> <add key="InfoPathConverterFullFidelity.IncludeAttachmentTypes" value=""/> <!-- Control which attachment types to exclude. Specify either an empty value to exclude all or specify values in a comma separated list using standard wildcard expressions (e.g. *.docx, tmp???.xls).--> <add key="InfoPathConverterFullFidelity.ExcludeAttachmentTypes" value=""/>
For Emails containing attachments
<!-- The default value for converting attachments. --> <add key="MSGConverterFullFidelity.ConvertAttachments" value="True"/> <!-- Specify whether the attachment filenames are displayed in the email header. This setting works independently from ConvertAttachments. --> <add key="MSGConverterFullFidelity.DisplayAttachmentSummary" value="True"/> <!-- How to deal with attachments if the source email contains any. * Default - Legacy behaviour, attachments are converted to PDF and merged into the main PDF. See MSGConverterFullFidelity.ConvertAttachments and MSGConverterFullFidelity.BreakOnUnsupportedAttachment * Merge - Supported attachments are merged to the output PDF. Unsupported attachments are handled according to MSGConverterFullFidelity.UnsupportedAttachmentBehaviour * AttachAsPDF - Supported attachments are converted into PDF and attached to the output document. Unsupported attachments are handled according to MSGConverterFullFidelity.UnsupportedAttachmentBehaviour * AttachOriginal - All attachments are attached to the output document in their original format --> <add key="MSGConverterFullFidelity.AttachmentMergeMode" value=""/> <!-- What to do with unsupported attachments (for MSGConverterFullFidelity.AttachmentMergeMode = 'Merge' or 'AttachAsPDF'). The default value is 'Error' * Error - An error is raised if unsupported attachments are found. * Remove - The unsupported attachments are ignored and not included in the output. * AttachOriginal - Unsupported attachments are attached in their original format. --> <add key="MSGConverterFullFidelity.UnsupportedAttachmentBehaviour" value=""/> <!-- If 'true' then merging the attachments will return an error message in case any error occurs. If 'false' then error pages are added to the output document --> <add key="MSGConverterFullFidelity.BreakMergeOnError" value=""/> <!-- Control which attachment types to include. Specify either an empty value to include all or specify values in a comma separated list using standard wildcard expressions (e.g. *.docx, tmp???.xls).--> <add key="MSGConverterFullFidelity.IncludeAttachmentTypes" value=""/> <!-- Control which attachment types to exclude. Specify either an empty value to exclude all or specify values in a comma separated list using standard wildcard expressions (e.g. *.docx, tmp???.xls).--> <add key="MSGConverterFullFidelity.ExcludeAttachmentTypes" value=""/>
XML override
For Nintex Workflow, SharePoint Designer workflows, Microsoft Flow and REST API requests, it is possible to specify Muhimbi’s XML override syntax on a request by request basis. As it is not feasible to have a a switch in our user interface for every imaginable tweak or setting, we allow settings to be passed in via XML.
It is this technique that is used in the video in the introduction of this post. There are literally hundreds of settings, exact details can be found in the Developer Guide.
An example, to control the conversion of email attachments during PDF Conversion, is as follows:
<Override> <ConversionSettings> <ConverterSpecificSettings type="ConverterSpecificSettings_MSG"> <ConvertAttachments>true</ConvertAttachments> <AttachmentMergeMode>Merge</AttachmentMergeMode> <DisplayAttachmentSummary>true</DisplayAttachmentSummary> </ConverterSpecificSettings> </ConversionSettings> </Override>
Via SOAP API
The on-premise version of the Muhimbi PDF Converter comes with a rich SOAP based web service, as well as plenty of sample code. For details see our GitHub repository.
The object model, classes and properties can be found in the Developer Guide.
As always, if you have any questions leave a comment below, or contact our friendly support team.
Clavin is a Microsoft Business Applications MVP who supports 1,000+ high-level enterprise customers with challenges related to PDF conversion in combination with SharePoint on-premises Office 365, Azure, Nintex, K2, and Power Platform mostly no-code solutions.