Java - Passar url https a pdf - Pasar url a html con css

 
Vista:

Passar url https a pdf - Pasar url a html con css

Publicado por fenix (2 intervenciones) el 30/06/2016 11:30:35
Hola, estoy teniendo problemas para guardar una direccion https a pdf.

El primer de los problemas que me he encontrado es que el paso intermedio que es pasar la url a html me lo guarda sin el formato. (o sea sin css).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
public static void main(String[] args) throws Throwable {
	// TODO Auto-generated method stub
 
	javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(
			new javax.net.ssl.HostnameVerifier(){
 
				public boolean verify(String hostname,
						javax.net.ssl.SSLSession sslSession) {
					System.out.println("nom: "+hostname);
					return hostname.equals("EC-SAFP");
					//  return hostname.equals("google");
				}
			});
 
	// String uriTest = "https://contractaciopublica.gencat.cat/ecofin_pscp/AppJava/awardnotice.pscp?lawType=2&reqCode=viewDcan&idDoc=16570428";
	//String uriTest = "https://lacaixa.es";
	//String htmlDesti="caixa.html";
	String uriTest = "http://www.udg.edu/";
	String htmlDesti="spanish.html";
		URL url;
 
		try {
		//----------------------- HTML CREATTION ------------------------
		// get URL content
		url = new URL(uriTest);
		// HttpsURLConnection connection = (HttpsURLConnection)url.openConnection();
		HttpURLConnection connection = (HttpURLConnection) url.openConnection();
		connection.getInputStream();
		// open the stream and put it into BufferedReader
		BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
		String inputLine;
 
		//save to this filename
		//String fileName = "C://WorkspacePSCP/857-PSCP/pdf_converter2/temp_html.html";
		File file = new File(htmlDesti);
		if (!file.exists()) {
		file.createNewFile();
		}
		//use FileWriter to write file
		FileWriter fw = new FileWriter(file.getAbsoluteFile());
		BufferedWriter bw = new BufferedWriter(fw);
		while ((inputLine = br.readLine()) != null) {
		bw.write(inputLine);
		System.out.println(inputLine);
		}
		bw.close();
		br.close();
		System.out.println("Html Creation Done");
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder