TCPDF : Make Chinese Characters BOLD using FONT "cid0cs" and "stsongstdlight" - character

I have used "cid0cs" and "stsongstdlight" Fonts for chinese characters ,And all characters comes proper . Following is the chinese chracters :
安吧爸八百北不大岛的弟地东都对多儿二方港哥个关贵国过海好很会
家见叫姐京九可老李零六吗妈么没美妹们明名哪那南你您朋七起千去人认日三上
谁什生师识十是四他她台天湾万王我五西息系先香想小谢姓休学也一亿英友月再张这中字
I want to BOLD this characters in PDF .
I used this : $pdf->SetFont($font, 'BUI', 12);
The output in PDF has only underlines and not Bold and italic .
I also used the English Characters using same fonts to see if the bold and italic comes for them . But for English as well the BOLD and Italic dint come .
ALSO : I tried
$pdf->writeHTML("<span><b>安吧爸八百北不大岛的弟地东都对多儿二方港哥个关贵国过海好很会</b></span>", true, 0, true, true);
$pdf->writeHTML("<span><b>The quick brown fox jumps over the lazy dog</b></span>", true, 0, true, true);
$pdf->writeHTML("<i>The quick brown fox jumps over the lazy dog</i>", true, 0, true, true);
$pdf->writeHTML("<strong>The quick brown fox jumps over the lazy dog</strong>", true, 0, true, true);
$pdf->writeHTML("<span><b>谁什生师识十是四他她台天湾万王我五西息系先香想小谢姓休学也一亿英友月再张这中字</b></span>", true, 0, true, true);
But none of this gave me an bold or italic output .
What can be done for FONT "cid0cs" and "stsongstdlight" to support BOLD and Italic.
Have attached the image of PDF output (As cant find the option to attach the pdf)
Awaited for some helpful reply .
Thanks !

If you import custom fonts, you need to make sure that you include both italic and bold version of these fonts. If you check font's dir in tcpdf lib you'll see that each font has bold, italic and bold italic version included (for example you have times, timesb, timesbi and timesi).

Related

Summernote and customize "magic pen" (style) tool

I am using summernote in my project and i want customize style button with "magic pen" icon. In this button you can set h1-h6 or quotes, code(pre tag)....
There is my summernote toolbar settings:
toolbar: [
['style', ['style']],
['style', ['bold', 'italic', 'underline', 'clear']],
['view', ['fullscreen', 'codeview']],
['help', ['help']]
]
first style setting is for "magic pen" button (first from left on toolbar), second style is for bold italic... button group (second from left on toolbar).
So is there some possibility customize first style button with "magic pen" icon?
I need remove some options from there... h1, h5, quotes, code...
On internet i was find some solutions which not work:
StyleTags options (not toolbar):
styleTags:
['p', 'blockquote', 'pre']
Or specify first 'style':
toolbar: [
['style', ['blockquote', 'pre']],
but without success can anybody help?
Not sure if you got sorted with this but had this issue today, Summernote documentation wouldn't be the best but this worked for me and might help someone else out in the future.
$(document).ready(function() {
$('textarea[data-content~=summernote-content]').summernote({
height: 400,
toolbar: [
['style', ['style']],
['font', ['bold', 'italic', 'underline', 'clear']],
['help', ['help']]
],
styleTags: ['p', 'h1', 'h2', 'h3', 'h4', 'h5'],
});
});
So you just define the style as normal in the toolbar tags but then below it you specify the actual attributes you wish to show.

officejs : Unable to set underline property to false for hyperlinked text

I inserted text and added a hyperlink to it. After doing this by default the text appears in blue color and underlined. I don't want the underline, but when I try to set the underline property to false, it has no effect on the text. You can find the sample code below.
Word.run(function (context) {
var selection = context.document.getSelection();
var para = selection.insertText("lorem", Word.InsertLocation.end);
para.hyperlink = "https://www.stackoverflow.com";
para.set({
font: {
underline: false
}
});
return context.sync();
}).catch(function (e) {
console.log(e.message);
})
The values for Word's JS API font.underline property do not include false. Try with the string value 'None'.
The accepted Enum values for Font.Underline are listed here.
Note that the blue, underline formatting is Word's default style definition for the Hyperlink style. In the "COM" world the better approach would be to change the style definition to not include an underline. This option is not (yet?) available for JS Add-ins, which provide no functionality for changing or creating styles.

How to highlight invisible unicode character &# 65279; in Visual Studio Code?

Sometimes, I (in release) find this character. So, how highlight it in Visual Studio Code??
p.s. I know about utf-8 without BOM, but fix it I need to open page with code in notepad++ and change encoding. And I want to see this unicode in Visual Studio Code how highlighted, so I can see (and delete later)
How it's work
1) I add extension Gremlins
2) and in C:\Users\tomnolane.vscode\extensions\nhoizey.gremlins-0.6.2\extension.js add this code:
const gremlins = [
{
...
},
{
char: 'feff',
regex: /\ufeff+/g,
width: 0,
message: 'Zero Width No-Break Space',
backgroundColor: 'rgba(255,127,80,.5)',
overviewRulerColor: 'rgba(255,127,80,1)',
},
{
char: '2060',
regex: /\u2060+/g,
width: 0,
message: 'Word Joiner',
backgroundColor: 'rgba(255,127,80,.5)',
overviewRulerColor: 'rgba(255,127,80,1)',
},
{
char: 'fffe',
regex: /\ufffe+/g,
width: 0,
message: 'Not a Character',
backgroundColor: 'rgba(255,127,80,.5)',
overviewRulerColor: 'rgba(255,127,80,1)',
},
]
3) then, reload Visual Studio Code and it's work!
With the new setting:
Editor > Unicode Highlight: Invisible Characters set to true or deriveFromWorkspaceTrust.
In settings.json:
"editor.unicodeHighlight.invisibleCharacters": true,
the unicode character U+FEFF (zero-width space character) will be highlighted.
See more at https://stackoverflow.com/a/70164173/836330

