cfdocument PDF showing empty for Hindi language string - coldfusion

Here, As per my business logic I should support for all languages. So I've display a string based on country selections.Everything is works fine in my side. But having issue with cfdocument. Here I've come up with my sample / demo code.
Note : I already take a look on CFDocument PDF not showing Japanese data but not help me more in Hindi.
<cfoutput>
<table border='1px;'>
<tr>
<td>Name</td>
<td>Age</td>
<td>अनुरोध आईडी</td>
</tr>
<tr>
<td>Kannan</td>
<td>29</td>
<td>108</td>
</tr>
</table>
</cfoutput>
Which is displayed properly as expected like below image.
But while I'm using that Hindi string inside the cfdocument that not supported one. Like my below image.
<cfoutput>
<cfdocument format="PDF" overwrite="Yes">
<table border='1px;'>
<tr>
<td>Name</td>
<td>Age</td>
<td>अनुरोध आईडी</td>
</tr>
<tr>
<td>Kannan</td>
<td>29</td>
<td>108</td>
</tr>
</table>
</cfdocument>
</cfoutput>
Note : I've tried below all type but no luck, I've tried with cfprocessingdirective , cfsetting SetLocale() meta tags cfsavecontents
Please let me know if any suggestions. Thanks in advance !

I've spent many hours getting this right after migrating from CF10 + Windows servers where all the languages we needed had working fonts out of the box, to CF2016 on Linux + Docker, where Chinese, Japanese, Korean and others - I cannot remember if we tested Hindi - were all broken.
Unfortunately there isn't a simple "right" answer to your question, as it depends upon getting two key things correct, and the method will vary slightly depending upon your Server OS, Java version and CF version. But as this is too long for a comment I will risk posting as an answer. The two key points are:
Ensure that suitable fonts are available in a path that CF can access and expects to find them - confirm this using CF Admin -> Fonts
Ensure that your JVM font config is configured for each of the languages that you need to support.
(1) is the easy part and is well documented elsewhere, including on the Ben Nadel link mentioned in an earlier comment - https://www.bennadel.com/blog/2987-testing-foreign-and-unicode-character-rendering-with-the-cfdocument-tag-in-coldfusion.htm
Doing that and restarting the CF service will get you to a point where cfdocument will be capable of rendering each font if you explicitly declare it in the CSS. However this is not ideal when you need to support multiple languages and do not know which one applies for a particular element in advance, and/or have a mix of languages within one element.
That's where (2) comes in, you should be able to specify one font in CSS - eg Arial / Helvetica / sans-serif - for an element containing multiple languages eg English and Hindi and in the same paragraph; then Java detects character sequences which fall outside the current font and uses the JVM font config to substitute in a suitable font for those characters without you needing to declare it in your html/css. For Hindi I believe this would typically be Devanagari or Kruti on Windows.
Unfortunately that's the tricky part to get right as it varies by Java version and platform and doesn't seem too well documented. In days gone by, Sun and the OS vendors were pretty good at maintaining a decent base config for us. These days it seems to be an afterthought, particularly on many flavours of Linux.
This link gives an example of how the font config used to work on some environments: https://docs.oracle.com/javase/8/docs/technotes/guides/intl/fontconfig.html
Yours may use a different method though. If you search for java [your java platform version] font properties config [your OS] then you should end up on the right path.

After a long analyzing here I've come with solutions. That is we can download a font ttf file ( Based on your needed languages ). I need Hindi so I've download it from here https://fonts.webtoolhub.com/font-n17979-kruti-dev-010.aspx?lic=1 . And to the following steps.
Step 1: Coldfusion admin - > setting - > font Management.
Step 2: Add a new font management. ( Here you can download the ttf file for needed language then paste it in your local. And mentioned your local path in browser directory options ). FYR : please see my below screen.
Step3: Then we can use our needed font in style attribute in HTML.
style="font-family:Kruti Dev 010;"
Sample Code :
<cfoutput>
<div>
<cfdocument format="PDF" overwrite="Yes" fontembed="true">
<table border='1px;' style="font-family:Kruti Dev 010;">
<tr>
<td>Name</td>
<td>Age</td>
<td id='test'> Request ID </td>
</tr>
<tr>
<td id='testVal'>Kannan</td>
<td>29</td>
<td>108</td>
</tr>
</table>
<p style="font-family:verdana;">This is a heading</p>
<p style="font-family:courier;">This is a paragraph.</p>
<p style="font-family:Kruti Dev 010;">This is a paragraph.</p>
</cfdocument>
</div>
</cfoutput>
Sample Output in PDF by using cfdocument :
I hope this will help for some one. Thank you !

