PDFlib - change origin of text to top-left from default of bottom-left - pdflib

In pdflib:
$font = $p->load_font("Helvetica", "unicode", "");
$p->setfont($font, 12);
$p->set_text_pos(100, 100);
$p->show('My text');
First arguments of set_text_pos($x, $y) tells library where to position bottom-left corner of text element.
Question. How can I change the origin of text to be top-left corner, so that "My text" string appears below 100x100 coordinate?

I would recommend to use the more comfortable fit_textline() call. In this case, you can replace your four lines with a single line:
$p->fit_textline('My text', 100, 100, 'fontname=Helvetica encoding=unicode fontsize=12 position {top left} ');

Related

pdflib - how to Use the end of "..." when the box width is insufficient

I want to put a long textline, such as "ABCDEFGHIJKLMN", in a fixed-size box.
//already set fontname and fontsize
p.fit_textline("ABCDEFGHIJKLMN",100,500, "boxsize={50 20} fitmethod=clip showborder");
here's the result
[ABCDEFHG]
but i expect it like this
[ABCD...]
you can solve this with Textflow. A sample implementation is located in the PDFlib cookbook:
https://www.pdflib.com/pdflib-cookbook/textflow/continue_note_after_text/
The trick is, that you leave at the end of the box a space with createlastindent={rightindent=" + textwidth + "}. The space of the textwidth is the length of the "...", which you can determine with p.info_textline() before.

libgdx - scene2d.ui label position

How can I dock a multiline Label to the bottom of the screen? There's the Label.setY() method but it works in some arcane way that makes no sense to me. I can get the approximate height of the label with getWrappedBounds() but I can't figure out how to use the label's height to set the position of the label.
You cannot position directly a label, you would have to add to a class that is using WidgetGroup such as Table. Or you can a Container [that is supposed to be more lightweight than a Table] and add the label to it:
Label testLabel = new Label("testme",super.getSkin(),"gameName");
Container labelContainer = new Container(testLabel);
labelContainer.bottom();
Then the label should be displayed at the bottom
You should prepare your label first and then place it:
skorTextLabel = new Label("Score " + level_skoru, skorTextStyle);
skorTextLabel.setPosition(
ekran_genisligi * 0.5f - skorTextLabel.getWidth() * 0.5f,
skorTextLabel.getHeight() * 0.3f);
"skorTextLabel.getHeight() * 0.3f" distance from bottom.

Show unread item count in Google Chrome extention icon

Is it possible to show unread item count in Google Chrome extension icon? If yes, then can someone point me to some pointers which explains how to do it?
I went through Google Chrome extension documentation, but couldn't figure it
If I understand correctly, you are looking for the browser-action's badge.
...a bit of text that is layered over the icon...
A badge has a background color and optionally some text and is used for displaying small bits of info (such as unread item count).
Use chrome.browserAction.setBadgeText to set/unset the text and chrome.browserAction.setBadgeBackgroundColor to set its color. E.g.:
var ba = chrome.browserAction;
function setAllRead() {
ba.setBadgeBackgroundColor({color: [0, 255, 0, 128]});
ba.setBadgeText({text: ' '}); // <-- set text to '' to remove the badge
}
function setUnread(unreadItemCount) {
ba.setBadgeBackgroundColor({color: [255, 0, 0, 128]});
ba.setBadgeText({text: '' + unreadItemCount});
}
Then use setUnread() and setAllRead() to show/hide the unread items count.

modifying google-maps default directions title

I'm using the Google maps V3 JavaScript API and I'm currently using the default directions formatting (because this is the easiest way to get the map pins and step icons integrated into the listing). I'm setting the text that is displayed for each 'address' for example:
var loc = 'The Old Ballpark Bar and Lounge';
var addr = '1234 Main st. Chicago, IL.';
...
route.legs[0].start_address = loc + ' - ' + addr;
I'd like to enhance the readability of this start_address in 2 ways:
I'd like to put the addr part on a separate line.
I'd like to highlight the loc part in bold
Since the text for this start_address is placed in a td (class="adp-text") within a table (class="adp-placemark"); I thought that putting a <br/> between the loc and addr would get me the newline I wanted; but it doesn't work, the api translates this into <br/>. Similarly, trying to put <b> before the loc part, gets translated into & lt;b& gt;.
I've tried escaping the markup code with quotes and backslashes, etc.; but can't find a way to do what I want. Is there any way to insert such mark up so as to get it past the Google code translators? Are there some lower-level CSS tags that might be used to accomplish this?
You must modify the elements after they have been inserted into the DOM.
assign the desired markup:
route.legs[0].start_address = '<div style="font-weight:bold">'+ loc + '</div>' + addr;
hide the panel(to avoid undesired effects)
//directionsDisplay is the google.maps.DirectionsRenderer-instance
directionsDisplay.getPanel().style.visibility='hidden';
set the direction:
directionsDisplay.setDirections(response);
wait a moment until you modify the elements:
setTimeout(function(){
//fetch the elements
var nodes=directionsDisplay.getPanel().querySelectorAll('td.adp-text');
for(var n=0;n<nodes.length;++n){
//assign the text-content of the element to the innerHTML-property
nodes[n].innerHTML=nodes[n].firstChild.data;
}
//show the panel
directionsDisplay.getPanel().style.visibility='visible';
},100);

Display in input text instead of div

I follow the http://gmaps-samples-v3.googlecode.com/svn/trunk/geocoder/getlatlng.html
instead of displaying the 'latlng' in ,
how do i display it in
If I understand your question correctly (.ie the lat/long value is appearing in the div below the map and you want it to appear in the input text field at the top) then you should change the following line of Javascript (Line 75)
document.getElementById('latlng').innerHTML = latlng;
to
document.getElementById('address').value = latlng;