Merge PDF "Error: End-of-File, expected line"

In Microsoft Flow, I am using the Create PDF from HTML action to create PDFs from the attached files, which creates each document successfully. Then I adding the file contents to an array and using the Merge PDF action to create a single PDF. However, the Merge PDF action fails with error "Error: End-of-File, expected line". Any ideas for what is happening here?

Hello @physics515,

Please share with me the MS flow screenshot and , if it’s possiblde, the source documents. You can send them as a private message.

Best regards,
Petr Bushuev
Plumsail Team

No, I can’t share them as they are proprietary company files. I can test it again with different files later today and see if I get a similar result.

However, the part that is confusing is that the “Convert to PDF” action has no problem converting the original files to PDF. It is the “Merge PDF” action that is giving me the error. So, it would seem to me that it is a problem with the PDFs generated by PlumSail that is throwing the error, not the original files.

That or I guess it could be a problem with the array that I am using to construct the merge function. I will run non-proprietary files through it and give you the result.

1 Like

I have the same error code when adding a watermark to a PDF. Here is the flow (as you have described in the article)

and here the complete message after the flow runs an error.

{
"statusCode": 400,
"headers": {
"Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload",
"Referrer-Policy": "strict-origin-when-cross-origin",
"Timing-Allow-Origin": "*",
"x-ms-apihub-cached-response": "true",
"x-ms-apihub-obo": "false",
"Date": "Wed, 03 Jan 2024 07:57:00 GMT",
"Content-Length": "332",
"Content-Type": "application/json"
},
"body": {
"request": {
"url": "/flow/v1/Documents/jobs/AddWatermarkToPdf",
"traceId": "400621c2-0000-fd00-b63f-84710c7967bb"
},
"error": {
"code": "Invalid format of the message",
"message": "The document content empty. Please fill the data in and try again",
"date": "2024-01-03T07:57:00.5938587Z"
}
}
}

Any idea why? I tryed empty pdf's also different color and possitions...

So I found the issue: The files were indeed corrupt.

The Files are mostly corrupt if you don't get the attachments properly (from Forms or Emails). Using the attachments directly from the trigger only works in Azure logic apps; for power automation, you usually have to add a step to collect the attachment.
It is described well here.
Power Automate save email attachment to SharePoint - SPGuides

1 Like

Hello Andy and thank you for sharing the solution! It helps indeed to other users.