Add CSS and images to file running from Zip

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Add CSS and images to file running from Zip

Postby golu123 » Mon Jul 07, 2014 5:01 am

I tried to create a website with a single page and an images folder with images and css folder with css files in it. Then I zipped the whole thing up and then went into the zip file and trying to view the page by using CEF application. After applying some code and using JCEF application, I am able to view content of my html file inside zip, but CSS and images not applied on it.

Is there any way to set and view whole contents with images and css applied on html page directly from zip by using CEF or JCEF ? If this is possible, then can anyone please attach some sample code.

Let me know if you need more information.

Thanks,
Golu
golu123
Newbie
 
Posts: 3
Joined: Mon Jul 07, 2014 4:33 am

Re: Add CSS and images to file running from Zip

Postby magreenblatt » Mon Jul 07, 2014 10:54 am

How are you currently loading the contents of the zip archive? Are you setting the mime type correctly?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Add CSS and images to file running from Zip

Postby golu123 » Tue Jul 08, 2014 8:07 am

yes I have set mime type correctly
this is the sample code I am using
any help from your side...............

ZipFile fis = new ZipFile(pathOfZipArchive);
for (Enumeration e = fis.entries(); e.hasMoreElements();) {
ZipEntry entry = (ZipEntry) e.nextElement();
if(entry.getName().endsWith(".html")){
InputStream in = fis.getInputStream(entry);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
try {
StringBuilder sb = new StringBuilder();
String line = br.readLine();
while (line != null) {
sb.append(line);
sb.append("\n");
line = br.readLine();
}
content_=sb.toString();
}
data_ = content_.getBytes();
mime_type_ = "text/html";
handled = true;

this is the sample html and image logo.png inside the zip under image directory

<html>
<head><title>hello</title>
</head>
<body>
<p>
<img src="images/logo.jpg" />
</p>
<h2>hello</h2>
</body>
</html>
Last edited by golu123 on Wed Jul 09, 2014 1:45 am, edited 1 time in total.
golu123
Newbie
 
Posts: 3
Joined: Mon Jul 07, 2014 4:33 am

Re: Add CSS and images to file running from Zip

Postby magreenblatt » Tue Jul 08, 2014 10:02 am

Based on the code you posted you're not handling anything other than html files.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Add CSS and images to file running from Zip

Postby golu123 » Wed Jul 09, 2014 1:43 am

Yes, I am handling html files from zip archive and there are images inside 'images' folder within zip archive which I include in the html file content. Those images not applied or open when I use the sample code with CEF. Any help on rendering those images directly from zip archive without extracting that zip archive is appreciable.

Thanks,
Golu
golu123
Newbie
 
Posts: 3
Joined: Mon Jul 07, 2014 4:33 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 41 guests