TinyMCE issue: textarea not updated even with TriggerSave()

I'm using TinyMCE in a form where I use ajax to submit the form. I've been struggling for the last 4 hours to figure out what is going wrong but I have reached a dead end.
I initialize TinyMCE with the following code:
tinymce.init({
selector: "textarea.editme",
plugins: ["advlist autolink autosave link image lists charmap print preview hr anchor
pagebreak spellchecker","searchreplace wordcount visualblocks visualchars code
fullscreen insertdatetime media nonbreaking","table contextmenu directionality
emoticons template textcolor paste fullpage textcolor imageplugin"],
toolbar1: "image_list undo redo | bold italic underline strikethrough | alignleft
aligncenter alignright alignjustify | fontselect fontsizeselect forecolor backcolor",
toolbar2: "cut copy paste | searchreplace | bullist numlist | outdent indent
blockquote | preview | table",
menubar: false,});
I don't have problems loading it so the code should be all right but I copied it here just in case.
I have a textarea with the right class "editme" to display TinyMCE. This text area is embedded in a form ()
I submit the form with the following code:
$("#submitform").submit(function(e)
{
tinyMCE.triggerSave(true,true);
var postData=$(this).serializeArray();
var url = 'php/forms_post.php';
$.ajax(
{
url : url,
type: "POST",
data : postData,
success:function(data, textStatus, jqXHR)
{
// DISPLAY SUCCESS
},
error: function(jqXHR, textStatus, errorThrown)
{
// DISPLAY FAILURE
}
});
e.preventDefault();
e.unbind();
});
The code works fine, except for one thing. If I write "aaaaaa" in the textarea the first time, it gets submitted correctly and everything is fine. But if I then change it to "bbbbbb", the data that is submitted is still "aaaaaa". It looks like the triggersave keeps the data in memory and refuses any changes. I already restarted the browser, the server, cleaned cache, cleaned cookies,... but still the problem is there.
If I remove TinyMCE and keep a standard textarea, I have no problem.
Do you have any idea of what's going wrong?
Thanks a lot
Laurent

Applying tinymce to dynamically created textarea works exactly once

I have a page with three horizontal tabs. Clicking on a tab dynamically populates a div with a form. I am using BackboneJS to manage views' rendering (not sure if relevant). When I call render() on the view, after I populate the element's html, I make a call to apply tinyMCE to a text area:
$('#text_' + this.model.id, this.$el).tinymce({
script_url : '/lib/tinymce/tinymce.min.js',
theme : "modern",
content_css: "/css/bootstrap.min.css",
menubar: false,
toolbar: "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | " +
"bullist numlist outdent indent | link image | forecolor backcolor emoticons",
setup: function(editor) {
editor.on('change', function(e) {
var change = {};
change["content"] = e.level.content;
self.model.set(change);
});
}
});
This works perfectly fine on the first go. When view is removed, there is an event called that applies .tinymce().remove(); to the field to properly remove editor before displaying the next view. The next view renders - it's the same view but different model. On this, and all subsequent calls, tinyMCE hides the textarea, and doesn't show the editor. I know my views work - commenting out .tinymce() call in render() makes everything work as intended. TinyMCE stumbles somewhere. Any insight will be appreciated.
I'm not 100% clear on what .tinymce().remove(); is doing but have you tried this:
tinymce.triggerSave();
tinymce.execCommand('mceRemoveEditor', true, tinymce.activeEditor.id);
and when you switch to the next view try re-attaching the editor via:
tinymce.execCommand('mceAddEditor', false, selector);
If that doesn't work or doesn't apply to what you're doing. Have you considered having more than 1 tinyMCE editor? It sounds like you have a set number of tabs, so you could create a separate tinyMCE for each one and simply hide/show the editor on each as needed with:
tinymce.execCommand('mceToggleEditor', false, selector);
This method is considered much faster than adding/removing the editor.