Related

Improper alignment and Height issue with inline formatting

ods escapechar='^';
%let bmi=^S={font_weight=bold} Body Mass Index(Kg/m^{super 2});
When i am trying to create pdf o/p my font is changing in output(Superscript appears in different height)
Is there any solution for the above issue
I think the problem is that you are overriding the style inline, which SAS handles a bit oddly. I am assuming this is a TITLE element below, but the same rules apply no matter where it's coming from.
<td class="c systemtitle">
<span class="c" style=" font-weight: bold;">
Body Mass Index(Kg/m<sup>2</sup>)
</span>
</td>
Notice the class of the span: it's not a systemtitle anymore, it's just a 'c' (which is generic centered text). More than likely your style doesn't properly implement superscripts in generic centered text. I would look at that and see if changing styles works. In general, it is better to do things like the font-weight:bold in styles rather than in inline formatting; you might find you have better luck with that.
I would also add that in the default style in 9.3 for PDF, this isn't a problem, using the default PDF driver in base SAS. If you're running this in EG, it uses a slightly different driver to print PDFs, so that could also be worth trying; options dev=PDF; fixes it.

MVC - Strip unwanted text from rss feed

Ive got the following code in my RSS consumer (Vandelay Industries RemoteRSS) in my Orchard CMS implementation:
#using System.Xml.Linq
#{
var feed = Model.Feed as XElement;
}
<ul>
#foreach(var item in feed
.Element("channel")
.Elements("item")
.Take((int)Model.ItemsToDisplay))
{
<li>#T(item.Element("description").Value)</li>
}
</ul>
The rss feed Im using is from Pinterest, and this bundles the image, link, and a short description all inside the 'description' elements of the feed.
<description><a href="/pin/215609900882251703/"><img src="http://media-cache-ec2.pinterest.com/upload/88664686384961121_UIyVRN8A_b.jpg"></a>How to install Orchard CMS on IIS Server</description>
My issue is that I don't want the text bits, and I also need to prefix the 'href=' links with 'http://www.pinterest.com'.
I've managed to edit the original code with my newbie skills to the above,, which essentially displays the images as links which are only relative and thus pointing locally to my server. These images are also then followed by the short description.
So to summarise, I need a way to prefix all links with 'http://pinterest.com' and then to remove the fee text after the image/links.
Any pointers will be greatly appreciated, Thanks.
You should probably parse the description, with something like http://htmlagilitypack.codeplex.com/, and then tweak it to add the prefix. Or you can learn regular expression and do without a library. Could be a little trickier and error-prone however.

CFDOCUMENT ignores font coloring when backgroundvisible is false

Does anyone else get this problem or know a solution / workaround I could try as I'm running out of ideas? :-(
I'm running this code on ColdFusion 9 - the idea is that it creates a PDF page (a front cover to a report) applies a watermark (a design I've been given with an orange background that I put my content on) and saves it for use later down the page.
The problem I've got is firstly I needed to turn backgroundvisible on in the cfdocument tag. Reason for this is I kept getting this white square showing on top of my produced page. When I do this though cfdocument then ignore any font colour changes I make it.
I've tried all kinds of combinations of trying to get this including styles, classes. internal / external CSS files but everytime ColdFusion defaults it to black.
Does anyone have any suggestions on what I can do to get this showing in white?
<cfdocument format="pdf" marginbottom="0" marginleft="0.77" marginright="0" margintop="5" pageType="A4" unit="in" name="cover" backgroundvisible="false">
<cfoutput>
<html>
<head>
</head>
<body style="color:##fff">
here
</body>
</html>
</cfoutput>
</cfdocument>
<cfpdf action="addWatermark" copyFrom="#coverFile#" source="cover" foreground="false" opacity="10" showonprint="true" />
<cfpdf action="write" destination='#PDFDir##frontCoverFile#' source="cover" overwrite="true" />
Thanks very much,
James
P.S. It maybe that a workaround has to be using CFIMAGE to produce this and then placing that in the page instead. I'd rather not though :-(
Try using straight HTML styles . Tried it and it seemed to do the job.
Ello world
Unfortunately in the case of this question I had to strip the PDF right back to basics.
I had more problems than just this but generally when it comes to PDF features in ColdFusion Adobe will certainly have to pull their fingers out as it's really buggy :-(
Don't know anything about CF mate, but you have two hashtags before the hex colour, so it probably won't be read!

