NodeJS pdfkit text width - node.js

I'm trying to do a PDF using node's pdfkit but I'm having some problems related to the text width.
The result i want is something like this.
Overall comments: This is the comment
that will display here bla bla
extra text here
But what i get with my current code is this
Overall comments: This is the comment
that will display here blab bla extra text here
To write this piece of text i use the following code:
doc.font('Courier-Bold').text(padRight('Overall Comments:',28),{continued: true});
doc.font('Courier').text(audit.comment,{width: 100,align: 'justify'});
Where audit.comment is the text on the right and padRight returns the string with a fixed size of 28, adding spaces to the right.
It seems that it's ignoring the width option or I don't know how to use it.

Related

How can I change the font sizing within multiple lines of a string in Lua? (WoW Lua Question)

I am currently beginning to write functions for WoW WeakAura addons that use the WoW Lua in order to create the addon. I am trying to change the fonts within the printed string so that I have a Header essentially.
The code is essentially as follows:
return string.format("|cFFFFFFFFHeader Text|r\nRegular Text|r\nMore Regular Text|r\nEven More Regular Text")
The current printing returns all of the text the same size, but I just want to make the "Header Text" a size larger. I've found how to modify the colors, but I have yet to find anything similar for font size. Can someone assist?

How to break text to a new line when space occurs between words for an svg document

I have an svg text element that looks like this :
<text class="new" x="22%" y="80%" style="dominant-baseline:central; display:table-caption; text-anchor:middle; font-size:25px; fill:#E3E3E4; font-family:'MyriadPro-Regular'">Random heading
</text>
I added a class new to the text element but however much I try, I can get the text to break where space occurs in the text. I know how to do this when not working with an SVG document. I just can't seem to understand why it won't work.
The text remains as is. I want to split it so that the word breaks where space occurs. In our case, I need the output to be:
Random
heading
I have tried the following:
word-break, display:table-caption
I don't wish to use fixed width because I want to use the space for defining where the text breaks to a new line. Please help if you know of a solution.

Why does changing text in Actionscript only preserve included letters?

I am working with Actionscript 3 in Flash, and I have a dynamic text field, instance called "textField" inside an instance of movie clip "mcpoo" and a keyframe with actionscript:
addEventListener(Event.ENTER_FRAME, myfunc);
function myfunc(e:Event):void{
mcpoo.textField.text = "this is a test string";
}
When I set the text field to a default value via text tool, e.g., "asdf" and test the movie, the text will change to include ONLY the chars in the default value, stripping out the rest. "this is a test string" is displayed as "ssass".
Why the good gawddam would it do something like this? As a corollary, how can I work around this or avoid it?
You need to embed more characters in the font you are using. By default, Flash will only embed the characters that you put in the field at author time. It does this to reduce file size.
Select the textfield and hit the Embed button in the Properties panel.
From there you can select the range of characters you want to include (under Character Ranges). You probably want to limit it to only the characters you will need, as it will add to the file size of the SWF.
Alternately, you could use a system font and forget about embedding anything.

Is there a way to make a fragment of text within a line bold in nodejs pdfkit?

Node-pdfkit http://pdfkit.org/index.html
I am using nodejs pdfkit to generate a pdf. I want to be able to bold or italic individual words in a line. It looks like pdfkit doesn't support this, so I was wondering if anyone had done something similar?
What would be really useful is to call the doc.text function, but have the document retain it's x position, so that I could do the following.
doc.text('some words then ');
doc.font('Helvetica-Oblique');
doc.text('italic');
doc.font('Helvetica');
doc.text(' then the remaining words');
and see the output:
some words then italic then the remaining words.
Right now it's outputting one line per text function.
Anyone know a good way to do this?
This feature was added by ej4 in this pull request https://github.com/devongovett/pdfkit/pull/60
It hasn't been merged in to the main project yet, so I ended up forking pdfkit myself, and including ej4s changes and a few of my own.
The basic result is that the changes make it possible to add
continued: true
to the options object. Pdfkit then remembers the caret position and returns you to that position for the next line of text.
Please see: Can I mix font weights in the same paragraph when using pdfkit?
pdf.text('Hello ', LEFT, 200, {
//here it is,
lineBreak : false
}).font(bold).text('World!');

MailMerge: No fixed width font?

I am trying to send data to a specific MergeField. The data are sent correctly. Each line of the data has for specific characters. For example the data to the field may be:
12345 FIRST\nABCDE.F SECOND
(it cannot get the newline so i just so it through character \n)
Now in the printed document each character has its one width, '1' is smaller than 'E' for example. So the data are not alligned within the field. I tried the following fonts: Arial, Tahoma, Courier New. Nothing helped.
Any ideas? Thanks in advance.
Ps the data are sent through an executable built by Visual C++ 5.0!!
You should probably use a tab-stop based layout. Set your tab-stops every, say, centimetre or so (i.e. just big than the widest character in your font) and add a tab before each element that needs to be aligned.
With this you shouldn't need to find a fixed width font and can use something more attractive.
Edit: Out of interest, I wonder why you have no luck with Courier New which is fixed width.
Maybe you could post a screenshot somewhere so we can have a look at your problem in more detail.
Try Courier - it does not have kerning (kerning = variable character width)
Also in the Font window there is a check box that allows you to apply kerning to fonts of a certain size or above - setting this value to a large font size may remove kerning.

Resources