In my Project I have to display a text in Gujarati Font on HTML page so, can anyone help me how can i do this?
I will explain you how my application read Gujarati String.
Steps :
1) Upload MsWord document(with Gujarti content) from jsp page and store it in MySQl table with hibernate.
2) Retrieve document by java/hibernate and display back to HTML page.
Now, problem is HTML page can no display this Gujarati font. I have used UTF-8 encoding also.
Add following line in your HTML.
< meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
Related
I'm generating pdfs from HTML pages with an application. Sometimes, the pdf is formatted correctly (with styles); other times, it lacks style elements.
In the log file I can see the "Error in rendering".
We are using HTML tags and using string buffer we are converting html tag to pdf file. Not sure why we are getting this missing format issues while generating the pdf file.
So sometimes the CSS file (style) does convert with the HTML file, and sometimes the CSS doesn't convert with the HTML file.
I'm guessing that you use an external CSS file. If I were you, I would try to type your CSS code inside your HTML file, under the header element, like this:
<style>
body {background-color:#fff}
h1 {color:#eee}
</style>
In my header of my site, there is a textarea with show more /less option, the content is stored in database as html tags. I want to retrieve the content as page. in textarea, i will display only first 40 chars. so when i retrieve html tags and remove tags, it will be problem. because i will some style inside content like bold text
ex:
<html>
</body>
<b>this is sample text</b>click here
</body>
</html>
expected result: this is sample text click here
Rather than storing the entire HTML (unless you really have to), I'd say parse the HTML first using JSoup and store the contents of the <b> tags. If you really need to store the HTML then do that (as #ppeterka mentioned though, check it's not a 40 char max on the db) and parse the result using JSoup before you populate the textarea.
I need help your help on croatian letters in my program. On the website (play framework) you can put in names. The name will be saved and a PDF file will be created (with iText) where the string the user typed in is shown. I want to use the font lucida bright. The problem is that there are non-german letters in the names that are not shown. I also tried to convert it into unicode (/u----) but it also doesn't work. I tried to use utf-8 like this in the iText doc:
String name = new String(e.getName().getBytes("UTF-8"));
// e is the object where the name and some other infos are saved
and in the html where the user can type in the name
<meta name="language" content="cr">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
but it doesn't work completely.
In lucida bright (font) are only Š and š correctly shown and in times new roman Š, Ž, š and ž. How can I solve this problem?
If you want to use a font in iText's PDF generation then you have to add it
As in
Font font = FontFactory.getFont("Times-Roman");
document.add(new Paragraph("Times-Roman", font));
For more information see iText
I have created a theme in liferay 6.1. Now my question is how do I change the title of the theme pages.
For ex: About us page has title "Aboutus -liferay", I want to change it to "Aboutus".
I have tried using javascript for this like:
document.title="aboutus";
But until the page loads it shows the default title(Aboutus-liferay) and then after page load this "aboutus" title appears.
I want the custom title.
Any help is highly appreciated.
I just added:
**<head>
<title>$the_title</title>
</head>**
in my portal_normal.vm file and this solved my problem. Now whatever title i add in my html title of the pages in Manage Pages --> pages gets displayed in the title.
Edit the title inside portal_normal.vm of your theme.
In portal_normal.vm, which is a velocity file, add your title to the following code snippet :
<head>
<title>your_title</title>
</head>
EDIT
If you are talking about JSP pages, you can use:
com.liferay.portal.util.PortalUtil.setPageTitle(String, title, HttpServletRequest request);
in the respective page body.
I'm working on an Android app, which loads a HTML page and shows it in a webview.
The problem is I want to add my custom css (the loaded HTML hasn't any CSS or link to a css). How do I add the custom css to the HTML code using jsoup?
I cant modify the html.
And how does the webview can open it afterwards?
Thank you
Several ways. You can use Element#append() to append some piece of HTML to the element.
Document document = Jsoup.connect(url).get();
Element head = document.head();
head.append("<link rel=\"stylesheet\" href=\"http://example.com/your.css\">");
Or, use Element#attr(name, value) to add attributes to existing elements. Here's an example which adds style="color:pink;" to all links.
Document document = Jsoup.connect(url).get();
Elements links = document.select("a");
links.attr("style", "color:pink;");
Either way, after modification get the final HTML string by Document#html().
String html = document.html();
Write it to file by PrintWriter#write() (with the right charset).
String charset = Jsoup.connect(url).response().charset();
// ...
Writer writer = new PrintWriter("/file.html", charset);
writer.write(html);
writer.close();
Finally open it in the webview. Since I can't tell it from top of head, here's just a link with an example which I think is helpful: WebViewDemo.java. I found the link on this blog by the way (which I in turn found by Google).
Probably the easiest way is to search and replace on the HTML text to insert your custom styles, before loading it into your WebView. I do this in my app BBC News to restyle the news article page slightly. My code looks like this:
text = text.replace("</head>",
"<style>h1 {font-size: x-large;} h1, div.date, div.storybody, img {margin:4px; padding:4px; line-height:1.25;}</style></head>");
See how I search and replace on the end head tag (including my own </head> tag in the replaced segment. This ensures that the new snippet goes in the right pace on the page.
There a a few ways to include ccs in html
Tis i use if you have it stored as a external file:
<head><link rel="stylesheet" type="text/css" href="mystyle.css" /></head>
If You want to put it stight i the html file:
<head>
<style type="text/css">
hr {color:sienna;}
p {margin-left:20px;}
body {background-image:url("images/back40.gif");}
</style>
</head>
Or if you wnat to modify a singel tag:
<p style="color:sienna;margin-left:20px">This is a paragraph.</p>
*Edit
Any of thees examples shouldn't have any problem whit displaying.
Ref: W3 Schools CSS