Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Images are note centered on PDF Export

Jens Kasperek (Bosch GmbH)
Contributor
November 24, 2015

This question is in reference to Atlassian Documentation: Customise Exports to PDF

We just migrated to Confluence 5.8.16. Unfortunately, we experience issues with the PDF export. We have some pages where images are centered and are displayed as centered, correctly. If we export them to PDF, images will be re-aligned to the left. Does someone know, if we can rewrite this behaviour ?

See also: https://jira.atlassian.com/browse/CONF-38632

3 answers

1 vote
Jens Kasperek (Bosch GmbH)
Contributor
November 26, 2015

We just found a pretty and smart solution for pictures that are either not centered or aligned to the right!


Append the following code to your PDF stylesheet:

span.confluence-embedded-file-wrapper {   
    display: inline-block !important;  
}


If not just images are affected, but other spans, you can embed the following:

p[style="text-align: center;"] span,  
p[style="text-align: right;"] span  
 {   
    display: inline-block !important;  
}


Issue Description


The actual issue is about the <span> tag that wraps the image. After centering an image with the editor, you have a construct like

&lt;p style="text-align: center;"&gt;&lt;span class="confluence-embedded-file-wrapper confluence-embedded-manual-size"&gt;&lt;img class="confluence-embedded-image" src="/xsystem/download/attachments/344041801/Koala.jpg?version=1&amp;amp;modificationDate=1448543356520&amp;amp;api=v2" data-image-src="/xsystem/download/attachments/344041801/Koala.jpg?version=1&amp;amp;modificationDate=1448543356520&amp;amp;api=v2" data-unresolved-comment-count="0" data-linked-resource-id="382009443" data-linked-resource-version="1" data-linked-resource-type="attachment" data-linked-resource-default-alias="Koala.jpg" data-base-url="https;//*/xsystem" data-linked-resource-content-type="image/jpeg" data-linked-resource-container-id="344041801" data-linked-resource-container-version="15" height="250"&gt;&lt;/span&gt;&lt;/p&gt;


The style 'text-align:center' will not be applied to the <img> tag due to the span tag which has this missing property: "display:inline-block;"


@Atlassian: Please provide this fix in an upcoming version!

0 votes
Attila Gaspar _META-INF_
Contributor
February 5, 2016

Hi @Jens Kasperek (Bosch GmbH),

I used Content Exporter addon (available in Cloud too) to export a test page and the alignment seems to be correct in PDF (see the attached picture)

BR: Attila

 

2016-02-06_10h31_31.png

 

0 votes
Steffen Heller
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 25, 2015

That is complicated.

Centering elements can be achieved with numerous methods. Search for "css image center" to see how many hints and tricks exist.

If your images are centered in the wiki page but not in the PDF you would have to examine

  • with what HTML and CSS code the images are centered in the wiki page
  • what Confluence CSS code is defined as standard behaviour for images in the PDF export

In the end you have to define your own customized CSS that

  • will work together with the HTML of the wiki page
  • overwrite the standard CSS code

To answer your question: Yes, you can rewrite this behaviour but it can take a while.

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, confluence whiteboards, whiteboard templates, template contest, visual collaboration, atlassian learning, confluence community, brainstorming tools, agile planning, team productivity, confluence templates, share your template

Share Your Confluence Whiteboard Template for a Chance to Be Featured in the Product! 🏆

Want to leave your mark on Confluence? One winner will have their whiteboard design added into Confluence for all users to access! This is your chance to showcase your creativity, help others, and gain recognition in the Confluence community.

Share your template today!
AUG Leaders

Atlassian Community Events