Defining Courier font in Java Documentation comments - java

In my Enunciate API documentation report, I need to change the font of some comment text to "Courier New" font type.
Is is possible?

Found a way for this feature -
Use Font html tag in the comment, Java doc code reads it as a html tag and displays in courier font.
/* Sample URL - <font face="courier">https://{Hostname}/programs/FireIn</font>, Replace the host name with the respective environment name</br>
*/

Starting with 1.2, Javadoc supports HTML style sheets. You can make these changes to stylesheet.css (located at the root directory of the Javadoc HTML files).
To choose a smaller, sans-serif fonts for the left-hand frames, change this:
#FrameItemFont { font-size: normal; font-family: normal }
To:
#FrameItemFont { font-size: 10pt; font-family: helvetica arial sans-serif }
Customize this yourself for whatever font you want.

Related

Java ,wkhtmltopdf, HTML to PDF not all fonts works correctly

I am using wkhtmltopdf to generate PDF from HTML (string not file).
Before I start creating PDF, I add all fonts to HTML file
htmlTemplate = htmlTemplate.replaceAll("\\$\\{fontsPlaceholder}", ResourcesCache.getInstance().getFontsCSSCache());
and all fonts are inside of html, and look like
#font-face {
font-family: 'Abril_Fatface-Regular';
src: url(data:font/ttf;base64,AAEAA....
But when I tried to use font properties, bold, italic etc, and then make the pdf, this is not working correctly, and field use 'regular' font in pdf, but in html set bold..
So, why not all fonts working good in wkhtmltopdf, does someone fixed issue like this?
I have been solve this issue. The problem was with fonts, not with wkhtmltopdf lib.
If you want to use font-property correct, you need to be sure that 'Preferred Family' is set in your font. To check or to set this you can with FontForge app.
Open FontForge, then import your font, and click 'Element/FontInfo/TTF Names', and change 'Preferred Family' (it's need to be unique for each font).

java itextpdf 5.5.6 custom font not displaying properly

I am using ITextPdf (5.5.6) with my java + android web application to generate pdf.I wanted to view the contents in Gotham Light font. Therefore I have downloaded a Gotham Light .ttf file and created a font as follows.
In my generated pdf it looks like it is the good font but it is bolder.
The version that i am using of iText does support Gotham Ligh ?
The code that i am using:
Template t = ve.getTemplate(contratXHTML, "UTF-8");
StringWriter writer = new StringWriter();
t.merge(context, writer);
String body = writer.toString();
writer.close();
OutputStream os = new FileOutputStream(absolutePathContratPDF);
renderer.getFontResolver().addFont("C:\\Windows\\Fonts\\Gotham Light_0.ttf",BaseFont.EMBEDDED);
renderer.setDocumentFromString(body);
renderer.layout();
renderer.createPDF(os);
os.close();
FileUtils.deleteQuietly(new File(pathTemporalDirectory));
return body;
Please can you help me ?
I got stuck with a similar problem,
The problem was not with the font you add, but the CSS/style used to body (HTML body) you want to print in PDF.
Please specify the font-family correctly. In my case, I used Arial font along with
font-family: Arial; in
and my font did not work with tag.
So, changing it to
font-family: sans-serif;
resolved the issue.
In few cases, you might need to define
font-family: Arial, Helvetica, sans-serif;
Reference : https://developer.salesforce.com/forums/?id=906F000000095wDIAQ

JavaFX Embed Custom Font Not Working

I'm using JavaFX version 8.0.40-b27 and trying to embed a custom/external font via CSS. I've also tried programmatic approaches, all of which have failed. A System.out.print of "font" returns null, which I suspect to be the cause.
Java:
Font font = Font.loadFont( Main.class.getClassLoader().getResourceAsStream( "application/stratum.ttf"), 10);
System.out.println(font); // Prints "null"
nowPlayingTitle.setFont(font);
CSS:
#font-face {
font-family: stratum;
src: url('stratum.ttf');
}
.text{
-fx-font-family: "stratum", "Segoe UI Light";
-fx-font-weight: 100;
-fx-text-fill: white;
}
Directory:
http://i.stack.imgur.com/c92ii.png
EDIT:
System.out.println(font); now prints Font[name=StratumNo1-Thin, family=StratumNo1, style=Thin, size=10.0], so the file is being accessed correctly. However the font is still not being rendered on screen: http://i.stack.imgur.com/bueUk.png
For the URL in Java code, try either
// relative to classpath, with leading /
Font font = Font.loadFont( Main.class.getClassLoader().getResourceAsStream( "/application/stratum.ttf"), 10);
or
// relative to class:
Font font = Font.loadFont( Main.class.getClassLoader().getResourceAsStream( "stratum.ttf"), 10);
The CSS looks right to me... are you sure your ttf file is being deployed along with the compiled code as css, etc?

How to convert PrimeFaces p:dataTable to standard h:dataTable (without skin) and then print it

I want to print a <p:dataTable>, so I use <p:printer>, but I want to skip printing the skin and make it look like a <h:dataTable>. How can I do this?
Also, is it possible to change the paper orientation of the print? I would like to print it as landscape instead of portrait.
<h:outputLink id="lnk" value="#">
<p:printer target="tbl" />
<p:graphicImage value="http://www.primefaces.org/showcase/images/print.png" />
</h:outputLink>
I didn't find any suitable attribute in the <p:printer> tag.
Update: sorry, nevermind the <p:printer> can be used on a <h:dataTable> as well, so you can also just answer the second question only.
Both qustions are answered with CSS #media print rule. It allows you to specify CSS styles which are specific to printed output. You can embed those rules in a normal CSS stylesheet file or <style> element the usual way.
I want to print a <p:dataTable>, so I use <p:printer>, but I want to skip printing the skin and make it look like a <h:dataTable>. How can I do this?
Lookup the classname of the <p:dataTable> and override it in your #media rule:
#media print {
.primeFaces-dataTable-className {
border: 0;
margin: 0;
padding: 0;
background: none;
color: black;
}
}
There are likely more, I don't know it all from top of head, you should be able to check using Firebug or Chrome developer tools what classname is been used and which properties are all been set so that you know which you should reset to 0, none or some other default.
Also, is it possible to change the paper orientation of the print? I would like to print it as landscape instead of portrait.
Use CSS.
As per CSS 2.1, you can specify it as follows:
#media print {
#page {
size: landscape;
}
}
This has however browser specific impediments, it's not supported in FF and in MSIE <=7. For workarounds, check the accepted answer of this question: Landscape printing from HTML

