ABCPdf .EmbedFont not working when adding Russian (Cyrillic) text - translation

We use ABCpdf software, and recently added a Russian translation option for some of our documents. Most of the contents of the PDF come from a web page using the AddImageURL method. This all works fine, meaning that the Russian text is readable.
However, we have a few text sections that need to be placed exactly at the bottom of the page, so we do this with ABCpdf's AddText method. These strings show up as ???????? in the generated PDF.
Here's a quick code sample:
Doc pdfDoc = new Doc();
//snip snip snip...
//add footer text
pdfDoc.Rect.SetRect(30, 30, 552, 10); //footer section
pdfDoc.HPos = 0; //set horizontal position to left
pdfDoc.AddText(GetRussianString("REFERENCE") + " #" + ReferenceID);
After reading the documentation on Websupergoo's site, I tried using AddFont and EmbedFont (separately and together), but this did not work:
pdfDoc.Font = pdfDoc.EmbedFont("Times-Roman", LanguageType.Unicode);
I also searched for ways to set encoding at the document level, and didn't find any documentation on this, at least not for version 8. We are currently using 8.11.2 of the ABCpdf software.
Has anybody done something like this successfully?

OK, the (totally embarrassing) answer is that I was being far too literal about the example from WebSuperGoo's site. I needed to use the exact font name from my development/production machine.
pdfDoc.Font = pdfDoc.EmbedFont("Times New Roman", LanguageType.Unicode);
Obvious? Yes. But it's one of things that can be overlooked when in a hurry, so I'll post the answer here in case anybody else gets tripped up.
Part of my confusion stemmed from the fact that Russian text added from a URL was just fine in the document, but not the content added as text. I'm guessing that abcPDF sets the font according to the encoding it gets from the web page, but that affects only the content it is pulling in, not the overall PDF.
Anyhow, thanks to gekannt and anybody else who took a look.

Related

authorProfileImageUrl returns only a tiny thumbnail

I'm trying to use YouTube Data API to get a list of comments for a video.
The problem is that the field authorProfileImageUrl in the response contains a URL to a tiny thumbnail (28x28 pixels) of the profile image instead of the bigger one (48x48) that can be seen in YouTube's comment section. How can I retrieve the bigger one? Am I missing some magic parameter in the request that selects the size of the profile images in comments?
Here's my request URL:
https://www.googleapis.com/youtube/v3/commentThreads?videoId=VIDEO_ID&part=snippet&fields=pageInfo,items(snippet(topLevelComment(id,snippet(authorDisplayName,authorChannelUrl,authorProfileImageUrl,authorChannelId,textDisplay,likeCount,publishedAt)),totalReplyCount))&maxResults=3&key=API_KEY
Edit:
Here's an example profile pic URL i get:
https://yt3.ggpht.com/-b-fXZSZ0hPw/AAAAAAAAAAI/AAAAAAAAAAA/mq4JpF46xq4/s28-c-k-no-mo-rj-c0xffffff/photo.jpg
^^
I noticed that the marked part seems to select the size, because when I change the 28 to 48, the size of the profile pic changes too.
I could change it "manually" with some fancy regexp, and it will work, but it will also rely on implementation details that are undocumented and that may change in future and render the application broken :P So it really would be better if there was a documented API way to do that.
Seems like nobody knows how to solve this, ho here's my temporary solution.
It works, but it depends on an implementation detail that can change in the future and then the solution will break apart and will have to be corrected :q
I accept my own answer for now, but when someone posts a better one, I'll accept it instead.
The solution:
I made a simple function that searches for the image size in the URL string and replaces it with a bigger size.
function small2big(url)
{
return url.replace(/(\/.*s)28(.*\/photo.jpg)$/,"$1"+"48"+"$2");
}
Oh, and here's my middle finger for you, Google: ,,|,,
It seems that actually removing everything right at the 's28' will display the entire image without specifying a size.
For example, instead of this:
https://yt3.ggpht.com/-b-fXZSZ0hPw/AAAAAAAAAAI/AAAAAAAAAAA/mq4JpF46xq4/s28-c-k-no-mo-rj-c0xffffff/photo.jpg
You can use this: https://yt3.ggpht.com/-b-fXZSZ0hPw/AAAAAAAAAAI/AAAAAAAAAAA/mq4JpF46xq4/
And it will return the full size image.
In my case, using php I simply:
function bigAvatar($url) {
$url = substr($url, 0, strpos($url, 's28'));
return $url;
}
Again, if google decides to change this in the future, this would break. But for now, it works.

How to copy class and function name in Blackfire report

