I'm using iReport 5.6.0 for creating a report,
I want to add a header for excel when print preview, I tried adding this line in the jrxml
<property name="net.sf.jasperreports.export.xls.sheet.header.left" value="My Left Text"/>
<property name="net.sf.jasperreports.export.xls.sheet.header.center" value="My Center Text"/>
<property name="net.sf.jasperreports.export.xls.sheet.header.right" value="My Right Text"/>
This is working fine, but the problem is I don't know how to add font style or font size.
Is there a way that I can add font style, font size, or font color?
Jasper report has no attribute in which you can specify the font used for header.
but we can do some crazy stuff
Jasper report is using Apache POI to export to excel, in POI to set the page header, commands like this is used (see HSSFHeader)
header.setCenter(HSSFHeader.font("Calibri", "bold") + HSSFHeader.fontSize((short) 16) + "My Center Text");
This is actually generating a String that is set to center.
&"Calibri,bold"&16My Center Text
Since we need to put it in an xml attribute we need to escape " with " and & with &.
<property name="net.sf.jasperreports.export.xls.sheet.header.center"
value="&"Calibri,bold"&16My Center Text"/>
Voilà
To understand how the String should be when switching from different style and using other POI attributes, an easiest way is to make a small java program, for example
System.out.println(HSSFHeader.font("Times New Roman", "regular") +
HSSFHeader.fontSize((short) 12) + "My " + HSSFHeader.startBold() + "Bold" +
HSSFHeader.endBold() + " Text with date " + HSSFHeader.date());
&"Times New Roman,regular"&12My &BBold&B Text with date &D
just escape and insert into to value attribute
Related
I want to add a logo to a keystone project or if logo is not possible, just a simple text. I was able to add the logo only during the login process. I suppose the best place to add the logo is the navigation bar but its not a must.
I tried to changed the home logo <span class="octicon octicon-home"></span> with my logo but was not able to found where.
I tried to add img(src='/images/logo.png', width='160') to templates/layouts/default.pub but I got an error img is a self closing element: <img/> but contains nested content. It's also wrote There is no .container wrapping class around body blocks to allow more flexibility in design
I tried to add an iFrame using javascript and tried to put some html code on it. This also didn't worked.
I also tried to set a label or singular to one page but this is not what I need
Do you have any idea?
Firstly you can find the default logo in:
\node_modules\keystone\admin\public\images\logo.png
After replace the PNG image, the login screen will reflect the updated logo.
Next for Admin UI, you can check:
\node_modules\keystone\admin\client\App\components\Navigation\Primary\index.js
Line 77:
return (
<PrimaryNavItem
className={className}
label="octicon-home"
title={'Dashboard - ' + brand}
to={Keystone.adminPath}
>
<span className="octicon octicon-home" />
</PrimaryNavItem>
Replace the span with:
return (
<PrimaryNavItem
className={className}
label="octicon-home"
title={'Dashboard - ' + brand}
to={Keystone.adminPath}
>
<img src="/keystone/images/logo.png" width="20" height="20"/>
</PrimaryNavItem>
Finally in public page, edit (if you are using PUG):
\templates\layouts\default.pug
Line 54:
a.navbar-brand(href='/')
img(src='/keystone/images/logo.png' width='20' height='20')
I'm wondering how to add custom headers or footers to a PDF that is exported using Google Apps Script from a Google Sheet. I would like to add a footer that says "My Company Proprietary and Confidential" in the center of the page.
This is functionality that is available in normal PDF export from Sheets (i.e. File » Download as » PDF » Headers & footers » EDIT CUSTOM FIELDS), but I don't know how to replicate it with URL parameters. I've also tried setting '&sheetnames=true&printtitle=true', but this puts the sheet name and spreadsheet name in the header instead of the footer.
Are there any additional URL parameters I can use to control these custom fields?
var url = 'https://docs.google.com/spreadsheets/d/'+sourceSpreadSheet.getId()
+'/export?exportFormat=pdf&format=pdf' // export as pdf / csv / xls / xlsx
+ '&size=letter' // paper size legal / letter / A4
+ '&portrait=false' // orientation, false for landscape
+ '&fitw=true' // fit to page width, false for actual size
+ '&sheetnames=false&printtitle=false' // hide optional headers and footers
+ '&pagenum=CENTER&gridlines=false' // hide page numbers and gridlines
+ '&fzr=false' // do not repeat row headers (frozen rows) on each page
+ '&gid='+sourceSheet.getSheetId() // the sheet's Id
+ '&top_margin=0.45&left_margin=0.25&right_margin=0.25&bottom_margin=0.5'; // margins
Target Footer:
I think the workaround would be:
create a new document
Insert your header
Copy the contents of your spreadsheet
Insert your footer
Export the new file as PDF
Trash the new file
I am working on dynamic HTML to PDF document and using ckeditor to write HTML and then itextsharp 5.5.10 to generate downloadable PDF from it. Below is the code I am using
string htmlText = "some basic HTML I wrote in ckeditor 4.0 and save in my DB to retrieve later"
StringReader sr = new StringReader(htmlText);
Document pdfDoc = new Document(PageSize.A4, 0, 0, 0, 18f);
PdfWriter writer = PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
// instantiate the custom PdfPageEventHelper
MyPageEventHandler e = new MyPageEventHandler()
{
ImageHeader = imageHeader
};
writer.PageEvent = e;
pdfDoc.Open();
XMLWorkerHelper.GetInstance().ParseXHtml(writer, pdfDoc, sr);
pdfDoc.Close();
// Auto Download option
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=Proposal-" + pid + ".pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Write(pdfDoc);
Response.End();
Now everything is working fine, thanks to this great library itextsharp however sometimes its not adding few images to PDF file.
During debugging I found that variable htmlText has same input HTML that I saved using ekeditor and it contains all img tags too but still some images are not showing up in PDF.
Below are few tags in my HTML
<img alt="" src="http://www.mydomain/fullpath/13101571jjc-banner.png" />
<img alt="" src="http://www.mydomain/fullpath/0c1bc6fbchart-1.png" style="width:400px" />
<img alt="" src="http://www.mydomain/fullpath/f7802520graph1.png" style="height:288px; width:643px" />
<img alt="" src="http://www.mydomain/fullpath/4cd70c03sample_s-l_DISTRIBUTION.jpg" style="height:756px; width:1056px" />
and 4th image is not showing up in my PDF.**
I understand that it may have something to do with Height and Width attribute on img tag but I am not able to solve it.
Note : image show up properly when I remove either Height or Width or both attributes from img tag. But actual user using my code won't do that every time they add a new image in HTML so I am looking for a proper solution here.
Thank you in advance for any suggestion and solution.
On one hand the style attribute of your problem image looks like this:
style="height:756px; width:1056px"
On the other hand you use an A4 sized document
Document pdfDoc = new Document(PageSize.A4, 0, 0, 0, 18f);
and an A4 page has a width of about 8.27in which at 96px per inch are about 794px.
Thus, an A4 page simply is not width enough for a 1056px wide image!
So to accommodate the image you can either
change the document size to something wider, or
before feeding the HTML into iTextSharp apply a preprocessing step which checks it for inappropriate attribute values and fixes them, or
change the HTML generation process to not produce such inappropriate attribute values to start with.
In an additional comment you asked
What should be the max-width and max-height of an image in order to get it printed correctly?
Considering that you explicitly set the left, right, and top margin to 0 and the bottom margin to 18 user units (by default a user unit is a 1/72 in), the maximum image width will likely be about 794px and the maximum image height about (1122 - 18 * 96 / 72)px = 1098px. To be sure subtract yet another few pixels.
This of course depends on your HTML not adding additional margins or cell borders or whatever around the image...
I'm looking for nodes that are circles with a font-icon in the middle and the stock label below. This (http://jsbin.com/hiqega/3/edit?js,output) is really close to what I'm looking for except that I need to pass the font name and the icon code to use.
function nodeImage(color, icon, font)
{
var svg = '<svg xmlns="http://www.w3.org/2000/svg" ' +
'width="120" height="120" viewPort="0 0 120 120">' +
'<ellipse ry="55" rx="55" cy="60" cx="60" ' +
'style="fill:' + color + ';stroke:black;stroke-opacity:.5;stroke-width:4;" />' +
'<text x="61" y="63" text-anchor="middle" dominant-baseline="middle" ' +
'style="font-family:' + font + ';font-size:100px;fill:black;fill-opacity:.5;">' +
icon + '</text>' +
'</svg>';
return 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(svg);
}
I'm calling this like so nodeImage('red', '', 'FontAwesome') in a page that is already using the font elsewhere so I don't think the issue is that it's not loaded.
Here's a pic of the resulting node
Any suggestions on where I'm going wrong?
I think you need to write nodeImage('red', '\uf03d', 'FontAwesome'). http://visjs.org/examples/network/nodeStyles/icons.html
"Remember! Unicode in javascript is done like this: \uf274 for the unicode f274.
If a node is shown as a rectangle, it means the css is not loaded (or not yet loaded). A redraw will fix that."
I have this text field that has right arrow included in the text field that I have set but the text appearing in the resulting PDF file has no right arrow with it.
<textElement textAlignment="Center" verticalAlignment="Middle" markup="html">
<font fontName="Calibri" size="8" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{generalManager} + " \u2192 " + $F{manager} + " \u2192 " + $F{teamLeader} + " - EE Count: " + $F{totalEmployeeCount}]]></textFieldExpression>
Note: When I change the font to DejavuSans, the right arrow appears.
Is there any work around for Calibri? I have also searched that Calibri, along with DejavuSans, supports right arrow, what could be the problem here?