The problem is that PDF uses fixed page sizes while HTML is a floating format rendering the content according to the size of the output window.
You have not specified which method you are using to generate the PDF. But such generation is usually a kind of printing. So you can use media specific CSS styles:
<html>
<!--
<link rel="stylesheet" type="text/css" media="all" href="css/general.css">
<link rel="stylesheet" type="text/css" media="screen, projection, tv" href="css/screen.css">
<link rel="stylesheet" type="text/css" media="print" href="css/print.css">
<!--
You can now define your styles for the left and right part in the
screen and
print files with different settings.
I have not tested it (and it may depend on the other content of your page), but you can try to set the height of the left and right parts to 100% for printing. Note that this requires setting the height of the
html
and
body
sections to 100% too:
html, body {
height: 100%;
}
div.left-part {
background-color: blue;
height: 100%;
}
div.right-part {
background-color: white;
height: 100%;
}
If this does not work try other settings. Overall using media specific styles makes it much easier to format the output for one media type without affecting others.
But note that the above also when a user is printing your page and would then get a blue background printed what is usually not wanted. Therefore, the above method is often used when having some kind of background to disable that when printing.