When I am copy-pasting method name from Blackfire profile, I am getting a reversed string like this:
sgnitsiLredivorPdaol::yrotisopeRresopmoC\yrotisopeR\resopmoC
What is intended way to copy a proper method name (not reversed)?
Why does Blackfire has such behaviour? Is this some kind of stupid joke or copy-paste protection?
This is indeed a UX issue we currently have in Blackfire, let me explain it to you:
We want to display the end of the namespace/classname value in this part of the interface
We want to have a text-overflow ellipsis on the left part of the value.
Unfortunately, using text-overflow: ellipsis on the left of the text is not supported by modern browsers at the moment.
There are two ways to do that: Either know the width of the text, work with a fixed width column and truncate programmatically or use a hack, revert the letters, change the text direction from left-to-right to right-to-left locally and use traditional text-overflow.
As we deal with a resizable UI here, we chose the second option, and this is the one that provide the better experience at the moment. However, as you notice, this issue remains.
We're thinking about a fix for this issue. It might be with the Clipboard API.
In the meantime, here's the way you can copy/paste the value :
Just expand a node and copy from the inner box, see:
Hope it helps you until we find a better solution.

Multiple-page print or Reporting library for Vaadin 7 UI

We had a Vaadin 7 UI page with multiple Layouts, Panels, and Chart (the Browser will come with ScrollBar as height is big). When we try to print using JavaScript in Vaadin code or using Ctrl+P of browser, it prints only One page in Firefox 32.0.3; prints multiple pages with only data for First Page in IE 8.
We tried with specifying undefined size for all components in UI page
(as mentioned in https://vaadin.com/forum#!/thread/3869543/7861633)
We also tried with some CSS changes for print (as mentioned in https://vaadin.com/forum/#!/thread/529738/539201)
Both above cases didnot solved our problem. As we can understand from documentation that Vaadin scrolling uses a DOM structure, it was unusual to know such a tool does not provide proper Print option.
To brief our objective, we are looking at Reporting option in Vaadin for some data analysis. We saw some options (using JasperReport etc.) mentioned in StackOverflow, however will not be able to implement them as we need to deploy this application to Google App Engine (GAE) which has unsupported functions such as FileOutputStream etc.
To conclude, these are our issues -
How to resolve multiple page print issue in Vaadin 7?
If we are not able to solve first issue, What is the best Reporting library (for PDF or PNG or HTML or Print) that is supported by both Vaadin 7 and GAE?
Any guidelines or suggestions to direct us would be appreciated.
Printing HTML pages is random at best.
Every browser has it's own rules for display and page breaks. We always use pdf for things to print.
iReport / Jasperreports is the thing we use most of the time
You can try this workaround:
private void setSizeUndefined2Print()
{
com.vaadin.ui.JavaScript.getCurrent().execute("document.body.style.overflow = \"auto\";" +
"document.body.style.height = \"auto\"");
UI.getCurrent().setSizeUndefined();
this.setSizeUndefined();
}
If for some cases you need to switch back to "defined" size, next method can be used:
private void setSizeFull2Print()
{
com.vaadin.ui.JavaScript.getCurrent().execute("document.body.style.overflow = \"\";" +
"document.body.style.height = \"\"");
UI.getCurrent().setSizeFull();
this.setSizeFull();
}

Full URL for one specific page content only in Typo3 while the rest follows the base URL constant

I am managing an association's site using typo 3 version 4.5.30. The site has the config setup for [baseURL] = http://www.afj-japon.org/ in its template.
Everything works fine, but I need ONE page only to have the URLs written in full in the code.
Right now the page code indicates
and the URLs are written in full for the redirections to other pages, but as for the images.
I need to have the code to actually be as
How can I set this to affect only this one page and not the whole site ?
Thank you in advance for your help.
Regards,
Gilles
if I understand the question right you want to have absolute URLs on one certain page, right?
TYPO3 comes with a setting called config.absRefPrefix.
If said one page has no child-pages you can set up an extension template on that page and have this line in there:
config.absRefPrefix = http://www.afj-japon.org/
If the page has child-pages underneath it, you will have to use a condition in the ID of that page.
[globalVar = TSFE:id = PAGE-UID]
config.absRefPrefix = http://www.afj-japon.org/
[global]
Mind that every condition has to be evaluated prior to caching so having a lot of conditions might make your website slower.

Searching RichTextBox and deleting all between

I'm having a little trouble trying to figure out how to search all the text in my RichTextBox and delete everything between the parentheses (including the parentheses). I have a lot of files with different comments wrote in the parentheses that may have different text in them.
Example : This is my text in the text box (AS YOU CAN SEE HERE). I am wanting to be able to read the entire text box (This would be another comment) and delete the out.
Result: This is my text in the text box. I am wanting to be able to read the entire text box and delete the out.
The rich text box are usually longer files than just a couple lines. Any help would be gratefully appreciated.
You can use a regular expression for this:
Regex r = new Regex("\(.+?\)");
If you are using a richtextbox or a textbox:
rtb.Text = r.Replace(rtb.Text,"");
You can do this without reading the file into the richttextbox:
string filetext = File.ReadAllText("file.txt");
filetext = r.Replace(filetext,"");
File.WriteAllText("file.txt",filetext);
Or in one line:
File.WriteAllText("file.txt",r.Replace(File.ReadAllText("file.txt"),""));
You can loop all files in a directory:
foreach(string file in Directory.GetFiles(targetDirectory)
File.WriteAllText(file,r.Replace(File.ReadAllText(file),""));

Resources