I have a Power Automate workflow which takes fields from Sharepoint lists and puts them into a pdf using the Compose action to create HTML and then convert to a pdf. There are a bunch of conditions within the Compose action such as:
if sharepoint_field = 'Yes' then 'Show this' else ''
Since I have a bunch of these blank strings, it is adding a lot of random whitespace between text in the final output. Is there a way I can remove the whitespace and blanks that are added due to all the conditions after the Compose action in Power Automate before it is converted to a pdf?
These if then else statements are in separate
tags and wrapping each of them in a trim still creates line breaks so I'm guessing the cleaning up of whitespace will have to happen after the compose action
This is what the expressions look like:
<p><b> trim(if(equals(outputs('Get_item')?['body/SharepointField/Value'], 'Yes'), 'Details:',''))
</b> <span...> trim(if(equals(outputs('Get_item')?['body/SharepointField/Value'], 'Yes'), outputs('Get_item')?['body/SharepointField'],''))</span></p>
So inside the <b> tags is the Question, and I want it to print the Question only if SharepointField Value is 'Yes' then inside the span tags is the answer if Sharepoint Field value is 'Yes', if it gets to the else tag then it is just a blank. so multiple of these blanks add up and create a bunch of blank space in my final pdf.


Thanks for the update to the question. You are going to have to add all your html in the if statement....
Leaving the below just in case it helps others...
I suspect it isn't the blank strings in the if statements, but the white space between your tags in the Compose action. Sharing a screen shot of your Compose would be helpful.
For example, the blue "-" is a line break, the blue "|" is a space
So maybe look to remove all white space between your tags, and add the required whitespace within your if statements. Like:
And your if statement could then be like:
or if needing a line break: