Opened 18 years ago

Last modified 11 years ago

#731 confirmed Bug

0 border tables have a border when sent to a printer

Reported by: rhum1@… Owned by:
Priority: Normal Milestone:
Component: General Version: FCKeditor 2.5.1
Keywords: SF Cc: Frederico Caldeira Knabben

Description

fck_showtableborders_gecko.css defines the rules to show border="0" table borders on Gecko when editing. But those borders are present if you send your document to a printer, which is not a good thing... I link a patch i use for this file to hide the border="0" tables border on a printer.


Moved from SF:
http://sourceforge.net/tracker/index.php?func=detail&aid=1491546&group_id=75348&atid=543653

Attachments (1)

fck_showtableborders_gecko.css (2.0 KB) - added by Martin Kou 18 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 18 years ago by Martin Kou

Reporter: changed from Martin Kou to rhum1@…

I was able to have the same result by simply using "@media screen" for the current contents actually.

But it doesn't solve other things, like the anchor icon, for example.

More investigation will be done in this sense. For now, it is better to have the same output visible in the editor when printing, instead of having a mixture of final layout and current editor layout.


Moved from SF. Original poster: fredck

Changed 18 years ago by Martin Kou

comment:2 Changed 17 years ago by Wojciech Olchawa

Keywords: Confirmed added
Version: FCKeditor 2.5.1

comment:3 Changed 17 years ago by Wojciech Olchawa

Confirmed on IE and FF2 Windows.

comment:4 Changed 15 years ago by Wiktor Walc

This is still a problem in the latest version of CKEditor.

comment:5 Changed 11 years ago by Jakub Ś

Problem can still be reproduced in latest CKEditor 4.3.1.

comment:6 Changed 11 years ago by Jakub Ś

Here is a workaround for iframed editor:

function hideBorderZeroOnPrint( classname ){								
				var node = editor.document.$.getElementsByTagName( 'body' )[0];//iframed editor				
				var elements = node.getElementsByTagName( 'table' );
				for( var i=0, len=elements.length ; i<len ; i++ ){
					var helper = elements[i].getAttribute('class');
					if(helper)
						elements[i].setAttribute('class', helper.replace(classname,''));
				}
			}			
			function showBorderZeroAfterPrint( classname ){								
				var node = editor.document.$.getElementsByTagName( 'body' )[0];//iframed editor				
				var elements = node.getElementsByTagName( 'table' );
				for( var i=0, len=elements.length ; i<len ; i++ ){
					var bor = elements[i].getAttribute('border');
						if(bor && bor == 0){
							var helper = elements[i].getAttribute('class');
							elements[i].setAttribute('class', helper ? helper.concat(classname) : classname);
						}
				}
			}		
			var editor = CKEDITOR.replace( 'editor1');
			editor.on( 'instanceReady', function( evt )	{
				editor.on('beforeCommandExec', function( event ){
					if( event.data.name == 'print' )
						hideBorderZeroOnPrint('cke_show_border');
				});
				editor.on('afterCommandExec', function( event ){
					if( event.data.name == 'print' )
						showBorderZeroAfterPrint('cke_show_border');
				});
			});		
Last edited 11 years ago by Jakub Ś (previous) (diff)

comment:7 Changed 11 years ago by Jakub Ś

This seems to work for inline editor:

<body onbeforeprint="hideBorderZeroOnPrint('cke_show_border');" onafterprint="showBorderZeroAfterPrint('cke_show_border');">
...

CKEDITOR.disableAutoInline = true;
		var editor = CKEDITOR.inline( 'editable' );
			function hideBorderZeroOnPrint( classname ){								
				var node = document.getElementsByTagName( 'body' )[0];//inline editor				
				var elements = node.getElementsByTagName( 'table' );
				for( var i=0, len=elements.length ; i<len ; i++ ){
					var helper = elements[i].getAttribute('class');
					if(helper)
						elements[i].setAttribute('class', helper.replace(classname,''));
				
				}
			}					
			function showBorderZeroAfterPrint( classname ){								
				var node = document.getElementsByTagName( 'body' )[0];//inline editor				
				var elements = node.getElementsByTagName( 'table' );
				for( var i=0, len=elements.length ; i<len ; i++ ){
					var bor = elements[i].getAttribute('border');
					if(bor && bor == 0)
					elements[i].setAttribute('class', elements[i].getAttribute('class').concat(classname));
				}
			}		

Please note however that onbeforeprint and onafterprint are only supported in Firefox and IE.

Last edited 11 years ago by Jakub Ś (previous) (diff)
Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy