Printing RTF/HTML Files with Node.js - java

I have the following problem:
I've created an electron app which prints out receipt with a thermal printer, however, the print quality really seems to suffer when using any other formats that .txt, .rtf or .html.
The module I've been using so far is node-native-printer and although html is listed as a supported file type, it only prints out the unrendered html text.
I've also tried JTextComponent but I could not get it to work with RTF or HTML.
I am not familiar with C# so I do not know how I could play around with node-native-printer's .cs files to get it to work.
Also ideally there should not be any dialog popping up when printing and most importantly no extra user input required.
I'd appreciate any help!

Related

Preview LaTeX output with Java

Right now I'm working on displaying LaTeX generated document with Java.
Strictly speaking, LaTeX source can be used to directly generate two formats:
DVI using latex, the first one to be supported;
PDF using pdflatex, more recent.
However rendering dvi or pdf is not available as far as I know.
Is there any way to handle those formats ? Or maybe others that makes sense ?
There are not enough details with regards to how you wish to "render" DVI or PDF from a LaTeX document. However, you could always just render the pdf using pdflatex and DVI using latex and use ICEpdf for viewing PDFs and javaDVI for viewing DVIs.
Another neat hack to display pdf in a panel is to pass the file path to an embedded web component in the application, and the web component will use whatever pdf rendering tool is available on your machine (Acrobat, Foxit, Preview, etc.)
I remember there was a post about this a long time ago.
I don't think there's a generic way to preview the rendered output without generating the file itself. You can write your own LaTeX engine which caches the output every few seconds and displays that but regardless of the storage, you have to output it somewhere physically and then render the output separately using any of the steps mentioned above.
Another approach is to convert the div output to an svg image file and render that with SVGGraphics2D. That will produce nice scalable results. Dvi files can be converted to svg on the command line (or in a script) using:
dvisvgm --no-fonts input.dvi -o output.svg
For more conversion options see this thread on how to convert pdf to clean svg.

extracting text AND Images from PDF file

I have been bumping my head against the wall with this one, have researched and pretty much tried every library suggested to me. I am currently trying to write a program in java that will extract text AND images from a pdf file and allow me to write the extracted content to a word file. I have managed to extract the content using the ICEpdf library, however the problem is that I need to be able to write the content in the exact same order as it was read. So, to clarify, I need a library that will help me keep track of where exactly in the page the text and images are situated so I can put them in the same place in my word file.
A PDF to Word converter is a horribly complex proposition.
Your best bet will probably to use Open Office to do it for you and not even try to handle the intermediate steps.
http://www.openoffice.org/api/
Look at this: Advanced PDF parser for Java
OFF:
-Also to my knowledge there is a python parser that sorta converts the pdf to html (that way you can keep track of the ordering of the objects within the pdf). I know its not java, but you might be able to use the output.
http://www.unixuser.org/~euske/python/pdfminer/index.html

Java document printing in Windows

I am doing a project which will finally print a pdf file or doc file to the printer as "another user". But now I stuck on how to print document in Java.
I know there is a pdf renderer in java, developed by sun, which can convert pdf to pcl file.
After the conversion, I want to print the pcl file to remote printers.
My previous way is "copy /b filename \printserver\printer", however, this approach actually is too lowlevel and cannot even display the document name, and sometime is not working.
I wonder is there a better approach of java to send the PCL file to print server, where the server can actually detect the document name and host name(which I want to specify in the program, not the original one). This one is really driving me crazy...Thanks!
Have you looked into java print service?
You can find some useful code here
http://docs.oracle.com/javase/1.4.2/docs/guide/jps/spec/printing.fm2.html

PDF printing in java

is there a way to print pdf files from a java webapplication on the local printer of the end user (connected via vpn)?
The simple lookup of a printer via Java Printing Service always returns printer which are not able to print pdfs. Are there other libs which can be used for printing in java?
By the way, just opening the pdf in the browser is not an option, though it must be possible to run scheduled batch printing without user interaction.
Thanks in advance
Since the Java web application can't connect to the client (the client connects to it), there is no way to do this.
The only solution is to send the PDF file to the client via a download link or similar, so that the browser on the client can offer the user to save or print it.
I currently have the same problem - having to find a way to print PDF and Word documents.
And the short answer is:
It's not as easy as you'd want it to be.
The problem is that "someone" has to do the interpretation of your document. And that someone is either the printer or you.
Not all printers support DocFlavor.x.PDF. We have four printers at my company (one was bought just last month) and none of them does.
If you find a printer that does accept that DocFlavor you're done.
But since chances are the printer doesn't know what to do with a PDF file, you have to render the document yourself. I can recommend trying PDFRenderer and PDFBox. For me PDFRenderer works great and PDFBox doesn't print text correctly, but other people report the opposite. So, you will have to try for yourself.
All that still doesn't help me with Word docs, but that's not your concern.

View PDF files in IFrame with Named Destinations

We've got an application that displays PDF files in an IFrame at specific Named Destinations. This works well on Windows systems but not Mac. In Safari, with Acrobat, the Named Destination is ignored and the document is displayed at the start.
Does anyone have any suggestions on how we might accomplish the task of displaying this information? Our initial thoughts are to:
Convert the PDF to HTML on the fly and display the HTML version in the IFrame
Convert the PDF on the page referenced to another format such as PNG etc. and display that in the IFrame
Utilize some kind of Java app that allowed us to render the PDF while honouring the Named Destination (not sure if this exists)
Any other ideas on a potential method of better displaying PDF files at Named Destination points that is a little more cross platform?
EDIT: I guess another option is to store the data in XSL/XSLT type format and convert to HTML for veiwing or PDF for saving to the desktop.
Not much help, but I found that alternative ways to display PDF files (other than the Acrobat Reader client) are few and far between. As you say, the commonly accepted way to render PDF's in something that doesn't natively support it seems to be converting it "something else", which is supported (even Acrobat.com does it this way in their Flex client if I remember it correctly).
Even converting the PDF document to other formats may be disappointing - especially if you expect a certain level of quality. It may also introduce server-side performance issues.
I realise this doesn't help anyone much but I'm interested to see if any other suggestions come up. We've dealt with this problem before in the same way, using IFrame controls (but without named destinations) but I'm very much interested in other suggestions/ideas as well.

Categories

Resources