How to center all pictures on a page once?
Asked by maria liseenkova:

I usually use the tool on the user panel to center each picture. It is more or less fine, but I have problems while pdf export. Some of the pictures a left centered. I don\`t know why. Sometimes I use html command "text-align: center" for a picture, it helps but not for every picture. On the confluence page it is centered, everything is fine.

Is there any command to make all the pictures centered and have them the same after pdf exporting? Or it is possible to solve this problem using some tools?


Answers:
author: Bill Bailey
body: One tool to help diagnosis the issue is the [confluence-source-editor](https://marketplace.atlassian.com/apps/1210722/confluence-source-editor?hosting=server&tab=overview). This tool will allow you to look at the XHTML source of the page to see if the images that are not centering on PDF export are some how inserted differently than other, for example, inside div or span tags, or non-breaking spaces ahead of the image, etc.

If you see differences, but not sure what to do, you can paste the code here, both one that centers and one that does not. Then we (the community) can try to give you more guidance.

comments: author: maria liseenkova
body: 2 cases are attached below (pdf output and the source codes). On the confluence page all the pictures are centered.

![1 in pdf.png](https://community.atlassian.com/t5/image/serverpage/image-id/33559i63621C23DCA4F743/image-size/large?v=v2&px=999 "1 in pdf.png")![1.png](https://community.atlassian.com/t5/image/serverpage/image-id/33560iE4D339233979B253/image-size/large?v=v2&px=999 "1.png")![2 in pdf.png](https://community.atlassian.com/t5/image/serverpage/image-id/33558i345FC444AAE2CEE6/image-size/large?v=v2&px=999 "2 in pdf.png")![2.png](https://community.atlassian.com/t5/image/serverpage/image-id/33557i8371B7A3351CE07F/image-size/large?v=v2&px=999 "2.png")


author: maria liseenkova
body: I see only one way -- leave empty line between text and picture and center this line. It works. Is there any other way?


author: Bill Bailey
body: One thing that sticks out at me is that the images look like they were pasted into the Confluence page, rather than linked to either an attachment on the page or another page within Confluence. I have seen strange behavior with pasted images.

For example, this is what I would have expected to see for an image correctly inserted and centered

```
<p>
? <ac:image ac:align="center" ac:height="436" ac:width="593">
??? <ri:attachment ri:filename="worddavae7a5f7d81588469b7c82fa3b8a63ce1.png"/>
? </ac:image>
</p>
```

In the first instance, I see you have text in front of the image, followed by \<br\> tag before the ac::image tag -- that will cause problems. So it should appear as:

```
<p>a bunch of text ... (<<RESET>>)</p>
<p>
? <ac:image ac:align="center">
??? <ri:url ri:value="...."/>
? </ac:image>
</p>
```

The reason the second instance worked was because the parent p tag was also centered aligned.

```
<p style="text-align:center;">a bunch of text ... )<br>
? <ac:image ac:align="center">
??? <ri:url ri:value="...."/>
? </ac:image>
</p>
```

Hope this helps.


author: maria liseenkova
body: Thank you for your reply!

I\`ll try to find a proper way to insert pics. Some of the pictures were imported with the document from a word file. I found pictures with the same code as you wrote, but they had the same problem with centering in pdf. I guess \<p\> value is a priority for pdf exporter, so pictures have the same characteristics as a text above. I started to make a new line, then insert a picture. It works. For now I see this as the only way.


author: Bill Bailey
body: If if works, please give a vote or accept the answer, please. ;-)


Tags: confluence-server

data-center

export

image

pdf

server