Help me please,
Highcharts, How to show data table when export pdf and not show data table when normal like this:
[http://jsfiddle.net/highcharts/z9zXM/]
But can show data table when export pdf or print only.
I did some changes in the official demo from FAQ - https://www.highcharts.com/docs/getting-started/frequently-asked-questions#can-i-add-a-data-table-to-the-exported-chart to render table only for export. Take a look and test it: https://jsfiddle.net/BlackLabel/fwtu48s3/
events: {
load() {
if (this.renderer.forExport) {
Highcharts.drawTable(this);
}
}
},
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.
I am trying to update the font of a range of text in a Google Docs document using the API. I am trying to change just the font and not the font size or style attributes like bold or italic. So if for example I have a document with just the text below as the content:
Hello world
I want to change just the font for the word Hello but leave it the same size and still bold and italic.
I tried to accomplish this with the following code documents.batchUpdate request
{
"requests": [
{
"updateTextStyle": {
"range": {
"startIndex": 1,
"endIndex": 6
},
"textStyle": {
"weightedFontFamily": {
"fontFamily": "Times New Roman"
}
},
"fields": "weightedFontFamily"
}
}
]
}
The result is a successful response from the server but when I check the document I see it changed the font keeping the size and italic attribute, but it didn't keep the bold attribute. I have also tried this using the Google API Explorer and can reproduce the same results.
My question is how do I change the font without loosing the bold? It seems like it should be possible as it kept the italic attribute in tact. Why is bold different? Is it a bug?
My goal is to just change the font leaving the other attributes as is so I do not want to set bold or other attributes explicitly. I also don't want to have to determine the attributes before hand and reset them. That is more work and will be slower and shouldn't be necessary if italic is maintained.
I am able to do something very similar without issue in Google Sheets using a repeatCell.cell.userEnteredFormat.textFormat.fontFamily request and it maintains the bold and italic.
Thanks in advance for any insight or help.
How do I change the font without loosing the bold?
Answer
You have to first save the font weight and bold settings for the range of text you want to modify. There may be more then one font setting for the range. To get the font weight and bold settings for the range you must first check textRun.textStyle. If not defined there you must lookup the paragraphs namedStyleType and check it for the weight and bold settings. If not defined there you must check the NORMAL_TEXT namedStyleType. If not defined there you must use the Google Docs editor default value which for weight is 400 and bold is false.
Once you have the font info for the range you make make a requests for each different font. The request would be like the one in the original question but would set the weightedFontFamily.weight and the bold attributes based on the saved font info.
{
"requests": [
{
"updateTextStyle": {
"range": {
"startIndex": 1,
"endIndex": 6
},
"textStyle": {
"weightedFontFamily": {
"fontFamily": "Times New Roman"
"weight": savedWeight
},
"bold": savedBold
},
"fields": "weightedFontFamily"
}
}
]
}
Why is bold different?
Answer
The Google Docs API uses weightedFontFamily where the weight sub-attribute defaults to 400 and not the current font weight. The bold setting just increases the weight, so bold and weight are linked. There is no current way in the API to set just the font leaving weight/bold alone.
Is it a bug?
Answer
Based on a reply from #Tanaike I have reported the issue to Google via the Google Issue Tracker (https://issuetracker.google.com/165029692). They informed me it was working as intended.
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"/>
";
When exporting chart in Highchart, all my characters are displayed well, except Chinese colon.
Do I need to set something specical?
Even in the highchart exporting example from its site, there is still the problem
Please see an example in http://jsfiddle.net/warmwind/Prah7/2
When setting title as below, it cannot be export correctly
title: {
text: 'Exporting it:colon in between'
}
Something is wrong with the defautlt font on the export-server for this chinese character. Please, specify a font-family for your title. Like this,
title: {
text: 'Exporting it:colon in between',
style: {
"font-family":'verdana'
},
},
There´s reported an issue for this, see https://github.com/highslide-software/highcharts.com/issues/2120