wkhtmltopdf vertical-align baseline ignored - wkhtmltopdf

I have the following html markup, where I want to use different font and fontsize for the first letter:
<table class="maintable">
<tr>
<td>
<span class='first-letter'>E</span>s war einmal ein Prinz, der auf der Suche nach der richtigen Frau war.
</td>
</tr>
</table>
I use the following CSS
body {
font-family: 'montserrat';
font-size: 3.5mm;
line-height: 6.0mm;
}
.first-letter {
font-family: 'arabesqueinitialen', Arial;
font-size: 15mm;
vertical-align: baseline;
}
.maintable td {
vertical-align: top;
text-align: justify;
}
If I run this in Chrome I get the following result:
which is exactly what I want.
But when I convert this with wkhtmltopdf I get this:
As you can see, the vertical alignment of the first letter is wrong.
Any ideas how to fix this?

I don't know if you still have the problem, but I had this same problem, the reason I found was that the element affected (image, table, chart, etc) was close to the page break, I think that with a <br> before your line would be enought.
Another way is specify where do you want your page break in the css file, like this
p{
page-break-inside:avoid;
}
.pagebreak {
page-break-after: always;
}
That way you won't have pagebreak inside paragraphs and can specify where do you want the page break with the class pagebreak.
If you still have problems with the vertical align, you can search in the WkHtmltoPdf GitHub page GitHub WkHtmlToPdf

Related

CKEditor Source Code Mode Copy

