Monday, September 19, 2011
Using Java, iText fill Abode LiveCycle Designer Form
I do it by following step.
1. first, create a XML schema, which contains all the field used in the form.
2. open Adobe LiveCycle, click 'file', then select 'New...', and follow screen instruction to create a new form.
3. click 'File', then click 'New Data Connection...', then give it a name, and choice 'XML Schema', then following screen instruction to import the XML schema.
4. You can drag the data tree from the Data View panel to form. form consists of fields that are organized in subforms, click subforms, select 'Object', then click 'Subform' tab, set 'Content' to 'Flow', and check 'Allow page break'.
5. then select 'request' in data panel, then select 'Object' , then click 'Subform' tab, set 'Content' to 'Position', and check 'Allow page break'.
6. arrange all the fields as you need. save the PDF form.
to get data and fill form, we use Java language and iText API.
1. we get data from data and write to a XML file, the xml file should follow the schema.
DocumentBuilderFactory domFactory = DocumentBuilderFactory
.newInstance();
DocumentBuilder domBuilder = domFactory.newDocumentBuilder();
Document newDoc = domBuilder.newDocument();
Element rootElement = newDoc.createElement("requests");
newDoc.appendChild(rootElement);
...add other element.....
// write to file
TransformerFactory tranFactory = TransformerFactory.newInstance();
Transformer aTransformer = tranFactory.newTransformer();
Source src = new DOMSource(newDoc);
Result dest = new StreamResult(new File(destname));
aTransformer.transform(src, dest);
2. using iText to fill form.
// src is the PDF form name,
// xml is the xml file name created last step,
// dest is the output PDF file name
public void manipulatePdf(String src, String xml, String dest)
throws IOException, DocumentException {
PdfReader reader = new PdfReader(src);
PdfStamper stamper =
new PdfStamper(reader, new FileOutputStream(dest));
AcroFields form = stamper.getAcroFields();
XfaForm xfa = form.getXfa();
xfa.fillXfaForm(new FileInputStream(xml));
stamper.close();
}
other things,
1. as we don't want user fill the form, I set all the field in the PDF form to 'Read only', to do it, in LiveCycle, select the field, click 'Object', then click 'Value', then select 'Read only' as type.
Thursday, August 19, 2010
EXCEL VBA for Copy, Position and Resize Picture
For catalogue program in excel, usually need process pictures.
Following excel VBA procedure is a useful example to do the job as copy picture from other sheet, position and resize it.
Public Sub s()
Dim oPic As Picture
Sheets("Sheet2").Select
'delete picture is it existed in target sheet
On Error GoTo errorhandling
Sheet2.Pictures("Phont_123").Delete
On Error GoTo 0 ' resume
errorhandling:
For Each oPic In Sheet1.Pictures
If (oPic.Name = "photo_1234567890") Then
Sheet1.Shapes(oPic.Name).Copy
Sheet2.Range("C3").PasteSpecial
Selection.Name = "Phont_123"
Dim p As Picture
Set p = Sheet2.Pictures("Phont_123")
' position picture base on cell C3's position
With Range("c3")
t = .Height
l = .Left
End With
' resize picture, this example fixed the height as 200,
With p
oh = .Height
ow = .Width
.Top = t
.Left = l
.Width = ow * 200 / oh
.Height = 200
.Placement = xlMoveAndSize
.PrintObject = True
End With
End If
Next oPic
End Sub
Monday, March 22, 2010
MOVEX workplace using IE8
- Set IE8 to Compatibility View for Movex workplace site by click 'Tools', then click 'Compatibility View Settings', then add website.
- Create shortcut for workplace login, the program is "C:\Program Files\Internet Explorer\iexplore.exe" –nomerge. the '–nomerge' parameter solve the IE8 session merge problem, please see following url for details.
http://blogs.msdn.com/ie/archive/2009/05/06/session-cookies-sessionstorage-and-ie8.aspx
Tuesday, March 02, 2010
List file changes date
We can use following command to list the subdirectory and files with last changing date.
dir /s /od /tw Directory >list.txt
Wednesday, November 11, 2009
List Schedule Jobs
For windows server 2003 or windows Vista, you can use following command to list schedule jobs.
schtasks /query /FO CSV /V >output.csv
For IBM iSeries (AS400), you can use following command to list scheduled jobs.
WRKJOBSCDE OUTPUT(*PRINT) PRTFMT(*FULL)
Monday, October 26, 2009
Convert a IBM AS400 (iSeries) spooled file to PDF
I recently created a program to convert AS400 Spooled file to PDF. Below is the screen shot of the main screen of the program.
After the user login, he can list spooled file by date; if he has '*SPLCTL' authority, he also can list other user's spooled file.
Then he can choice the spooled he want to convert and click 'Convert' button, the PDF will generated in 'PDF Directory' and with the name as below
Spooled file+job name+user+Jobnumber+filenumber.PDF
If you want do the same thing, please let me know, I like to help.
Monday, June 29, 2009
Lenovo T61 Bluetooth
Lenovo t61 running Vista, when start up, show 3 Bluetooth peripheral devices cannot install properly.
The hardware ID is BTHENUM\{00000004-0000-1000-8000-0002ee000002}_LOCALMFG&000f.
After Google, I find following message from
http://forums.lenovo.com/lnv/board/message?board.id=T_Series_Thinkpads&message.id=15948
Hi All,
PROBLEM SOLVED, you might be missing the
D20032-002-001.exe Windows Vista WIDCOMM Bluetooth Driver version: 6.0.1.3400
I am using a T61 with a corporate image, and could never get the last Bluetooth peripheral to work in device manager.
After the installation of the "Windows Vista WIDCOMM Bluetooth Driver version: 6.0.1.3400" you will see that it relates to the "Bluetooth Imaging Responder"
Download these drivers here>>
Hope this helps.
Cheers
Monday, May 04, 2009
TOMCAT return 403
Tomcat return 403 for http://127.0.0.1:8080/thgsrp/images/uploaded/watchfront.jpg.
The resource is there, I found the reason in tomcat setting server.xml
<Host appBase="webapps" name="localhost">
<Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_log." suffix=".txt" timestamp="true"/>
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="10.1.*.*,192.168.*.*,127.0.0.1"/>
</Host>
After add 127.0.0.1 in the allow IP address, the problem solved.
Wednesday, March 25, 2009
GWT Internationalization
I find a good explain about GWT internationalization at http://markmail.org/message/kkve5qmokt6lixub
Below is the notes get from the post:
Here are my own notes to set up Internationalization (i18n) in GWT.
1. In myApp.gwt.xml
<inherits name="com.google.gwt.i18n.I18N"/> <extend-property name="locale" values="en"/> <extend-property name="locale" values="sp"/> <extend-property name="locale" values="fr"/>
2. Create 3 properties files in the client folder:
MyMessages_en.properties MyMessages_fr.properties MyMessages_sp.properties
3. Here is the content of MyMessages_en.properties (the other two files should be identical):
enBtn = English spBtn = Español frBtn = Français
4. Create 3 Button Widgets in the EntryPoint module
MyMessages myMessages = (MyMessages) GWT.create(MyMessages.class);
Button enBtn = new Button(); enBtn.setHTML(myMessages.enBtn());
Button enBtn = new Button(); enBtn.setHTML(myMessages.frBtn());
Button enBtn = new Button(); enBtn.setHTML(myMessages.spBtn());
5. Create the MyMessages.java in the client folder:
package com.myApp.client;
import com.google.gwt.i18n.client.Messages;
public interface MyMessages extends Messages { String spBtn(); String enBtn(); String frBtn(); }
6. Here is the ClickListener for one of the buttons:
enBtn.addClickListener(new ClickListener() { public native void onClick(Widget sender) /*-{ var currLocation = $wnd.location.toString().split("?"); var currLocale = "?locale=en"; $wnd.location.href = currLocation[0] + currLocale; $wnd.location.replace(currLocation[0] + currLocale); }-*/; });
7. Don't forget this meta tag in the main html file:
<meta name="gwt:property" content="locale=en">
8. Here is how to manually check that the locale are indeed changed:
or
or
Well. That's it. I believe there are enough information in this post to start the ball rolling for anyone interested to learn how to internationalize his/her GWT application.
Cheerio. |
Thursday, March 19, 2009
Saving and deleting audit journal receivers
This topic describes how to save and delete audit journal receivers, explains why it is important, and provides step-by-step instructions.
Purpose:
To attach a new audit journal receiver; to save and delete the old receiver
How to:
- CHGJRN QSYS/QAUDJRN
- JRNRCV(*GEN) SAVOBJ (to save old receiver)
- DLTJRNRCV (to delete old receiver)
Authority:
*ALL authority to journal receiver; *USE authority to journal
Note: Select a time when the system is not busy to save and delete audit journal receivers.
You should regularly detach the current audit journal receiver and attach a new one for two reasons:
- Analyzing journal entries is easier if each journal receiver contains the entries for a specific, manageable time period.
- Large journal receivers can affect system performance, in addition to taking valuable space on auxiliary storage.
Having the system manage receivers automatically is the recommended approach. You can specify this by using the Manage receiver parameter when you create the journal.
If you have set up action auditing and object auditing to log many different events, you may need to specify a large threshold value for the journal receiver. If you are managing receivers manually, you may need to change journal receivers daily. If you log only a few events, you may want to change receivers to correspond with the backup schedule for the library containing the journal receiver.
You use the CHGJRN command to detach a receiver and attach a new receiver.
System-Managed Journal Receivers: If you have the system manage the receivers, use the following procedure to save all detached QAUDJRN receivers and to delete them:
- Type WRKJRNA QAUDJRN. The display shows you the currently attached receiver. Do not save or delete this receiver.
- Use F15 to work with the receiver directory. This shows all receivers that have been associated with the journal and their status.
- Use the SAVOBJ command to save each receiver, except the currently attached receiver, which has not already been saved.
- Use the DLTJRNRCV command to delete each receiver after it is saved.
Note: An alternative to the above procedure could be done using the journal message queue and monitoring for the CPF7020 message which indicates that the system change journal has completed successfully.
Thursday, January 29, 2009
Sun Tech Day 2009
I attended the Sun Tech Day on 21 & 22 January in Singapore. It is an event worth to attend.
Saturday, November 08, 2008
Monday, August 11, 2008
How to Remote Desktop to the Console on Windows 2003
mstsc /console
Tuesday, June 10, 2008
Saturday, February 16, 2008
display excel from TOMCAT site
mime-mapping
extension xls extension
mime-type application/vnd.ms-excel MIME-TYPE
/MIME-MAPPING
also, you need add your site as intranet in web explorer, which meaning the security for your site is very low.
Sunday, February 10, 2008
set Xerox C450 as Iseries printer
the source is http://docs.google.com/Doc?id=dgts9g23_10g594d9cr .
sencond, run CRTWSCST command to generate Workstation customizing object from the source file.
third, run WRKCFGSTS, create a new printer, set 'Manufacturer type and model' as '*WSCSTA4', and set 'Workstation customizing object' as the object created in sencond step.
after printer created, run
CHGWTR WTR(printer) FORMTYPE(*ALL *NOMSG)
to prevent form type error message.
Thursday, January 24, 2008
using Fat jar plugin
seet http://sourceforge.net/projects/fjep.
Sunday, January 13, 2008
Solve installation problem of Adobe flash cs3 professional on Windows Vista
When I check event log, I see the message 'Internal Error 2739'.
I search the solustion by Google and found the solution on http://www.adobeforums.com/webx/.3bc3ddab
the step to fix the problem is
Choose Start > All Programs > Accessories.
Right-click the Command icon, choose Run As Administrator, and authenticate.
Navigate to Windows\System32. At the prompt, type regsvr32 jscript.dll and press Enter. When a dialog box with the message "DllRegisterServer in jscript.dll succeeded" appears, click Ok.
then run the setup program again.
Thursday, January 10, 2008
WebSphere Development Studio Client for iSeries JVM Crash
to solve the problem.
screen shot as bellow:
Microsoft Windows XP [Version 5.1.2600](C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\wangzj.HOURGLASS>cd C:\Program Files\IBM\SDP70\jdk\jre\bin
C:\Program Files\IBM\SDP70\jdk\jre\bin>javaw.exe -Xshareclasses:destroy
C:\Program Files\IBM\SDP70\jdk\jre\bin>