Convert Jsf File To Pdf



It is a command line utility that can be provided an html file or web address and a save location for the pdf. Very easy to use and utilizes the same rendering engine as safari. Works MUCH better than many of the other parsers that I have used (that don't always support CSS and other advanced layout features. Upload your image to the JPG to PDF converter. Adjust the letter size, orientation, and margin as you wish. Click ‘Create PDF now!’ and wait for the conversion to take place. And that's all there is. Right-click a file with the extension whose association you want to change, and then click Open With. In the Open With dialog box, click the program whith which you want the file to open, or click Browse to locate the program that you want. Select the Always use the selected program to open this kind of file check.

Ranch Hand
posted 15 years ago
what is the best way to have pdf if all my pages are in jsf?
i'm planning to let user to print in pdf format when they click the 'print' button..
any suggestions on how to start with it?

Jys<br /><a href='http://jy-s.com' target='_blank'>http://jy-s.com</a><br /> <br />Trying my very best to learn java, please forgive me if i'm asking some really stupid questions.

Ranch Hand
posted 15 years ago
Ranch Hand
posted 15 years ago
i've read the thread.. hmm, by using this method provided i can actually convert my stuff into pdf?

and this line.. response.getOutputStream().write(yourdata[]);
i will pass all the things i want to retrieve from database here? do u happened to have a complete example for me to refer?
thks in advance..

Jys<br /><a href='http://jy-s.com' target='_blank'>http://jy-s.com</a><br /> <br />Trying my very best to learn java, please forgive me if i'm asking some really stupid questions.

Rancher
posted 15 years agoConvert Jsf File To Pdf
The code snippet assumes that the 'yourdata' array holds the contents of a PDF file. To create a PDF file from your database data, you will need to use some PDF library, such as mentioned here.
Ranch Hand
posted 15 years ago
so how will 'yourdata' look like? xml? html?
sorry, this is my first time generating pdf so i'm not really sure what do i need and how do i do that.

Jys<br /><a href='http://jy-s.com' target='_blank'>http://jy-s.com</a><br /> <br />Trying my very best to learn java, please forgive me if i'm asking some really stupid questions.

Rancher
posted 15 years ago
'yourdata' should contain a binary representation of the PDF file. That you can create by using a PDf libraray, as mentioned in my previous post. iText in particular has a thorough introduction.
Ranch Hand
posted 15 years ago
from the iText eg, i see that most of it are using servlet. just wondering, is it possible to have pdf without using servlet?

Jys<br /><a href='http://jy-s.com' target='_blank'>http://jy-s.com</a><br /> <br />Trying my very best to learn java, please forgive me if i'm asking some really stupid questions.

Rancher
posted 15 years ago
The servlets just serve as examples. iText can be used in any kind of Java program.
Ranch Hand
posted 15 years ago
So Jolie, any success? I mean, have you actually tried out any of the suggestions and code we've provided?
Ranch Hand
posted 15 years ago
i've actually read thru the itext.. and one of the example their using jsp with iText to generate...
hmm.. might used that, but still not sure how they do column and etc .. cos wat i can see is that they only using paragraph.. cos i'm generating reports, so they will be a lot of columns and tables involves...
in my jsp page, how can i called the backing bean? cos if i were to use jsp to generate pdf(s), i may need to refer to backing beans to do retrieval from the database.. and i think i won't have any jsf tags in that jsp page that generate pdf...

Jys<br /><a href='http://jy-s.com' target='_blank'>http://jy-s.com</a><br /> <br />Trying my very best to learn java, please forgive me if i'm asking some really stupid questions.

Ranch Hand
posted 15 years ago
Jolie, Jolie, Jolie...
Remember that method I showed you?

Ok, lets change that just a bit...

Now, supose you have a commandButton that calls a backing bean method called generatePDF(). Let's take a look at what that method might look like..

And that's it. It can all be done in the backing bean. That is what we have been trying to convey.
Greenhorn
posted 15 years ago
use this.
it will work
am doing this works great with itext.
public void executePDF() {
try {
FacesContext faces = FacesContext.getCurrentInstance();
HttpServletResponse response =
(HttpServletResponse) faces.getExternalContext().getResponse();
// setting some response headers
response.setHeader('Expires', '0');
response.setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
//response.setHeader('Content-disposition','inline; filename=kiran.pdf');
response.setHeader('Pragma', 'public');
response.setContentType( 'application/pdf' );
//response.setHeader('Content-Disposition', 'attachment;filename='ContactList.pdf');
response.addHeader('Content-disposition', 'attachment;filename='DataListBean.pdf');
//step 1: creation of a document-object
Document document = new Document(PageSize.A3.rotate(), 10, 10, 10, 10);
//step 2: we create a writer that listens to the document
// and directs a PDF-stream to a temporary buffer
ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
PdfWriter writer = PdfWriter.getInstance( document, baos);
//step 3: we open the document
document.open();
Table datatable = getTable();
int rowCount = data.getRowCount();
// step 4: we add a paragraph to the document
for (int i=0;i<rowCount;i++) {
datatable.setDefaultHorizontalAlignment(Element.ALIGN_LEFT);
List list = (List)data.getRowData();
Iterator iter = list.iterator();
while(iter.hasNext()) {
Object obj = (Object) iter.next();
datatable.addCell(obj.toString());
if (i<=2) {
System.out.println(obj.toString());
}
}
if (!writer.fitsPage(datatable)) {
datatable.deleteLastRow();
i--;
document.add(datatable);
document.newPage();
datatable = getTable();
}
}
document.add(datatable);
//step 5: we close the document
document.close();
//step 6: we output the writer as bytes to the response output
// the contentlength is needed for MSIE!!!
response.setContentLength(baos.size());
// write ByteArrayOutputStream to the ServletOutputStream
ServletOutputStream out = response.getOutputStream();
baos.writeTo(out);
baos.flush();
faces.responseComplete();
//DataOutput output = new DataOutputStream( response.getOutputStream() );
//byte[] bytes = buffer.toByteArray();
//response.setContentLength(bytes.length);
//for( int i = 0; i < bytes.length; i++ ) { output.writeByte( bytes[i] ); }
} catch(Exception e) {
e.printStackTrace();
}
}
private Table getTable()
throws BadElementException, DocumentException {
int colCount = columnHeaders.getRowCount();
Table datatable = new Table(colCount);
datatable.setPadding(4);
datatable.setSpacing(0);
datatable.setBorder(Rectangle.NO_BORDER);
int headerwidths[] = {14,3,3,9,8,5,14,9,5,3,1,4,4,10,3,3,2,10,10,2};
datatable.setWidths(headerwidths);
datatable.setWidth(140);
// the first cell spans 20 columns
Cell cell = new Cell(new Phrase('NEMO Order Tool Report',
FontFactory.getFont(FontFactory.HELVETICA, 14, Font.BOLD)));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setLeading(10);
cell.setColspan(20);
cell.setBorder(Rectangle.NO_BORDER);
cell.setBackgroundColor(new Color(0xC0, 0xC0, 0xC0));
datatable.addCell(cell);
// These cells span n rows
datatable.setDefaultCellBorderWidth(1);
datatable.setDefaultHorizontalAlignment(1);
datatable.setDefaultRowspan(1);
List colList = (List)columnHeaders.getWrappedData();
for (int i=0; i < colList.size();i++) {
ColumnHeader header = (ColumnHeader) colList.get(i);
datatable.addCell(header.getLabel());
}
return datatable;
}
Greenhorn
posted 9 years ago

sridhar panini wrote:use this.
it will work
am doing this works great with itext.
public void executePDF() {
try {
FacesContext faces = FacesContext.getCurrentInstance();
HttpServletResponse response =
(HttpServletResponse) faces.getExternalContext().getResponse();
// setting some response headers
response.setHeader('Expires', '0');
response.setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
//response.setHeader('Content-disposition','inline; filename=kiran.pdf');
response.setHeader('Pragma', 'public');
response.setContentType( 'application/pdf' );
//response.setHeader('Content-Disposition', 'attachment;filename='ContactList.pdf');
response.addHeader('Content-disposition', 'attachment;filename='DataListBean.pdf');
//step 1: creation of a document-object
Document document = new Document(PageSize.A3.rotate(), 10, 10, 10, 10);
//step 2: we create a writer that listens to the document
// and directs a PDF-stream to a temporary buffer
ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
PdfWriter writer = PdfWriter.getInstance( document, baos);
//step 3: we open the document
document.open();
Table datatable = getTable();
int rowCount = data.getRowCount();
// step 4: we add a paragraph to the document
for (int i=0;i<rowCount;i++) {
datatable.setDefaultHorizontalAlignment(Element.ALIGN_LEFT);
List list = (List)data.getRowData();
Iterator iter = list.iterator();
while(iter.hasNext()) {
Object obj = (Object) iter.next();
datatable.addCell(obj.toString());
if (i<=2) {
System.out.println(obj.toString());
}
}
if (!writer.fitsPage(datatable)) {
datatable.deleteLastRow();
i--;
document.add(datatable);
document.newPage();
datatable = getTable();
}
}
document.add(datatable);
//step 5: we close the document
document.close();
//step 6: we output the writer as bytes to the response output
// the contentlength is needed for MSIE!!!
response.setContentLength(baos.size());
// write ByteArrayOutputStream to the ServletOutputStream
ServletOutputStream out = response.getOutputStream();
baos.writeTo(out);
baos.flush();
faces.responseComplete();
//DataOutput output = new DataOutputStream( response.getOutputStream() );
//byte[] bytes = buffer.toByteArray();
//response.setContentLength(bytes.length);
//for( int i = 0; i < bytes.length; i++ ) { output.writeByte( bytes[i] ); }
} catch(Exception e) {
e.printStackTrace();
}
}
private Table getTable()
throws BadElementException, DocumentException {
int colCount = columnHeaders.getRowCount();
Table datatable = new Table(colCount);
datatable.setPadding(4);
datatable.setSpacing(0);
datatable.setBorder(Rectangle.NO_BORDER);
int headerwidths[] = {14,3,3,9,8,5,14,9,5,3,1,4,4,10,3,3,2,10,10,2};
datatable.setWidths(headerwidths);
datatable.setWidth(140);
// the first cell spans 20 columns
Cell cell = new Cell(new Phrase('NEMO Order Tool Report',
FontFactory.getFont(FontFactory.HELVETICA, 14, Font.BOLD)));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setLeading(10);
cell.setColspan(20);
cell.setBorder(Rectangle.NO_BORDER);
cell.setBackgroundColor(new Color(0xC0, 0xC0, 0xC0));
datatable.addCell(cell);
// These cells span n rows
datatable.setDefaultCellBorderWidth(1);
datatable.setDefaultHorizontalAlignment(1);
datatable.setDefaultRowspan(1);
List colList = (List)columnHeaders.getWrappedData();
for (int i=0; i < colList.size();i++) {
ColumnHeader header = (ColumnHeader) colList.get(i);
datatable.addCell(header.getLabel());
}
return datatable;
}


Convert Jsf File To Pdf Hello sridhar panini,
Please, can you give me the libraries used for this code? Thank you
Ranch Hand
posted 9 years ago
Hello,
I will suggest use Jasper reports, you will get the PDF within no time.
I have the made a sample long ago. If you want let me know.
BR,

Prithvi,
My Blog, Follow me on Twitter,Scjp Tips, When you score low in mocks, Generics,Scjp Notes, JavaStudyGroup

Greenhorn
posted 9 years ago

Jsp To Pdf

Hello Prithvi Sehgal,
I tried to use JasperReport 3.7.5 but I got some problemes. This my code with JasperReport

When I run this code, I get an empty pdf. Please can you help me to use Jasperreport to make my Reports.
Thank You
Ranch Hand
posted 9 years ago
Hello Boris,
I didn't look at the code before. Try to pick .jasper directly from IReport and see.
It should work. From where you data is coming?
HTH,

Prithvi,
My Blog, Follow me on Twitter,Scjp Tips, When you score low in mocks, Generics,Scjp Notes, JavaStudyGroup

Ranch Hand

Jsf To Pdf Converter Online

posted 9 years ago
Hello Boris,
I can see that you are using the compiler inside the code. I wanted to know from where
your data is coming?
Checkout my snippet of code.

BR,

Prithvi,
My Blog, Follow me on Twitter,Scjp Tips, When you score low in mocks, Generics,Scjp Notes, JavaStudyGroup

Greenhorn
posted 9 years agoI try your code, but I get always an empty pdf

Convert Jsp File To Pdf

I wanted to know from where your data is coming?


With ireport, I defined a Database JBDC Connexion. And, in my jrxml file, I used a query whose the database connexion parameters are defined in the Database JBDC Connexion. I hope that I answered correctly to your question. English isn't my mother tongue, so excuse me for my bad english
Thank you
Ranch Hand
posted 9 years ago
Hello Boris,
Thats true. So basically is your query parameter based, like a criteria query. For example, find all all employees
whose salary is greater then your specified parameter. If you see that, you are passing a empty hashmap to your
jrxml. You are not passing any parameters. You need to put your parameters in the hashmap and send that hashmap.
Be sure that your your parameter in Hashmap is of the same name as in the JRXML.
HTH,

Prithvi,
My Blog, Follow me on Twitter,Scjp Tips, When you score low in mocks, Generics,Scjp Notes, JavaStudyGroup

Greenhorn
posted 9 years ago
I don't pass parameter because my query don't have parameter. You can see my jrxml file
Ranch Hand
posted 9 years ago
Hello Boris,
Where are you calling the getConnection() method to get the connection. In your code, i don't see anywhere that you are calling
the getConnection method.
Put in your printPdf() method as

I feel your connection reference is not properly initialized.
Have you checked your SQL in a editor like SQL editor, is it returning any results? Additionally, try to use the .jasper file directly and comment
the JRXML compile. To me your JRXML looks okay. Additionally, check is is your connection object null means is it able to correct to database
properly?
BR,

Prithvi,
My Blog, Follow me on Twitter,Scjp Tips, When you score low in mocks, Generics,Scjp Notes, JavaStudyGroup

Greenhorn
posted 9 years ago
Hello,
Now the report is generated, but I can't open it because it is used by another process. After verification, this is the process 'java.exe' which use the genereted report.
I try to resolve it. Please, don't forget me If you have an idea to resolve the probleme.
I appreciate the attention you have given me
Ranch Hand
posted 9 years ago
Hello Boris,
Can you tell me what exception you are getting exactly? Additionally i would like to know did you try to use
.jasper file directly rather then using the built in compile utility.
BR,

Prithvi,
My Blog, Follow me on Twitter,Scjp Tips, When you score low in mocks, Generics,Scjp Notes, JavaStudyGroup

File typeAdobe Fireworks Batch Script
DeveloperAdobe
Ads

How to open JSF files

If you cannot open the JSF file on your computer - there may be several reasons. The first and most important reason (the most common) is the lack of a suitable software that supports JSF among those that are installed on your device.

A very simple way to solve this problem is to find and download the appropriate application. The first part of the task has already been done – the software supporting the JSF file can be found in the table. Now just download and install the appropriate application.

Program(s) that can open the .JSF file

More information about JSF file

JSF file extension is used by script command files generated by Adobe Fireworks (formerly Macromedia Fireworks) graphics editing software. JSF files store JavaScript code command sequences.

JSF file format applications

Commands stored in JSF file are used for automating frequently executed tasks in Adobe Fireworks. Such command sequences can, for example, change color or size of given shape. Single JSF file can store virtually unlimited number of such commands.

Possible problems with the JSF format files

The inability to open and operate the JSF file does not necessarily mean that you do not have an appropriate software installed on your computer. There may be other problems that also block our ability to operate the Adobe Fireworks Batch Script file. Below is a list of possible problems.

  • Corruption of a JSF file which is being opened
  • Incorrect links to the JSF file in registry entries.
  • Accidental deletion of the description of the JSF from the Windows registry
  • Incomplete installation of an application that supports the JSF format
  • The JSF file which is being opened is infected with an undesirable malware.
  • The computer does not have enough hardware resources to cope with the opening of the JSF file.
  • Drivers of equipment used by the computer to open a JSF file are out of date.

If you are sure that all of these reasons do not exist in your case (or have already been eliminated), the JSF file should operate with your programs without any problem. If the problem with the JSF file has not been solved, it may be due to the fact that in this case there is also another rare problem with the JSF file. In this case, the only you can do is to ask for assistance of a professional staff.

Similar extensions

.aawdefAd-Aware Definitions Format
.abrAdobe Photoshop Brush Format
.ac$AutoCAD Undo Info Format
.accDR DOS - ViewMax Format
.aclMicrosoft Office Automatic Correction List
.acsMicrosoft Agent Character Structured Storage Format
.adAfter Dark Screen Saver Format
.addMicrosoft Dynamics AX Developer Documentation Format
How to associate the file with an installed software?

If you want to associate a file with a new program (e.g. my-file.JSF) you have two ways to do it. The first and the easiest one is to right-click on the selected JSF file. From the drop-down menu select 'Choose default program', then click 'Browse' and find the desired program. The whole operation must be confirmed by clicking OK. The second and more difficult to do is associate the JSF file extension to the corresponding software in the Windows Registry.

Is there one way to open unknown files?

Many files contain only simple text data. It is possible that while opening unknown files (e.g. JSF) with a simple text editor like Windows Notepad will allow us to see some of the data encoded in the file. This method allows you to preview the contents of many files, but probably not in such a structure as a program dedicated to support them.