display an (x)html document structure in a new window - html

For debugging purpose, I need to create an new xml document popup to display the (x)html source structure of my current document.
But the following code does not work:
var w = window.open();
w.document.open('text/xml');
w.document.write(window.document.documentElement.innerHTML);
w.document.close();
It seems that document.open() does not accept contentType anymore.
Is there any other solution ?

Just put a textarea in your existing page and copy the innerHTML into the textarea.

Related

Convert Dynamic HTML to PDF

I am using jsp to display html and css3. When I display my html page, I will have a pdf icon, if that is clicked then I need to convert the html page to pdf and download it.
I have tried using XMLWorker, but there I need to send my html link through URL. But its saying this exception, "RuntimeWorkerException: Invalid nested tag head found, expected closing tag script.". I cant hard code my html.
Is there any easy way where I just click the button, so that all the html content from page can be downloaded as pdf? As I am new to programming I couldn't fix this issue. I went through other question but there were no clear explanation regarding this.
You can use jsPDF to convert HTML to PDF online, just using JavaScript on the client side.
The initialisation code is very simple:
// You'll need to make your image into a Data URL
// Use http://dataurl.net/#dataurlmaker
var imgData = 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4ge4SUNDX1BST0ZJTEUAAQEAAAeoYXBwbAIgAABtbnRyUkdCIFhZWiAH2QACABkACwAaAAthY3NwQVBQTAAAAABhcHBsAAAAAAAAAAAAAAAAAAAAAAAA9tYAAQAAAADTLWFwcGwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtkZXNjAAABCAAAAG9kc2NtAAABeAAABWxjcHJ0AAAG5AAAADh3dHB0AAAHHAAAABRyWFlaAAAHMAAAABRnWFlaAAAHRAAAABRiWFlaAAAHWAAAABRyVFJDAAAHbAAAAA5jaGFkAAAHfAAAACxiVFJDAAAHbAAAAA5nVFJDAAAHbAAAAA5kZXNjAAAAAAAAABRHZW5lcmljIFJHQiBQcm9maWxlAAAAAAAAAAAAAAAUR2VuZXJpYyBSR0IgUHJvZmlsZQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAbWx1Yw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ooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKK4z4yfFb/hWOl2zWUMVxe3jkRpISFVQOWOOepUfjXJj8dRy2hLE4h2hHf8vzNqFCeJqKnTV2zs6K+bm/aQ8VliReW4z2FsnH6VLaftL+KLaQNNLZXAB+7JbgA/98kGvjI+I+Vt2cZr5L/5I9l8OYpdY/e/8j6Morx3QP2sY3ZV8UaUyDPMltJu/wDHGx/6FXo/hX4jaL40Uf8ACPahBNKRnySdso/4Aea+iy7iTLc1ajh6ycuz0f3O1/lc87E5bicJrUg7d91+Bt0UUV7hwhRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRVLXPEVj4aszca/dwWkQ/ilcLn6DufpUVKkKUXObSS3b0Q4xc3aKuy7RXl3ib9qXStNneLw5Zz6jtBHms3lRk+2QSR+ArjdU/ah8Q3jn+zorCzXttjLt+bHH6dq+TxnHOUYNuKqObX8qv+OifyZ61HI8ZWV+Wy89Pw3P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GmSNgqIxGSo3RHp061sW3wp+HN2B5XimYZ5+e+gT/0KMV+r5Njc4wWEp4fC1KHKlonON9ddfe3uz5bGUMHXqyqVYzu/J2007HWf8NL+F/+et7/AOA5/wAaP+Gl/C//AD1vf/Ac/wCNYlr+z54LvmxZa7dzHGcJewMcfglXk/ZX8OSKGS+1lgeQRNEQf/Ide9TxPFNVXgqL9Hf9TglTyqPxOf8AXyNWP9ovwm7gNqEqA9zbSYH5LV62+N3hW6AMWs2wz/fV0/8AQgK5SX9lDSWX9zqeoq3qwRh+WBVG6/ZJjYf6FrrqeeHtA2fTkOMVf17iynvhacvR2/8AbxewymW1WS+X/wBqekR/Evw7KgZde0cA+t5GD+RNFeUP+ybqAc+Xq9mV7ExMD/Oij+3OI1vl6/ayaKTSluAUUUUwCiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA//2Q==';
var doc = new jsPDF();
doc.setFontSize(40);
doc.text(35, 25, "Octonyan loves jsPDF");
doc.addImage(imgData, 'JPEG', 15, 40, 180, 180);
This is a HTML5 client-side solution for generating PDFs.

Is it possible to embed a HTML into a PDF?

I like to embed a HTML site into a PDF document. Are there any libraries or PDF creator that make that possible?
Update:
I am not looking for ways to convert a HTML to PDF. I actually want to use the HMTL as it is inside the PDF. So I am looking for something like iframe for PDF.
There are a few out there, depends if you need to build using PHP or another language. I have used MPDF before: http://www.mpdf1.com/mpdf/
Yes, its possible using xmlworker5.4.1.jar. The XML worker object allows you to embed html in your document. xmlString object below is your HTML content as HTMLWorker is deprecated so use XMLWorker only.
XMLWorkerHelper worker = XMLWorkerHelper.getInstance();
String currentLine = "";
StringBuffer xmlString = new StringBuffer();
xmlString.append("<html><body>");
String str = htmlPages[i];
xmlString.append(htmlPages[i]);
xmlString.append("</body></html>");
worker.parseXHtml(pdfWriter, pdfDocument, new StringReader(xmlString.toString()));
Inorder to incorporate fonts mentioned in font face tag u need to register fonts using
FontFanctory.redisterDirectory("path of font files");
because itext doesnt scan system for fonts. u need to register it yourself this way

Using HTML file to output a PDF

So I've got a HTML file, that I am using to send emails, but in some instances I want it simply to use that file to create a PDF of the same template.
I've got it functioning for the most part - it creates the file, runs the evaluations and gets the content, but it doesn't actually render the html. It simply leaves all the html notation in place.
For example, it outputs a pdf but it reads:
Dear Martin, <br />
instead of:
Dear Martin
How do I make sure it renders the HTML so that the PDF is laid out correctly, and doesn't have the html code noted in the text?
Here's the code:
var docName = "test";
var htmlBody = HtmlService.createHtmlOutput(template.evaluate().getContent()).getContent()
var doc = DocumentApp.create(docName);
doc.appendParagraph(htmlBody);
doc.saveAndClose();
DocsList.createFile(doc.getAs('application/pdf')).rename(docName);
You can use your existing HTML as a blob, and convert it to PDF like this:
var htmlBody = HtmlService.createHtmlOutputFromFile('my_file_within_script_project.html').getContent();
var blob = Utilities.newBlob(htmlBody, 'text/html').getAs('application/pdf').setName('my_output_in_drive.pdf');
DriveApp.createFile(blob);
The best option when you want to create a PDF from a template is to use Google Docs directly so that no formatting is lost and also avoid the problem you are facing.
Why don't you just create your template directly in Google Docs. Have some placeholders such as {name} instead of the actual name. Instead of using template.evaluate(), you can do a find and replace in the doc.

How to serialize browser HTML DOM to XML?

I need to serialize browser parsed HTML DOM to well-format XML.
In firefox (gecko), this works:
// serialize body to well-format XML.
var xml = new XMLSerializer().serializeToString(document.body);
But in webkit, result is equivalent to document.body.outerHTML, not well-format XML (for example: <br> won't become <br />)
How to serialize browser HTML DOM to XML in webkit?
Thanks.
I have a setInnerXHTML method (not the Facebook version) which should work for this. The method is included in the base framework file, hemi.js, available from the Hemi Project Page. It is also included in my older libXmlRequest library.
Example:
var oXml = Hemi.xml.newXmlDocument("Xhtml");
Hemi.xml.setInnerXHTML(oXml.documentElement, document.documentElement, oXml);
var sSerial = Hemi.xml.serialize(oXml);
If you want to test this on a particular browser, navigate to the Hemi Project Page, click the upper-right tool icon, and click the Active Source tab. Copy and paste the sample code into the textarea and click Eval Source (the response will be a node name). Type in sSerial into the input field and hit enter, or click Eval, and you should see the serialized XML of the copied HTML DOM.

dom question: getting the full sourcode from a html document

i'm trying things out with a html document's dom (under visualbasic6) and i was wondering:
how can i get the full html sourcecode including all headers?
is there something like document.all.value?
thanks
If all you have is a DOM, there is no way to retrieve the original source, much less the response headers. It's gone. The DOM is what was generated from the source, which was thrown away thereafter.
If you must have the original source and headers, you will have to fetch it again from the server, using the location object to get the URL. For example from inside a web page script:
var req= 'XMLHttpRequest' in window? new XMLHttpRequest() : new ActiveXObject('MSXML2.XMLHttpRequest');
req.onreadystatechange= function() {
if (this.readyState===4) {
alert('Headers: '+this.getAllResponseHeaders());
alert('Body: '+this.responseText);
}
};
req.open('get', location.href);
req.send(null);
Clearly this will only work for a page generated from a GET request.