DevExtreme's DataGrid exportToPDF displays gibberish when used on a table with Russian values in it - jspdf

When I try to export to PDF DataGrid with Russian values in it, it displays gibberish in this new PDF file even though I managed to set a proper font (PTSans) for jsPDF and when you print just random text it is working fine…
So is there a way to configure table to PDF to display proper Russian?

Actually I suddenly found a solution :D
If anyone will ever have this problem again, this is how you solve it:
const doc = new jsPDF();
const font = "../../../assets/fonts/PTSans-Regular.ttf" // path to .ttf file
doc.addFont(font, "PTSans-Regular", "normal");
exportDataGridToPdf({
jsPDFDocument: doc,
component: grid,
autoTableOptions: {
styles: {
font: 'PTSans-Regular' // this is a part I forgot about before
}
}
}).then(() => {
doc.save(filename);
})
Basically you need to set up font for your language in jsPdf as well as set up the same in styles for jsPDF-autoTable options.
Huge thanks to Alisher from DevExpress Support whose answer helped me to figure it out.

Related

How do I set a title for the exported pdf?

I would like to set some sort of title for the exported data on the PDFs.
I have looked through http://ui-grid.info/docs/#/api/ui.grid.exporter but there does not seem to be a setting for it.
Right now when you export data as pdf, you get a grid with some red column headers, but nothing to indicate what the report is supposed to be.
Try this
exporterPdfHeader: { text: "My Header", style: 'headerStyle' },
http://ui-grid.info/docs/#/tutorial/206_exporting_data

How to display labels with custom ttf?

Apparently is is possible to use Cocos2d-js 3.0 RC3 cc.LabelTTF with custom fonts, for example as answered here. However this doesn't seem to produce any results for me, neither in the local JSBinding app nor in the web browser.
Font file was included in the res object:
var res = {
lobster_ttf: "res/Lobster.ttf"
};
var g_resources = [];
for (var i in res) {
g_resources.push(res[i]);
}
Lobster.ttf does exist in the directory res.
The label is instantiated as follows:
var label = new cc.LabelTTF("labeltext", res.lobster_ttf, 48);
Doing this will not display the label in the specified font but in the default font. Specifying an installed font instead of the path to the custom ttf does however work.
Is there extra work required to be able to use TTF files?
cocos2d-js v3.0 rc3
Mine worked using the font name (font name when installing the font, not the file name font)
sample:
var label = new cc.LabelTTF("labeltext", "Lobster", 48);
Give it a try..
Tim

Vaadin - TextArea/RichTextArea with real-time text analyzing

I am working on a Vaadin (7) server-side application, and i need to use a TextArea or a RichTextArea that will analyze word-by-word the typed input, and will highlight words of a certain type, for example - dates and times.
My problem is that a RichTextArea does not have a TextChangeListener, and a regular TextArea does not have a highlighting option because it does not support HTML tags...
I tries using ShortcutKeyListener for RichTextArea and analyze the text after every Space key, but it was too slow and had also some other problems.
Is there anything else i can do?
Is there an option to analyze the text on real time when using RichTextArea? or is there any add-on youre familiar with that can do that?
Or is there a way to highlight text in TextArea after analyzing it?
Thank you!
My suggestion is a bit strange, but anyway, take a look on Vaadin AceEditor. It supports text mode and SelectionChangeListener:
ed.addSelectionChangeListener(new SelectionChangeListener() {
#Override
public void selectionChanged(SelectionChangeEvent e) {
int cursor = e.getSelection().getCursorPosition();
Notification.show("Cursor at: " + cursor);
}
});
See details here: Vaadin AceEditor

tcpdf $pdf->Output('out.pdf', 'I'); gone bad

I'm trying to learn TCPDF but I`m stucked in a strange problem, it's my code picked up by the example.
require_once('../tcpdf.php');
ob_start();
// create new PDF document
$pdf = new TCPDF("P","mm","A4",true,"UTF-8",false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('User');
$pdf->SetTitle('TCPDF');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 001', PDF_HEADER_STRING, array(0,64,255), array(0,64,128));
$pdf->setFooterData(array(0,64,0), array(0,64,128));
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// set some language-dependent strings (optional)
if (#file_exists(dirname(__FILE__).'/lang/eng.php')) {
require_once(dirname(__FILE__).'/lang/eng.php');
$pdf->setLanguageArray($l);
}
// ---------------------------------------------------------
// set default font subsetting mode
$pdf->setFontSubsetting(true);
// Set font
// dejavusans is a UTF-8 Unicode font, if you only need to
// print standard ASCII chars, you can use core fonts like
// helvetica or times to reduce file size.
//~ $pdf->SetFont('dejavusans', '', 14, '', true);
// Add a page
// This method has several options, check the source code documentation for more information.
$pdf->AddPage();
// set text shadow effect
$pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal'));
$html = "ASD";
$pdf->writeHTML($html, true, false, true, false, '');
ob_end_clean();
$pdf->Output('prova.pdf', 'I');`
When the PHP reach the Output command something gone wrong, it doesn't open the PDF page on the browser but print a strange output, like if a open a PDF file with a text editor.
Here I use writeHTML(), but is the same with Image(), I've already try it.
Where am I doing wrong?
You need a Content-Disposition header.
See this other thread: PHP Content-Disposition: attachment / Content-Type
i tested things that you did, i working for me, i thing if download the tcpdf API again and replace it with your current folder.
and also about image: make sure that your image type is .jpg as
$html = "ASD
<img src="project path/images/image.jpg"/>
";

Word Document creation using OpenXML

We are creating word document using openxml programatically. Everything works fine but when we protect the document also programactially using openxml for editing then contents of the document are getting affected for example the sentence
نحاول اصلاح التقرير اليوم وشكرا
will become
اليوم وشكرا نحاول اصلاح التقرير
If the generated document is not protected then everything stays fine.
Any help would appreciated.
Thanks in advance.
The code we are using to protec the document is
using (WordprocessingDocument wdoc = WordprocessingDocument.Open(strPath, true))
{
DocumentSettingsPart docSett = wdoc.MainDocumentPart.DocumentSettingsPart;
docSett.RootElement.Append(new DocumentProtection { Edit = DocumentProtectionValues.ReadOnly });
docSett.RootElement.Save();
}
Somehow we managed to solve the problem by converting the normal book mark text to html and adding to the doucment using altChunk technique. This is preventing now the swapping of sentence.
<p>نحاول اصلاح التقرير اليوم وشكرا </p>
Doing so has solved our problem but still not sure why sentence was being swapped when document is protected if it is added to book mark as normal text.
Thanks

Resources