FlyingSaucer LTR/RTL/BiDi issue with arabic text

I'm using flying saucer xhtmlrenderer for building pdf documents. Everything worked fine until now - now we should generate arabic text inside pdf.
Xhtmlrenderer is rendering Arabic text in reverse order.
I've read somewhere on internet (maybe on their own site) that xhtmlrenderer does not support bidi/rtl.
But IText itself contains examples to work with arabic and hebrew via ColumnText and PdfPTable (sources can be found here: http://sourceforge.net/projects/itextpdf/files/Examples/examples-155/examples-155.zip/download - arabic_hebrew.java), and those work fine.
I tried to use itext api in xhtmlrenderer's ReplacedElementFactory/ITextReplacedElement, but could not find good examples for positioning elements.
Does anyone tried to do this? Or maybe there is a simplier (or at least working) solution?
Finally I'm able to print arabic text in rtl/ltr using flying saucer.
In my code I'm giving width and alignment for every arabic text block, but in general it works fine.
(Edited) Code is large to print it down here, please find the code on Google groups, the links are in the comments.
Same issue I was facing, only solution i can find out was using arial fonts
import/add arial.ttf and arialbold.ttf files in resources folder of your project.
OutputStream outputStream = response.getOutputStream();
ITextRenderer renderer = new ITextRenderer();
// renderer.getFontResolver().addFont("/fonts/arialbold.ttf",
// BaseFont.IDENTITY_H,BaseFont.EMBEDDED);
renderer.getFontResolver().addFont("/fonts/arial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
renderer.getFontResolver().addFont("/fonts/arialbold.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
// SharedContext sharedContext = renderer.getSharedContext();
// sharedContext.setPrint(true);
// sharedContext.setInteractive(false);
// sharedContext.setReplacedElementFactory(new B64ImgReplacedElementFactory());
// sharedContext.getTextRenderer().setSmoothingThreshold(0);
renderer.setDocumentFromString(content);
renderer.layout();
renderer.createPDF(outputStream);
renderer.finishPDF();
outputStream.close();
in your css use
html, body {
margin: 0;
padding: 0;
font-family: Arial, Arial Bold;
font-size: 10px;
line-height: 14px;
}

Categories

Resources