fpdf and new line - fpdf

why text don't jump to new line?
http://img826.imageshack.us/img826/2097/pdf.png
My code:
<?php
require('fpdf.php');
$pdf=new FPDF('P','mm','A4');
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World! Hello World! Hello World! Hello World! Hello World!Hello World!Hello World!','LRTB');
$pdf->Cell(40,10,'Hello World! Hello World! Hello World! Hello World! Hello World!Hello World!Hello World!','LRTB');
$pdf->Cell(40,10,'Hello World! Hello World! Hello World! Hello World! Hello World!Hello World!Hello World!','LRTB');
$pdf->Ln();
$pdf->Cell(40,10,'Hello World! Hello World! Hello World! Hello World! Hello World!Hello World!Hello World!','LRTB');
$pdf->Cell(40,10,'Hello World! Hello World! Hello World! Hello World! Hello World!Hello World!Hello World!','LRTB');
$pdf->Cell(40,10,'Hello World! Hello World! Hello World! Hello World! Hello World!Hello World!Hello World!','LRTB');
$pdf->Output();
?>

The "Hello World" strings are printing across the cell borders.
If you want text to wordwrap inside a cell try using the MultiCell() method.

Try one more argument at the end (ln=2)
$pdf->Cell(40,10,'Hello World! Hello World! Hello World! Hello World! Hello World!Hello World!Hello World!','LRTB', 2);

Related

How to capture UTC instead of local time in VS Code timestamp snippet?

So I've now got this great timestamp inside a code snippet in VS Code.
Full snippet:
"Frontmatter":{
"prefix": "sqFront",
"body": [
"---",
"title: $1",
"permalink: $2",
"description: $3",
"date: ${CURRENT_YEAR}-${CURRENT_MONTH}-${CURRENT_DATE}T${CURRENT_HOUR}:${CURRENT_MINUTE}:${CURRENT_SECOND}Z",
"tags:",
"- $0",
"---"
]
}
How do I set the snippet to capture UTC time instead of my local time?
You can use the HyperSnips extension:
Define the following snippet in the language.hsnips file or in all.hsnips file if you want to have it many file types
snippet sqFront "Frontmatter" b
---
title: $1
permalink: $2
description: $3
date: `` d = new Date();
twodigit = n => n.toString().padStart(2,'0');
rv = `${d.getUTCFullYear()}-${twodigit(d.getUTCMonth()+1)}-${twodigit(d.getUTCDate())}T${twodigit(d.getUTCHours())}:${twodigit(d.getUTCMinutes())}:${twodigit(d.getUTCSeconds())}Z` ``
tags:
- $0
---
endsnippet

How to output Specs2 result to a file

