1
import
org.zefer.pd4ml.PD4ML;
import
org.zefer.pd4ml.PD4Constants;
...
2
protected
Dimension format
= PD4Constants.A4;
protected
boolean
landscapeValue =
false;
protected
int topValue
= 10;
protected
int leftValue
= 10;
protected
int rightValue
= 10;
protected
int bottomValue
= 10;
protected
String unitsValue
= "mm";
protected
String proxyHost
= "";
protected
int proxyPort
= 0;
3 protected
int
userSpaceWidth =
780;
...
private
void
runConverter(String urlstring,
File output)
throws
IOException {
if
(urlstring.length() >
0) {
if
(!urlstring.startsWith("http://") && !urlstring.startsWith("file:"))
{
urlstring
= "http://"
+ urlstring;
}
4 java.io.FileOutputStream
fos =
new
java.io.FileOutputStream(output);
5 if
( proxyHost
!= null
&& proxyHost.length()
!= 0
&& proxyPort
!= 0
) {
System.getProperties().setProperty("proxySet",
"true");
System.getProperties().setProperty("proxyHost",
proxyHost);
System.getProperties().setProperty("proxyPort",
"" +
proxyPort);
}
6 PD4ML
pd4ml =
new PD4ML();
7 try
{
pd4ml.setPageSize( landscapeValue
? pd4ml.changePageOrientation( format
):
format );
}
catch
(Exception e)
{
e.printStackTrace();
}
if
( unitsValue.equals("mm")
) {
pd4ml.setPageInsetsMM(
new
Insets(topValue, leftValue,
bottomValue,
rightValue) );
}
else {
pd4ml.setPageInsets(
new
Insets(topValue, leftValue,
bottomValue,
rightValue) );
}
pd4ml.setHtmlWidth(
userSpaceWidth );
8 pd4ml.render(
urlstring, fos
);
}
}
...
|