Special character not showing in html2pdf - html

I'm using html2pdf and trying to display in a pdf a checkmark, checkbox(checked), a tick mark...anything that resembles check sigh.
I've tried all the codes I could find :
☑✔ ✓ but all I'm seeing is '?'
$html2pdf = new HTML2PDF('P', 'A4', 'fr', true, 'UTF-8', 0);

There was a problem with the font not being able to show those symbols
What I've done is I've added 2 different fonts, Arial as default and dejavusans for symbols.
<style>span{font-family: dejavusans;}</style>
<span>☑</span>
$html2pdf->setDefaultFont('arial');
$html2pdf->AddFont('dejavusans');

Related

WTL CCommandBarCtrl imagelist (default and hot/disabled) ignored when set

I am trying to modify the images in a ribbon's Quick-Access-Toolbar but all my attempts seem to be in vain. I had the WTL-wizard create a simple ribbon-based application to start with. The wizard creates a CMainFrame with the a member var called 'm_CmdBar' of type 'CCommandBarCtrl'.
In 'CMainFrame::OnCreate()' the m_CmdBar is created with 'Create( m_hWnd, rcDefault, NULL, ATL_SIMPLE_CMDBAR_PANE_STYLE )' and the images are loaded with 'LoadImages(IDR_MAINFRAME)'. The images come from the default visual-studio provided 4-bit Bitmap toolbar-resource. If I leave 'LoadImages(IDR_MAINFRAME)' untouched, then the crappy 4bit icons are visible in the QAT.
Now, reading through the very sparsely only available WTL documentation (and Win32 API docu about about image lists) some people suggest to change the image list. I tried the following approaches (after commenting out 'LoadImages(IDR_MAINFRAME)' in order to start with a blank slate.).
1st attempt (load a 32Bit bitmap-strip with 5 16x15px consecutive icons):
CBitmap bmp;
bmp.LoadBitmap( IDB_TEST32BPP );
WTL::CImageList imgList = m_CmdBar.GetImageList();
imgList.Create( 16, 15, ILC_COLOR32, 8, 1 );
imgList.Add( bmp.m_hBitmap, RGB( 255, 255, 255 ) ); // also tried different masks
m_CmdBar.SetImageList( imgList );
imgList.Detach(); // also tried once without detaching
But to no avail. I tried to force the imagelist with:
m_CmdBar.SendMessage( TB_SETIMAGELIST, 0, (LPARAM)imgList.m_hImageList );
but it this did not work either.
2nd attempt is very much like the first, except that this time I changed the create call to:
imgList.Create( 16, 15, ILC_COLOR24 | ILC_MASK, 8, 1 );
in hope that maybe the loading code does not like 32bpp images... but again, no cigar (LoadBitmap was adjusted to load a 24bpp version of course). 3rd attempt was to simply reload the default images (4bit) so again I changed the create call to:
imgList.Create( 16, 15, ILC_COLOR4 | ILC_MASK, 8, 1 );
but you have guessed it... noting. And with nothing I actually mean, that the QuackAccess-Toolbar does reserve the space for the 5 buttons (as per the XAML ribbon config) but icons/images do not appear. The QAT-buttons are white but react to interaction. Trying to load the hot and disabled lists using the provided WTL-API also does nothing at all.
The only approach that worked somehow was to manually load every bitmap directly and linking it to its command with:
CBitmap bmp;
bmp.LoadBitmap( IDB_ICON1_32BPP );
m_CmdBar.AddBitmap( bmp.m_hBitmap, ID_TEST_BTN );
works as long as the XAML config correctly provides an entry in the QAT section for ID_TEST_BTN. AddIcon also works but introduces an artifact (a black vertical
1px-bar, as if a right-frame was drawn for every icon. I guess it's the 16x16 versus 16x15 pixel problem).
I might be inclined to give up and go with the AddBitmap-workaround, but I'd like the disabled and hot-version to work too, and there is no AddBitmap for that as it looks. Also, I guess there is no way to force an image to any of the QAT buttons via the XAML file???

How to prevent ckeditor to not add in blank html tag

I have Visual Studio 2012 Express installed in Windows 8.1 OS and using CKEditor in my project as per requirement.
I am new for CKEditor and using it in a proper way as well but the problem is by defining the html in source in CKEditor it replaces automatically
<div><i class="classname"></i></div>
with
<div> </div> or <div></div>
So How to prevent CKEditor not to replace it and save as it is?
I have got some solution but still little bit error I am replacing
<i class="classname"></i>
with
<div class="classname"></div>
but in between the tag it automatically add &nbsp.
How to prevent it to not add &nbsp?
Here in below image is CKEditor is open and you can see in rounded area it automatically adds some space or tab in my code.
How to stop that?
Have a look at this Post:
CKEditor unwanted characters
After some research I might shed some light on this issue -
unfortunately there is no out-of-the-box solution.
In the CKEditor there are four ways a no-break space can occur (anybody knows more?):
Automatic filling of empty blocks. This can be disabled in the config:
config.fillEmptyBlocks = false;
Automatic insertion when pressing TAB-key. This can be diabled in the config:
config.tabSpaces = 0;
Converting double spaces to SPACE+NBSP. This is a browser behavior and will thus not be fixed by the CKEditor team. It could be fixed
serverside or by a clientside javascript onunload. Maybe this php is a
start:
preg_replace('/\s \s/i', ' ', $text);
By copy&paste. If you paste a UTF-8 no-break space or double-spaces CKEditor will convert it automatically. The only
solution I see here is doing a regex as above.
config.forcePasteAsPlainText = true; doesn't help.
Summary: To get rid of all no-break spaces you need to write an
additional function that cleans user input.
Comments and further suggestions are greatly appreciated! (I'm using ckeditor
3.6.4)
EDIT #1
Have a look at this.
CKEDITOR.dtd.$removeEmpty.i= 0;
You can also can use this with span and other tags.
The documentation to this.
Stop Removing ANY Empty Tag in CKEditor
There is a defined list of tags that is going to be removed if
empty(see dtd.js and $removeEmpty or run CKEDITOR.dtd.$removeEmpty
from console).
From HTmL
To ensure the certain empty tag are not being removed, add attribute
‘data-cke-survive’:
<span data-cke-survive="true" ></span>
From Configurations
Or you can configure the particular tag from not be removed:
if(window.CKEDITOR){
CKEDITOR.on('instanceCreated', function (ev) {
CKEDITOR.dtd.$removeEmpty['span'] = 0;
CKEDITOR.dtd.$removeEmpty['TAG-NAME'] = 0;
}
}
By setting an element to 0 in the CKEDITOR.dtd.$removeEmpty, it
prevents the empty tags from being removed by CKEditor.
http://margotskapacs.com/
This topic can be helpfull https://stackoverflow.com/
In short- You can disable Automatic filling of empty blocks in the config:
config.fillEmptyBlocks = false;
more information- here
UPD.
You can try this config.protectedSource.push(/<i[^>]*><\/i>/g);
From official documentation
{Array} CKEDITOR.config.protectedSource Since: 3.0
List of regular expressions to be executed on input HTML, indicating HTML source code that when matched, must not be available in the WYSIWYG mode for editing.
config.protectedSource.push( /<\?[\s\S]*?\?>/g ); // PHP code
config.protectedSource.push( /<%[\s\S]*?%>/g ); // ASP code
config.protectedSource.push( /(]+>[\s|\S]*?</asp:[^>]+>)|(]+/>)/gi ); // ASP.Net code
UPD 2
Hope this will help.
CKEDITOR.on( 'instanceReady', function( ev )
{
// turn off excess line breaks in html output formatting for blockquote tag.
// In same way you can correct any tag output formating
ev.editor.dataProcessor.writer.setRules( 'blockquote',
{
indent : false,
breakBeforeOpen : false,
breakAfterOpen : false,
breakBeforeClose : false,
breakAfterClose : true
});
});
For the one who are using UniSharp/laravel-ckeditor
<script>
var options = {
fillEmptyBlocks: false,
};
CKEDITOR.replace( 'content', options);
</script>