I have code something like this
class HelloWorldSpec extends Specification {
"This is a specification for the 'Hello world' string".txt
"The 'Hello world' string should" >> {
"contain 11 characters" >> {
"Hello world" must haveSize(11)
}
While I run this test I prints result in console, I want results in separate file(other file) not in console what I do?

Markdown, Knitr, Pandoc Header block disappears from output when styles sheet is added

---
title: "![logo](../Shared/logo.jpg) Title Text"
author: "Author Name"
output: html_document
css: styles.css
---
This header information gets output with render or knit2html, but when the css: styles.css and associated code
options(rstudio.markdownToHTML =
function(inputFile, outputFile) {
require(markdown)
markdownToHTML(inputFile, outputFile, stylesheet='custom.css')
}
)
is added to the start up file, the rendered output file has no header output. The first line in the file is the first line after the last "---" in the *.Rmd file. By the way, "Knit HTML" on the individual *.Rmd content works as expected.
Thanks,
Alan
The option rstudio.markdownToHTML is for R Markdown v1 only. The version based on Pandoc is v2, in which case the css field must be put under the html_document field:
---
title: "![logo](../Shared/logo.jpg) Title Text"
author: "Author Name"
output:
html_document:
css: styles.css
---
Please read the documentation.

Using scala sys.process with single quotes, white-space, pipes etc

I am trying to use scala.sys.process._ to submit a POST request to my chronos server with curl. Because there is white space in the command's arguments, I am using the Seq[String] variant of cmd.!!
I am building the command like so:
val cmd = Seq("curl", "-L", "-X POST", "-H 'Content-Type: application/json'", "-d " + jsonHash, args.chronosHost + "/scheduler/" + jobType)
which produces, as expected,
cmd: Seq[String] = List(curl, -L, -X POST, -H 'Content-Type: application/json', -d '{"schedule":"R/2014-02-02T00:00:00Z/PT24H", "name":"Scala-Post-Test", "command":"which scalac", "epsilon":"PT15M", "owner":"myemail#thecompany.com", "async":false}', localhost:4040/scheduler/iso8601)
however, running this appears to mangle the 'Content-Type: application/json' argument:
scala> cmd.!!
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 264 0 100 100 164 2157 3538 --:--:-- --:--:-- --:--:-- 54666
res21: String =
"The HTTP header field "Accept" with value "*/* 'Content-Type:application/json'" could not be parsed.
"
which I don't understand. By contrast, calling cmd.mkString(" ") and copy+pasting into the terminal works as expected.
curl -L -X POST -H 'Content-Type:application/json' -d '{"schedule":"R/2014-02-02T00:00:00Z/PT24H", "name":"Scala-Post-Test", "command":"which scalac", "epsilon":"PT15M", "owner":"austin#quantifind.com", "async":false}' mapr-01.dev.quantifind.com:4040/scheduler/iso8601
I have tried numerous variations on the -H argument to no avail, any insight into using single quotes in sys.process._'s !! would be greatly appreciated.
I have tried variations on this as well, which generates a slew of errors, including
<h2>HTTP ERROR: 415</h2>
<p>Problem accessing /scheduler/iso8601. Reason:
<pre> Unsupported Media Type</pre></p>
<hr /><i><small>Powered by Jetty://</small></i>
(in addition to butchering the jsonHash, ie:
[1/6]: '"schedule":"R/2014-02-02T00:00:00Z/PT24H"' --> <stdout>
curl: (6) Couldn't resolve host ''"schedule"'
Which makes me think it is not interpreting the -H argument correctly
You need to split each argument into a separate element of a sequence.
Instead of this:
val cmd = Seq("curl", "-L", "-X POST", "-H 'Content-Type: application/json'", "-d " + jsonHash, args.chronosHost + "/scheduler/" + jobType)
you need to write this:
val cmd = Seq("curl", "-L", "-X", "POST", "-H", "'Content-Type: application/json'", "-d " + jsonHash, args.chronosHost + "/scheduler/" + jobType)
It puts each element of a sequence as an argument on a command line. So "-H 'Content-Type... looks like a single argument to curl while it should be 2.
Here is a simple way to test:
import scala.sys.process._
val cmd = Seq("find", "/dev/null", "-name", "null") // works
// does not work: val cmd = Seq("find", "/dev/null", "-name null")
val res = cmd.!!
println(res)
Most of the other answers are a bit faffy, use the following trick to get Bash to do all the quote handling etc etc for you
import scala.sys.process._
Seq("bash", "-c", bashLine) !
For easier Googling myself: bash execute process sys.process pipe string scala
As a String pimp method (easy copy pasting)
import scala.sys.process._
implicit class PimpedString(bashLine: String) {
def !!!: Int = Seq("bash", "-c", bashLine) !
}
I also had a hard time to make this work. Enlighten by Aleksey, below worked for me. Note that, surprisingly, there is no extra quote (or double quote) for Content-type:
val deploy = Seq("curl", "-X", "POST", s"$ip/v2/apps", "-H", "Content-Type: application/json", "-d", s"#$containerJson")
println(deploy.!!)

Coffeescript compilation: not as file2file, but as text2text

We can compile coffescript file to js-file with command:
coffee --join path/to/result.js --compile path/to/coffeescript_dir/
But what if I want to compile a piece of coffeescript code (as text) and get piece of js code (as a text too), and they are not files.
For example:
cs text: "func = () -> 55"
js text result: "var func; func = function(){return 55;}"
It must be done from console, or even better from python interactive console :)
You can use --eval to take a string parameter as coffee input, --bare to avoid the JS output being wrapped in a closure, and --print to print the output on stdout instead of a file:
$ coffee --print --bare -eval 'func = -> 55'
var func;
func = function() {
return 55;
};
To call it from Python, you can use the subprocess module:
from subprocess import Popen, PIPE
def compile_cs(cs_code):
args = ['coffee', '--print', '--bare', '--eval', cs_code]
return Popen(args, stdout=PIPE).communicate()[0]