Any other suggestions?
When using CKEditor copying from one instance to another (with CTRL+C/V). You always get some changed source code. Even with Advanced Content Filtering enabled and only allowing a few plugins and content rules.
Check this example here (Code 1):
<p>nubosys GmbH ist ein
Infrastrukturanbieter und bietet für eine moderne Informations- und
Kommunikationstechnologie (ICT) das ideale Umfeld.<p>
CTRL+C/V in another instance becomes this (Code 2):
<p><span>nubosys</span> GmbH ist ein Infrastrukturanbieter und bietet
für eine moderne <span>Informations</span>-
und Kommunikationstechnologie (ICT) das ideale Umfeld.</p>
So what you see is that unnecessary span tags get inserted
When I monitor the clipboard I see this (Code 3):
So you see CKEditor does quit a good job filtering out things. But it is not 100% the same as in the original.
My approach would be to implement a source code based copy mode. So I am wondering if something like this does not exist already for CKEditor. My use case is to copy from one instance to another instance of the editor inside the CMS.
I case you want more background information. Here is the CKEditor Plugin for Orchard CMS we started: https://github.com/inteno/CustomCK/wiki/Introduction
How to force the user to copy the HTML Code from one instance to another (without source changes) with one click or by pressing CTRL+C/V.
When I use forcePasteAsPlainText: true, the problem does not occur, but the formatting is lost. I want a clean way to copy the formatting without changing the source.
Update:
In this fiddle http://jsfiddle.net/mjost/6rgo0udg/15/ the problem does not occur. CKEditor manages to filter out the bad code:
Version:0.9
StartHTML:0000000165
EndHTML:0000000886
StartFragment:0000000201
EndFragment:0000000850
SourceURL:http://fiddle.jshell.net/mjost/6rgo0udg/15/show/
<html>
<body>
<!--StartFragment--><p style="box-sizing: border-box; border-radius: 0px !important; margin: 0px 0px 10px; color: rgb(85, 85, 85); font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 20.7999992370605px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;">nubosys GmbH ist ein Infrastrukturanbieter und bietet für eine moderne Informations- und Kommunikationstechnologie (ICT) das ideale Umfeld.</p><br class="Apple-interchange-newline"><!--EndFragment-->
</body>
</html>
(http://freeclipboardviewer.com/)
But that is because there are no spans even in the clipboard.
Update 2:
The problem occurs here when I work with none breaking spaces:
http://jsfiddle.net/mjost/r34c7fLe/5/
HTML
<body>
<textarea id="cke1"><p>nubosys GmbH wurde 2011 von inteno ag und edicomp GmbH gegründet. nubosys GmbH ist ein Infrastrukturanbieter und bietet für eine moderne Informations- und Kommunikationstechnologie (ICT) das ideale Umfeld.</p>
</textarea>
<textarea id="cke2"></textarea>
</body>
JS
CKEDITOR.replace( 'cke1', {
forcePasteAsPlainText: false,
extraAllowedContent: 'span;'
} );
CKEDITOR.replace( 'cke2', {
forcePasteAsPlainText: false,
extraAllowedContent: 'span;'
} );
Updated Question:
According to the latest experiments I think it should be a Plugin that overwrites the default Copy&Paste and works on a Source Code base. Is this possible?
It appears to be some incompatibility between CKEditor and Chrome/Webkit. I'm not sure if you have any specific reason for that javascript. But forcePasteAsPlainText: false is redundant because that's default value. And extraAllowedContent: 'span;' is what's causing your problem with inserted spans.
If you don't need to set more options you can remove all javascript and just use class="ckeditor" on textareas to load editors on them.
Another way is to hit Source button on CKEditor's toolbar and copy the source directly, that is always 1:1 then you can hit Source button on second CKEditor and paste it there, again 1:1.
Does it still bug for you in this fiddle? http://jsfiddle.net/tfoaw743/1/

List item inline-block issue in IE8

I have a horizontal list of color swatches, and each list item has the following markup:
<li class="ws-filter">
<a class="ws-swatch-link" title="Black" href="#">
<div title="Black" class="ws-filter-swatch" style="background-color: #000000;"></div>
</a>
</li>
However, a selected color swatch has the following markup (no anchor tag):
<li class="ws-filter ws-selected">
<div title="Silver" class="ws-filter-swatch" style="background-color: #c0c0c0;"></div>
</li>
Here's the CSS:
.ws-filter-list .ws-filter {
display: inline-block;
}
.ws-filter-swatch {
width: 20px;
height: 20px;
border: 1px solid #dcdcdc;
margin: 2px;
}
And here's the JSFiddle: http://jsfiddle.net/nHk27/2/
This works just fine in most browsers, and looks like the following:
However, in IE8, the selected swatch pops out of line, like this:
This is a project I'm working on, and I can't change the markup. I've tried experimenting with changing the display of the div, anchor and list item in different combinations. I'm pretty sure I could get it to work using float, but is there any way to fix this without using float?
Try
vertical-align: middle;
I have a strong hunch IE8's default puts the content up on top.
Since you're not posting any relevant CSS, I can only suggest you to use IE hacks technique to target IE8 in your case, try something like this:
.ws-filter div[title="Silver"] {
margin-top: 20px\0/ /* or margin-bottom: -20px. The value here can changed based on your context */
}

Inside a div, I have an image, then paragraph, then image at the end. I can't get the second image to be 'inside' the paragraph

So, I have a div, and inside it I've got 3 things;
1. An image (a big left quotation mark)
2. a live text paragraph
3. another image at the end (a big right quotation mark).
The first image, when it's put in the div, causes the text to wrap, which is great. It appears to be part of the paragraph.
My issue: I can't get the second image to be 'inside' the paragraph at the end. It is pushed below the paragraph area. I want it to 'wrap' with my paragraph text.
#textarea {
width: 185px;
height: 70px;
padding: 49px;
}
#textarea p {
font-size: 15px;
font-weight: bold;
color: #4D6F79;
line-height: 230%;
text-align: center;
-webkit-margin-after: 0em;
-webkit-margin-before: 0em;
}
<div id= "textarea">
<img src="images/leftquote.png" width="36" height="43" alt="left quotation" align="left"/>
<p>The kids really loved it!</p>
<img src="images/rightquote.png" width="32" height="20" alt="right quotation" align="right"/>
</div>
Any help/ideas would be much appreciated! Thanks!!
I am not exactly sure what you mean by you want your second image in your paragraph but I know a decently easy and cheap way to use css to relocate your second image to be where you want...
First put an ID on your image:
<img id='image2' src="images/rightquote.png" width="32" height="20" alt="right quotation" align="right"/>
Then use CSS to reposition it:
<style>
#image2 {
position:relative;
top:-50px; // These numbers are just examples you can change them to anything to properly reposition your text.
left:20px;
z-index:-1; //depending on whether you want your image infront or behind the text you can change your z-index to either a positive number e.g.(5) or negative number e.g.(-2).
}
</style>
If you are worried about different formattings across different browsers they would not appar to be hugely different just off this positing but there is another way to do this if you are ok with wrapping your text around your image using overflow. Ex:
<div class='floating-eg'>
<p>The kids really loved it!</p>
<img class='left' src="images/rightquote.png" width="32" height="20" alt="right quotation" align="right"/>
</div>
<style>
.floating-eg {
overflow: auto;
}
p {
overflow: auto;
}
</style>
You can see a related example of wrapping here.

Left align text under an image (link) that floats right?

I have this image link:
<p class="alignright">
<a target="_blank" href="...">
<img width="230" height="158" align="right" style="margin-right: 30px; margin-top: 20px;" src="some_source" >
</a>
text should go here
</p>
The alignright class looks like that:
.alignright {
float: right;
margin: 4px 0 1px 10px;
}
Now I tried several things to place text below the above image link (I tried using a < br > and image captions for example), but everything failed. The text is either too far on the left, or its not even below the image link.
Any ideas how to get the text below the image link?
Thanks!
You mean that you want the text to be aligned to the left edge of the image link?
This means that you have to put both elements into one container and assign the float:left property to this one:
I guess that this is the "" I can see in your sample.
Did you make sure, that the width of the p-Element is the same as of the image link?
Otherwise the text would be aligned to the p-borders wherever they are on your page.
Shrink the size of the p-Element or put everything into an extra container:
<div style="float:right; width:#IMAGE_LINK_WIDTH#; text-align:left;">
IMAGE_LINK
<!-- A <br /> might be placed here -->
Text
</div>
after <p class="alignright"></p> tag put
<br style="clear: both;" />
some text here
Text will appear under the image.
Live Sample
Just add a span or a div with clear:both property and then align your text as you need.
EDIT:
If the text below the image is a link then just wrap the link inside a p tag like this
<p>Your Text</p>
By doing this your link will appear in the next line as p is a block element.
Block elements force line breaks before and after the position they are placed at.
See Demo
This is html file
<img src=""><span id="title" >your text</span>
This is css file
span#title {
text-align: center;
font-weight: bold;
}
span {
background: black;
bottom: 459px;
padding: 5px;
color: white;
opacity: 0.7;
position: absolute;
left: 8px;
width: 244px;
}
Try in this way

How to center text in an inline-block span on lte Firefox 2?

I have 3 spans inside a div.
text-align: center doesn't comply
text-align: -moz-center neither
I have to use spans
no floats
display: -moz-inline-block is working but the 2nd and 3rd spans clear left…
Anyone got an idea?
EDIT:
div{
width:80%;
display:table;
}
span{
width:33%;
display:table-cell;
text-align:center;
border:1px solid #F00;
}
Note that both the div AND span width need to be changed to adjust widths. The span should be 100/(no of spans)% and the div whatever width you want.
HTML
replace <span>text</span> by <p><span>text</span></p>
CSS
p {display:-moz-inline-stack;text-align:center}
span {display:block}
Just put some left and right padding on those spans?
So if you have something like this:
<div>
<span>some text</span>
<span>also some text</span>
<span>again here comes some text</span>
</div>
Just use it like this in your css:
span{
padding:0 10px;
}
Result will be something like this:
http://i48.tinypic.com/5knczm.jpg
Note, i added 1px border, so you would see that text is "centered"...

Resources