Japanese text in TextField with embedded font

In my ActionScript 3 project I use TextField with embedded font set to true and isHTML set to true. Everything works fine when I display latin characters.
But when I want to display Japanese characters they do not appear. Actually it is expected to be like this because Japanese font is not embedded.
Is there is a way to fall back to system font if embedded font doesn't have glyphs for certain characters?
Try to use hasGlyphs("..."); on a Font instance. I had some problems with it but in general it works alright, hopefully it works for Japanese too. Then you can simply use _sans if there is no japanese glyphs.
Edit:
I have no way to test this now but I assume something like this would work:
import flash.text.Font;
var myFont:Font = new MyFont(); // Embedded font in library, linkage set to 'MyFont'
if(myFont.hasGlyphs("Hello!")) {
field.embedFonts = true; // Not sure whether this is necessary in case of HTML text
field.htmlText = "<p><font color='#ff0000' face='" + myFont.fontName + "'>Hello!</font></p>";
}
else {
field.embedFonts = false;
field.htmlText = "<p><font color='#ff0000' face='_sans'>Hello!</font></p>";
}

MATLAB: displaying markup (HTML or other format)

I'd like to display a table from a script in MATLAB. I can easily generate the <td> and other HTML elements, but as far as I know, I can only write them to a file.
Is there a way to display HTML (or some other markup) from MATLAB? Or am I stuck writing to a file and opening a browser?
You can display the HTML text in a PopupPanel as explained here: http://UndocumentedMatlab.com/blog/customizing-help-popup-contents/
Or in an integrated browser control that points to your HTML file or HTML text as explained here: http://UndocumentedMatlab.com/blog/gui-integrated-browser-control/
Use the Java Swing component inside a MATLAB figure, precisely JEditorPane using MATLAB's javacomponent() function. JEditorPane supports a good subset of HTML.
Here is a code sample:
mytext = '<html><body><table border="1"><tr><th>Month</th><th>Savings</th></tr><tr><td>January</td><td>$100</td></tr></table></body></html>';
hfig = figure();
je = javax.swing.JEditorPane( 'text/html', mytext );
jp = javax.swing.JScrollPane( je );
[hcomponent, hcontainer] = javacomponent( jp, [], hfig );
set( hcontainer, 'units', 'normalized', 'position', [0,0,1,1] );
%# Turn anti-aliasing on ( R2006a, java 5.0 )
java.lang.System.setProperty( 'awt.useSystemAAFontSettings', 'on' );
je.putClientProperty( javax.swing.JEditorPane.HONOR_DISPLAY_PROPERTIES, true );
je.putClientProperty( com.sun.java.swing.SwingUtilities2.AA_TEXT_PROPERTY_KEY, true );
je.setFont( java.awt.Font( 'Arial', java.awt.Font.PLAIN, 13 ) );
EDIT: see the discussion of this solution here,
One alternative is to display the table in a graphics window using the UITABLE control.
EDIT: Even though this is only an alternative (not a solution) to the problem in the question, I thought I'd include a sample for anyone who may be interested in this option:
hFigure = figure('Position',[100 100 300 220]);
hTable = uitable(hFigure,'Data',rand(10,3),...
'ColumnName',{'X' 'Y' 'Z'},...
'Position',[20 20 260 180]);
I ended up doing what I didn't quite want to do, namely to write HTML to a file. It requires me to open it in a browser and refresh every time I run my script, but that's not too bad for what I needed in the short term.

mootools slideshow2

i am using slideshow2 by Aeron Glemann in a website.Does in generate the thumbnails or do i have to provide them?the images iam showing are coming from a cloud, and are passed to the slideshow in an array.the thumbs exist in the cloud. how can i pass them in the array if the show cannot create them?
i have used the replace parameter with regex but it shows as thumbnails the full image and nothing happens when i alter the css properties for the thumbnails. the images are displayed.
here is the line for the show creation:
var myShow = new Slideshow('show', eval(res.value), { controller: true, height: 350,overlap: false, resize: false, hu: '',replace:[/^\S+.(gif|jpg|jpeg|png)$/,'t$1'],thumbnails: true, width: 600});
the value object contains the images from the cloud in format shown below:
['xx.jpg','yy.png',....]
thank you very much for your time.
I'd say your regular expression is broken. To add a 't' to the end of the filename? Try:
replace:[/^(\S+)\.(gif|jpg|jpeg|png)$/,'$1t.$2']
Best to play with the regular expression using an online tester to get it right.