PDF-Export. Images that doesn?t fit on the same page always starts on a new page
Asked by Thomas Zobel:

PDF export:

Images that doesn t fit on the same page after any element (headline, paragraph... ) always starts on a new page.

Can I avoid this?


Answers:
author: dleng
body: Based on this documentation:<https://confluence.atlassian.com/display/DOC/Customising+Exports+to+PDF>

You will need to modify the attributes for the image elements, e.g.

```
img{ page-break-inside: avoid;-fs-fit-images-to-width: 6in; }
```

set *page-break-inside* to**auto** . (A value of **avoid** instructs the browser to start the element on the following page if there is not enough room for it on the current page)

Additional references: [http://msdn.microsoft.com/en-us/library/ie/cc304067(v=vs.85).aspx](http://msdn.microsoft.com/en-us/library/ie/cc304067%28v=vs.85%29.aspx)

comments: author: dleng
body: If that don't work, maybe you can apply some form of CSS (im not very good at css, you gotta find a solution yourself) that constrains the size of the image to its parent element. (so it doesn't overflow and do a page break)


author: Thomas Zobel
body: It don't work, so i have to try another solution.


author: Trupti Kanase
body: This solution does not work.. Is there any other solution available to resolve this issue?


author: Steffen Heller
body: @Anselmo: Better control for page breaks

In CSS you can use selectors to define elements more specifically. At <http://www.w3.org/TR/CSS2/selector.html#adjacent-selectors> you find an example:
> E + F -\> Matches any F element immediately preceded by a sibling element E.

So if you want to avoid page breaks between headlines and images you can use something like:

```
h1+img {page-break-before: avoid;}
```

But beware, it is not that simple. Always check the real html code because sometimes the image itself is inside another \<div\>, \<p\> or \<table\> and doesn't follow the headline directly or there is an unrecognized empty paragraph after the headline and so on...


author: Anselmo
body: Thanks, Steffen,

this is at least worth a try and may be useful in the majority of cases. I could explain all other phenomena and ask editors to handle their code adequately.

An even better solution, which analyses a preview completely to improve its look and feel may be used within Acrobat, although it is additional effort.

My special interest is a wiki wiki way of exporting pdf in an idiot-safe manner, because it's not only me being told to do it. I'm just a good test candidate as an idiot :-)


author: Anselmo
body: Hi Thomas,

Hi Atlassians,

I face a related problem in pdf-export. We often have page breaks between headlines and pictures belonging to this headline. There is no setting implemented so far, that standard text and pictures may break, but headlines and the following paragraph or picture not. This would hopefully lead to a page break before the headline and keep content together, which belongs together just by definition of the previous paragraph's format.

Another help to reduce the number of bad looking page breaks could be the choice between portrait or landscape pdf-export. If your article deals with many screenshots and little text (easy to translate!), a landscape format uses the page space much more efficiently and keeps most screenshots easy to read (bigger).

Many users still love to put printed documentation rather on shelves than reading it online. So making better use of page space is an ecological point too.


author: William Zanchet [Atlassian]
body: Hi Thomas,  

I took the liberty to raise a feature request for you, about this problem, as you can see here:  
<https://jira.atlassian.com/browse/CONF-27654>  

I did a test in my local environment and I was able to reproduce the same behavior that you're facing there.  
I would strongly suggest that you vote on this feature request to increase its popularity and add it to your watchlist for future updates.  

Cheers,  

WZ


Tags: css

pdf