Code breaks across multiple pages in PDF output
Asked by Joe Wojak:

Hi,

I'm using the code macro. When I create a PDF with the default Confluence settings, near the end of the code block the code breaks across 2 extra pages.

The odd thing is the page break starts more than halfway up the page. The empty space contains more than enough room for my remaining code, its just 3 lines.

What causes these excessively large page breaks and is there a fix for it?


Answers:
author: Joe Wojak
body: I found out this is a known bug in our version. The systems team has an upgrade scheduled.

comments: author: Erik S?derstr?m
body: Do you have a link you can share to the information about this known bug?


author: Darren Tonnessen
body: Was there a bug # that we could track from?


author: Aleksandr Beslik
body: Hello

Tell me please if the issue is fixed?   
I'm using version 5.4.3, and the error is present and prevents me to live ...


author: Jakob Skwarski
body: This is still an issue.


author: Steve Meiers
body: June 2017 and we're now running v6.1 and this is STILL an issue. My workaround is to manually break the code into page size blocks and tag the start with "cont." on the first line of each page that follows. Cludgy, but what else can we do, It makes is a mess to do HTML and PDF. I wish this bug would get resolved. Some of our long code blocks run fine and paginate beautifully, over three pages. Most not. DOH! A three year bug! HELP!


author: Davin Studer
body: What version of Confluence are you using? I use the code macro and don't see that when I export to PDF. Have a look at your page source. Is there anything there that could be doing it? You'll need this plugin to see the source easily.

[](https://marketplace.atlassian.com/plugins/com.atlassian.confluence.plugins.editor.confluence-source-editor)<https://marketplace.atlassian.com/plugins/com.atlassian.confluence.plugins.editor.confluence-source-editor>

comments: author: Joe Wojak
body: Hi Davin,

Thanks for the advice.

Regarding Confluence, we're using version 5.1-OD-6. This would indicate we have an "on-demand" version, but we migrated off that to hosted. This is kind of an odd set up. However, I'm not sure this is the problem. Other blocks of code in the code macro don't behave this way. Perhaps it's the length. The original code block is 77 lines long. I'll try with different code.

I did download the source plugin (great recommendation), however there's nothing unusual in the code that would inidcate "insert a weird page break here."

```
//more code above"user": {        "id": "xxxx",        "buyeruid": "xxxxx",        "data": [{            "id": "ABC",            "name": "XXXXX",            "segment": [{                "id": "ABC-123"            }]        }],        "at": 2,        "tmax": 30,        "wseat": ["1", "2"],		"cur": ["USD"], //breaks to new page here        "bcat": ["IAB1", "IAB1-2"],		"badv": ["advertiser.com"]     }}]]></ac:plain-text-body></ac:macro>
```

What's weird here is the macro appears to be inserting the double \]\] brackets before the closing angle \> on the next to last line.


author: Davin Studer
body: The brackets are fine. That is part of the CDATA block ... it's and XML thing.  

\<ac:macro ac:name="code"\>  
\<ac:parameter ac:name="linenumbers"\>true\</ac:parameter\>  
\<ac:parameter ac:name="language"\>js\</ac:parameter\>  
\<ac:plain-text-body\>\<!\[CDATA\[\]\]\>\</ac:plain-text-body\>  
\</ac:macro\>

Not sure what to tell you if you don't see anything in the source that could be causing it. Maybe try rebuilding the page. Cut and past the content in notepad to strip and formatting and then rebuild it from scratch and see if it goes better.


author: Erik S?derstr?m
body: We are experiencing the same issue here with code blocks spanning several pages ending with empty pages and the last two lines of code being put on the last page. We're currently running Confluence 5.4. Does anyone know if there is an ETA on the fix from the "systems team" Joe mentioned above? And is that the Atlassian systems team by the way?


author: Joe Wojak
body: I opened a ticket with Atlassian support. They indicated this problem is a confirmed bug and could be fixed by upgrading to the latest version. We haven't had a chance to perform the upgrade yet to verify.


author: Erik S?derstr?m
body: Thanks for the speedy reply Joe.

We have had this bug since 3.1.1 and it is still present in 5.4 which we are running now. The latest version that I know of is 5.4.4, so if they fixed it between 5.4 and 5.4.4 that would be incredible.

I just read through all release notes from 5.4.1 to 5.4.4 and there is no mention of this bug being fixed unfortunately. I suppose we will update to 5.4.4 and test it, in case it was fixed and just not added to the release notes.


Tags: code-macro

macro

pdf-export