I was wondering if there's a way to load an HTML file on JavaFx's HTMLEditor but rather then loading it as a web page, show the actual raw source code on the HTMLEditor. Is this possible with JavaFX's HTMLEditor?
I tried the following:
File f = fc.showOpenDialog(null); //This allows a user to find a file in a dialog
String textRead = readFile(f); //store the files content in a string
htmlFileEditor.setHtmlText(textRead); //displays the source but not as raw HTML
This only loads the html file and displays it, Im wondering if there is a way to show the raw source code of the HTML file loaded with tags and all on the HTMLEditor.
Related
I'm generating pdfs from HTML pages with an application. Sometimes, the pdf is formatted correctly (with styles); other times, it lacks style elements.
In the log file I can see the "Error in rendering".
We are using HTML tags and using string buffer we are converting html tag to pdf file. Not sure why we are getting this missing format issues while generating the pdf file.
So sometimes the CSS file (style) does convert with the HTML file, and sometimes the CSS doesn't convert with the HTML file.
I'm guessing that you use an external CSS file. If I were you, I would try to type your CSS code inside your HTML file, under the header element, like this:
<style>
body {background-color:#fff}
h1 {color:#eee}
</style>
I have a java web application that in theory, when working correctly, will display a PDF in the browser window next to some input text boxes so that an employee could index the document and store it away.
JSP URL: localhost:1234/Application
What is currently happening is this:
->User tells JSP to tell servlet to go into filesystem and grab a batch of PDFs
-->JSP displays which batch(folder) was grabbed, and the files contained inside the folder to the screen
EXAMPLE:
Folder1:
-document1 (button)
-document2 (button)
-document3 (button)
--->Person clicks on button that appears next to document name on the JSP and the servlet serves up the PDF data in a byte array as follows:
File file = new File(Dir + "\\" + batchName + "\\" + fileName);
byte[] by = new byte[(int) file.length()];
FileInputStream fis = new FileInputStream(file);
fis.read(by);
fis.close();
response.setContentType("application/pdf");
response.setHeader("Content-disposition", "attachment; filename=TheDocument." + "pdf");
response.getOutputStream().write(by);
response.getOutputStream().flush();
response.getOutputStream().close();
The PDF then opens in a SEPARATE WINDOW than what the application is running on, and the PDF file is downloaded to the machine into the downloads folder
What happens after this does not matter in the scope of this question.
What I WANT to happen is this:
User tells JSP to tell servlet to go into filesystem and grab a batch of PDFs
JSP displays which batch(folder) was grabbed, and the files contained inside the folder to the screen
Person clicks on button next to document name in the JSP and the servlet serves up the PDF document and loads it into the html page so that the person can view it in real time on the same window and do their indexing.
Changing the header to inline does not give me the desired effect as it loads the PDF in the same browser window, but only by clicking back can I get back to my JSP. It essentially loads up a whole new HTML/JSP window. The browser actually points right to my servlet in this case:
localhost:1234/Application/Servlet
Below is what I want the application to look like:
I've looked into several jquery plugins such as PDFObject, Colorbox and many others. I do not seem to get the desired effect that I want.
You could use pdf.js to render the pdf, with a Flash fallback for browser that aren't supported by pdf.js.
The helloworld example renders a pdf in a <canvas> element.
Whether a PDF opens in a separate application or in the browser is a setting in the browser, in Adobe, and in Windows Explorer (assuming Windows). You have no control over it, short of displaying your PDF in a Flash app, and then the user might not have Flash.
Not sure if this is what you are looking for but typically you can put a PDF in an iframe and have it opened up that way. The PDF just needs to be published on your server.
This answer may help you:
How to open a PDF file in an <iframe>?
I am having some html content with images(html+images) embedded inside it on my local drive. When i open it by double clicking on browser directly, i am able to see the content with embedded images in it.
Now i have to render this content on web browser using java apis.I am able to render html content without any issue but while rendering , image is not getting rendered , instead alt text is getting rendered on browser.
I got to know that i can not set two mime types in java code to render image as well as text on same page.I want to know how can i render html content with image inside it so that it can be rendered.
Regards.
Code added:
public void readFile() throws FileNotFoundException{
String lsFilePath = "D:\\alf3.3\\deployment\\target\\";
//String lsFilename = "/WEB-INF/message.properties";
String lsFilename = "spcontent2.html";
File loNewFile = new File(lsFilePath + lsFilename);
FileInputStream loFileInputStream = new FileInputStream(loNewFile);
FileOutputStream loFilOutputStream = new FileOutputStream(loNewFile);
}
It is fine till now but i need to know how can i render an image that is referred to in file mentioned.
For embedding an Image into html source page by adding content id into image source. This is usually practised while sending HTML emails with embedded images
Please refer following document for more info.
http://www.faqs.org/rfcs/rfc2111.html
I want to display a regular XML or any other file in text format in JEditorPane..I don't want to display the content in html page... the content should be exactly the same as in file with line break..the XML file is located on local system
Do you need syntax highlighting?
or just show plain text?
If syntax try to use this
http://java-sl.com/xml_editor_kit.html
If not just use JTextArea or normal JEditorPane with default editor kit. And call setText() to set your content.
I need to print a an html out to the printer programmatically. I do not want to print the html tags, I want the html tags parsed before printed.
This code adds html features and data to an htm document named document. I am then sending the output to a file named itext.html
HtmlWriter writer2 = HtmlWriter.getInstance(document,new FileOutputStream("itext.html"));
I know need to somehow parse that html file and print it without having to open it up in a browser and going to FILE and Print.
Cobra will render HTML to a Swing-compatible panel. You should be able to print that using the standard Print APIs/services.