Displaytag cannot export PDF, RTF?????? has been resolved
Because of the need to do graduation design, so from today on the need to consider the issue of paging, the first is to look for available open source framework for reference use, so in
After reviewing many articles on the internet, I locked the target to the display tag, the use of display tag, mainly focused on several aspects: paging (including
Paging to and from the database), sorting columns, and exporting data.
There is a lot of relevant information on the Internet, but many of the articles reproduced are quite similar. So it was a foreshadowing of some problems.
I have imported the relevant packages according to most of the online statements:
Displaytag-1.2.jar
Commons-lang-2.6.jar
Standard.jar
Commons-beanutils-1.8.3.jar
Commons-collections-3.2.1.jar
Commons-logging-1.1.1.jar
Itext-5.0.6.jar
Jstl.jar
Displaytag-export-poi-1.2.jar
Displaytag-portlet-1.2.jar
And we've got a simple example that you want to test for paging and exporting. But I found out how I couldn't export the data in PDF and RTF format (more accurately, on the page
The export feature is not available because it shows only the label or button for CSV, XML, or Excel, but does not display PDFs, RTF labels, or buttons! And the loss in NetBeans.
In the slaughter, the Tomcat logs, server logs, program output are not prompt exception! )。 There is no Chinese in my data. Baffled, not found on the Internet
Reasonable or relevant explanations, it seems that all are speaking Chinese questions!
So helpless, the introduction of Itextasian.jar, but found that the problem remains.
Tangled, and checked the configuration of Web. XML, found that it is configured correctly, otherwise it should throw an exception. And I'm under the default package.
displaytag.properties file The corresponding property set is also true, so what is the problem?
I configure the following:
#sort. behavior=list
#sort. Amount=list
#basic. Empty.showtable=true
#basic. msg.empty_list =no results matched your criteria.
#paging. Banner.placement=top
#paging. Banner.onepage=<span class= "Pagelinks" ></SPAN>
Export.types=csv Excel XML PDF rtf
Export.excel=true
export.csv=true
export.xml=true
Export.pdf=true
Export.rtf=true
Export.excel.class=org.displaytag.export.excel.defaulthssfexportview
Export.pdf.class=org.displaytag.export.defaultpdfexportview
Export.rtf.class= Org.displaytag.export.DefaultRtfExportView
Paging.banner.placement=bottom
# If set, file is downloaded instead of opened in the browser window
#export. [ Mymedia].filename=
Why not?
Helpless, I had to open the Displaytag-1.2.jar inside the org.displaytag.properties in the displaytag.properties file, want to copy the content
Go to my new property file. There is still a problem after deploying the project.
Finally, forced to check the relevant export to use the class, namely Org.displaytag.export.excel.DefaultHssfExportView,
Org.displaytag.export.DefaultPdfExportView, Org.displaytag.export.DefaultRtfExportView and so on.
Finally found some of the class is actually some import class missing! The original is still missing package! Have to admire, on-line those reprint articles, reproduced, but not to test, the result "to falsely
To pass false. "
After several twists and turns, I finally found that there is a package, that is itext-1.3.1.jar!!!!!!!! I can find the relevant download in CSDN!!!!
Download Place: http://download.csdn.net/source/2819666
After the package, found NetBeans inside the relevant import or display red, but careful inspection, indeed has been imported! Post-deployment discovery CSV Excel XML PDF rtf Five
All formats can be exported!
(after inspection, found that the Itext package and the Itext package is equivalent, the hint is missing package, may be tomcat itself bug, changed a glassfish after the no hint ...) )
Also attached, other useful URLs:
http://sourceforge.net/projects/itext/files/
http://sourceforge.net/projects/itext/files/extrajars/ExtraJars1.0/
Http://sourceforge.net/projects/itext/files/extrajars/ExtraJars1.0/iTextAsian.jar/download
PostScript: When the time to get more late, so no further down operation, and then click on the link to find Excel link error, throw an exception as follows:
Org.apache.jasper.JasperException:javax.servlet.ServletException:java.lang.NoClassDefFoundError:
Org/apache/poi/hssf/usermodel/hssfworkbook
After inspection, it is found that import Poi-3.7-20101029.jar is also required. Then import.
It is strange to find the problem still after importing.
I re-created the new Displaytag.properties file under the default package in the project source package, which is also a reference from the online approach. We know that in the project the import package
There is also a more complete properties file in Displaytag-1.2.jar, and according to an example I searched online, in the new properties file
There is no such sentence: Export.excel.class=org.displaytag.export.excel.defaulthssfexportview
Although I think it is the same as add or no add (because it exists in the more complete attribute file). Finally try to go, or you have to change the less
My properties file is written like this:
#sort. behavior=list
#sort. amount=list
#basic. empty.showtable=true
#basic. Msg.empty_list=no results matched your criteria.
#paging. Banner.placement=top
#paging. Banner.onepage=<span class= "Pagelinks" ></span>
Export.types=csv Excel XML PDF rtf
Export.excel=true
Export.csv=true
Export.xml=true
Export.pdf=true
Export.rtf=true
Export.excel.filename=page.xls
Export.csv.filename=page.csv
Export.pdf.filename=page.pdf
Export.rtf.filename=page.rtf
Export.pdf.class=org.displaytag.export.defaultpdfexportview
Export.rtf.class=org.displaytag.export.defaultrtfexportview
Paging.banner.placement=bottom
# If set, file is downloaded instead of opened in the browser window
#export. [Mymedia].filename=
But in my impression, the last time that it seems to be no problem, the other PDF directly on the browser can also be problematic, the symptom is that the Web tab automatically closed (I use the
is 360 browser). Export.pdf.filename=xxx must be set to open in a browser download .....
Helpless, think of this afternoon just updated 360 browser with Adobe Reader (happened the same day) ... Where's the problem? The hell knows ....
Postscript:
The previous study did not consider Chinese, and later I studied it and found that the class that was originally used to open Excel was
Org.displaytag.export.excel.ExcelHssfView, so I changed the contents of the configuration file back to the original:
Export.excel.class=org.displaytag.export.excel.excelhssfview
This will enable the correct display of Chinese in Excel.
Speaking of this, because it is the study of the output of Chinese garbled problem, so it is necessary to point out that I am here to refer to an article, Source: Ipsos
The following is an excerpt:
“
List Displaytag 1.2 Chinese PDF with excel in Chinese garbled solution:
Excel garbled part (use Poi-3.2-final-20081019.jar)//Note the version, otherwise may prompt missing partial method ....
1. Please download Displaytag-export-poi-1.2.jar
2. Join Export.excel.class=org.displaytag.export.excel.excelhssfview in Displaytag.properties
PDF Chinese Vanishing section (using Itext 2.1.5)
1. Please download Itextasian.jar
2. Please download source code for Displaytag 1.2
3. Copy the Pdfview.java in Org.displaytag.export in your own package
4. Changes in Inittable ()
1
Smallfont = Fontfactory.getfont (Fontfactory.helvetica, 7, Font.normal, new Color (0, 0, 0))
Become
1
Smallfont = Fontfactory.getfont ("Mhei-medium", "unicns-ucs2-h", font.defaultsize);
5. Join Export.pdf.class=com.kymco.displaytag.export.pdfview in Displaytag.properties, where
Com.kymco.displaytag.export should be changed to your own package
”
For the above paragraph, it is very useful for reference, but in the actual use of the process, or encountered a problem, for which the "use of Itext 2.1.5", I practice to prove that this
No, an older package is required, or an exception will be thrown: org.apache.jasper.JasperException:javax.servlet.ServletException:
Java.lang.NoSuchMethodError:com.lowagie.text.Table.setDefaultVerticalAlignment (I) v.
As for the solution, see this excerpt from the Internet:
“
Export to PDF uses deprecated IText method
Export Application Server:apache Tomcat 6
Description:hide Export to PDF throws
Java.lang.NoSuchMethodError:com.lowagie.text.Table.setDefaultVerticalAlignment (I) V
This is a deprecated method (since IText 2.1 I think), and (Captain Obvious) it does don't work with IText 5.0.1
That
”
From the above paragraph we can draw a few conclusions:
One, the Itext-1.3.1.jar we used before is obviously an old bag, and Itext-5.0.6.jar is a new package, and the letter T one is uppercase and one is lowercase. Obviously
Displaytag need to use the old bag, the new package is useless.
Second, to know that Displaytag and itext belong to two frames, the developers are different, so it is clear that their update speed is not synchronized. Cause we still need to use the old bag.
There is another exception: Org.apache.jasper.JasperException:javax.servlet.ServletException:java.lang.NoSuchMethodError:
Com.lowagie.text.Rectangle.width () F
But even if I used the oldest bag, I also found that the exception is still ... Completely without words ...
And even if it was in English, there were problems with the export. I knew this would be a good backup first ...
Finally, I re-built a project to step through the backup and find that the exception should not be thrown, and it seems that the problem is from NetBeans itself.
errors, which are estimated to be the cache, or the internal configuration file for what the record was.
Hey ~~~~~~~ remember the previous encounter similar situation did not expect this time again met ... It seems that NetBeans is unreliable ....
After my careful examination found that displaytag1.2 and ITEXT5 is not fully compatible, that is, once you want to modify the Displaytag inside the class, often encountered looking for
Not in the case of a class. Of course, the direct use of iText5.0.6, and not to solve the export data contained in Chinese and the problem arises, the direct use of iText5.0.6 is not serious.
Just follow the online approach, always unable to solve the CSV, PDF display problem in Chinese. Excel can do this by setting:
Export.excel.class=org.displaytag.export.excel.excelhssfview to solve. RTF itself can be exported normally. XML itself can be displayed as normal.
So, the problem is csv garbled, pdf Chinese is blank.
Next, attach my property configuration:
#sort. Behavior=list
#sort. Amount=list
#basic. Empty.showtable=true
#basic. Msg.empty_list=no results Matched your criteria.
#paging. Banner.placement=top
#paging. Banner.onepage=<span class= "Pagelinks" ></SPAN>
Export.types=csv Excel XML PDF rtf
Export.excel=true
export.csv=true
export.xml=true
Export.pdf=true
Export.rtf=true
Export.excel.filename=page.xls
Export.csv.filename=page.csv
Export.pdf.filename= Page.pdf
Export.rtf.filename=page.rtf
Export.excel.class=org.displaytag.export.excel.excelhssfview
Export.pdf.class=testlist.pdfviewsupportasian
Export.rtf.class=org.displaytag.export.defaultrtfexportview
Paging.banner.placement=bottom
# If set, file is downloaded instead of opened in the browser window
#export. [Mymedia].filename=
One of the Testlist.pdfviewsupportasian is made by modifying Org.displaytag.export.PdfView.
Use requires that the Itext version cannot be 5 or above. However, it is still not possible to solve the problem of Chinese display blank.
The contents of the Displaytag library I set up are:
Displaytag-1.2.jar
Commons-lang-2.6.jar
Standard.jar
Commons-beanutils-1.8.3.jar
Commons-collections-3.2.1.jar
Commons-logging-1.1.1.jar
Itext-2.1.5.jar
Jstl.jar
Displaytag-export-poi-1.2.jar
Displaytag-portlet-1.2.jar
Poi-3.2-final-20081019.jar
Itextasian.jar
Finally, I was thinking: should I try using ITEXT5? Because perhaps it has already supported the Chinese, utf8???? But then you need to find my solution.
The way to go, can not copy other people's plan.
............................................................
Cup with .....
Postscript:
For the above questions, I have a new answer, you see my other article: "Displaytag Chinese question exploration log notes"
Postscript:
The issue of PDF output Chinese as blank has been solved.
See my other article, "Displaytag Internationalization exploration log Notes", because I don't have a problem configuring the properties file correctly. Default locale for the system
Is ZH_CN, and I was in the configuration only pay attention to displaytag.properties, did not carefully check displaytag_zh_cn.properties, there because I wrote the project before
The problem is not written correctly, so it causes the problem.
After I corrected the problem, see the Displaytag Internationalization exploration log note, I then retried the export of the source cable network Displaytag
Can be garbled in Chinese ... "mentioned in the method, found that I wrote Testlist.pdfviewsupportasian its effect.
However, there are a few things to keep in mind during this period: see my comments on the page:
<%--incredibly can output PDF, but after the Adobe9 update, and the font is not good looking, what are the suggestions for improvement?
Recall that the original point when exporting a PDF, prompted that the server is not responding.
And just because of the wrong link name, so that the page does not show the "Export PDF" button, this should be noted later. --%>
That is, I wrote the wrong address bar at the beginning of the link name, and then corrected, so I can access. and recall the initial, has been prompted the server is not responding, do not know is
It's not because I might have the wrong property file, and now it's out of the way because I'm not doing the main project, so I don't have a regular backup.
Besides, that font doesn't look good. And in the meantime, Adobe Reader 9 prompted the update of the Chinese font library ...
So before the server can not respond to the problem is because of configuration problems, or the font does not support the problem, it is impossible to trace.
Finally, the font is so ugly, what's the best thing to change?
Postscript:
I found an article on the Internet: "Itext Chinese processing PDF (turn)", according to its tips, I changed the font to the song body, more beautiful.
Specific changes can be found in my space, "itext Chinese processing PDF (turn) (change)"
Collected in 2011-03-02
Displaytag cannot export PDF, RTF?????? has been resolved