Home > Forum > Plugins > Merging PDFs as an action in process

Merging PDFs as an action in process
1

Hello webcon Community,

currently I'm working on a process design which includes the automatic report generation from webcon as a PDF file.
Additionally the process does always comes with an user-attached PDF file.

My goal now is to merge/combine both files together into one final PDF for storage.

Searching online i only found this source related to my problem:
https://community.webcon.com/posts/post/sdk-actions/143
..which briefly states "Merging several PDFs into one" could be possible.

Does anyone know more about this topic and could help me with that problem?

Thanks in advance,
Philipp

Hi Philipp,
Using SDKs

Please take a look at PDFSharp library http://www.pdfsharp.net/pdfsharp_license.ashx?AspxAutoDetectCookieSupport=1.
Few examples of merging PDFs http://www.pdfsharp.net/wiki/concatenatedocuments-sample.ashx.

There is also portal for developers https://developer.webcon.com/docs/create-your-first-plugin/ with tutorials.
Best way to parameterize the action is to use SQL querry which retuns ATT_IDs.

In order to use SDK addons you have to acquire SDK licence or order addon from Webcon or Webcon's partner.

I can give you some more details on implementing if you choose to go this way.

MVP

Stumbled up on a similar requirement for a new bid we are working on.

The requirement is, that a user can select existing attachments (pdf and office documents) and merge them all to a single pdf.

Was thinking about creating a mini-workflow that can be executed in a modal dialog. Does not change the fact, that we need to create a custom action to convert/merge the documents.

MVP
In reply to: Thomas Dengler

Hi,

we are also looking for such a functionality.

---------------The best way would be to have it as "PDF merge" action.----------------

In our case we have the SDK license. @Philipp it would be great, if we could get some more details on implementing.
Thanks a lot

Best regards
Thomas

Hi,

I did once a small PoC and maybe you can amend the logic:
I used PdfSharpCore


using PdfSharpCore.Pdf;


your logic:

using (var targetDoc = new PdfSharpCore.Pdf.PdfDocument())
{

foreach (var file in ATTACHMENTS)
{
using (var sourceStream = new MemoryStream(Base64Decode(ATTACHMENTS.CONTENT.AS.BASE64)))
using (var document = PdfSharpCore.Pdf.IO.PdfReader.Open(sourceStream, PdfSharpCore.Pdf.IO.PdfDocumentOpenMode.Import))
{
for (int i = 0; i < document.PageCount; i++)
{
targetDoc.AddPage(document.Pages[i]);

}
}
}
using (var targetDocStream = new MemoryStream())
{
targetDoc.Save(targetDocStream, false);
using (var reader = new StreamReader(targetDocStream))
{
targetDocContent = System.Convert.ToBase64String(targetDocStream.ToArray());
}
}
}

Best regards,
Daniel