Notepad++ premade template

I have seen in videos, that people get html template by typing "html:5" or something like that (btw, they're not using notepad++). Is this possible in notepad++? Thanks.
A little late, but what you're looking for is called Zen Coding.
The Zen Coding project hosted on Google has a plugin for NotePad++ that should do exactly what you need.
For example, entering something like:
html>head+body>div#content>ul.nav>li*5
Followed by Ctrl + E, expands into:
<html>
<head></head>
<body>
<div id="content">
<ul class="nav">
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>
</body>
</html>
Now it's called Emmet plugin in Notepad++
Just type html:5 and press control + alt + enter
and you will get the following markup:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
</body>
</html>
Option 1
Install and use the Notepad++ Snippets plugin.
You can input whatever code snippet you want and give each snippet a name.
When you double-click on your snippet name, the snippet text just gets copied to your editor (before or after your cursor, based on how you set it)
Option 2
If you don't have admin access or behind a firewall, there is a Macro hack.
If your template is a bit short, then you can use the built-in MACRO and manually key in the template text (a one-time operation per template). You can then "Save Current Recorded Macro" and replay it for every new file that you create. Emmet works only for html, but this technique works for any kind of text(as long as you can manually key-in the text)
Note: You cannot copy-paste (Ctrl-C/Ctrl-V) text while recording as it will copy-paste current clipboard's contents which is undesirable!
For those who like step-by-step instructions:
Open Notepad++. Select Macro -> Start Recording.
Key-in your text (every key-stroke is now being recorded, so minimize backspaces and deletes)
Click : Macro -> Stop Recording
Click : Save Current Recorded Macro and give it a name (say "bash_header" or "html_structure")
Now click on your Macro name to repeatedly apply the template text to your notepad++ file.
Using NP++v6.1.4, I got this to work pretty quickly doing this:
Choose Plugins -> Plugin manager -> Show plugin manager
Wait for all the plugins to be shown, and check the box Emmet
It may alert you that Python will also be installed
Once it completes its installation, allow NP++ to be restarted, and now you can use the many Emmet features :)
Now, just type ! and hit ctrl-alt-enter.
You can use QuickText to create your own templates. It seems that QuickText isn't supported anymore, but it still works, the documentation just has some wrong content.
I use a program called Ditto, it's like a clipboard of all your copy-paste material. I have my prewritten syntax in there pinned. It helps.
In actuality, it is called marking up your code. Although "zen coding" is becoming well known in place of markup, it is the original term for building a structure for your code; which makes it easier for others to read.
As far as the template thing goes for Notepad++, I'm afraid that it is difficult to find public, custom made templates. Although the program does come with custom made templates, such as the Hello Kitty template, your best bet would be to ask people in online programming communities.
My personal favorite is DreamInCode, where they offer help and support, as well as pretty informative tutorials on numerous different computer programming and web development languages. I'm confident that if you can't find one you like that has been posted there, if any, someone would be glad to help you.

Regex help with Google Page Monitor extension

I'm trying to monitor a small section of a web page for changes using the the Google Page Monitor extension --
https://chrome.google.com/extensions/detail/pemhgklkefakciniebenbfclihhmmfcd
Under advanced settings I can use either Regex or Selectors to accomplish this, but need help with this. In the following html, I'd like to monitor the following for changes in either the URL in line 4 or the text in line 5. Any pointers gratefully accepted.
<div id="rtBtmBox"><div id="sectHead" style="margin-bottom:5px;">
<h3>SLJ's Pick of the Day</h3></div>
<p align="center">From the March issue</p>
<p align="center"><a target="_blank" href="http://www.schoollibraryjournal.com/article/CA6723937.html">
<font color="#0000ff"><strong><em>The Summer I Turned Pretty</em></strong><br/>
Awesome, to find a question about my own extension on the front page of StackOverflow.
Anyway, it's easier using a selector. This should do the job: #rtBtmBox p:nth-child(3). However, if that paragraph has more contents, you might need something different (post or link the whole page if so).
A regex that will probably work is: <div id="rtBtmBox">[^]*?<a target="_blank" href="([^"]+)"