I’m working on a program written in Java that uses LibreOffice to convert documents to .pdf format. Clients on their side use Microsoft Word.
The functionality of the program is such that through the program interface, clients upload documents to their server. It turns out that at first, the program reads the format and content of the document, then saves the content in .pdf and saves this document on the server.
I ran into a problem when working with a .rtf document that has the embed fonts option enabled. The problem is that when working with a document in Microsoft Word, everything works well. But if this document is opened in LibreOffice Writer (it doesn’t matter the version, I tried from 6.0.0.1 to 7.3.1), then the document is damaged, even if these are done manually, for example, on the Desktop in Windows. That is, the table inside the document is not displayed correctly. If I open it again in Microsoft Word, the document remains “damaged”. But if BEFORE these manipulations in Microsoft Word turn off the embed fonts option and then open it in LibreOffice or upload it to the server through my program, then everything will work fine. This error occurs both when working through the code and if this is done manually.
I think that the problem is related to this topic for the .doc and .docx format, but here I solved everything by switching from Windows Server 2016 to Windows Server 2019, but even on Windows Server 2019, the problem with .rtf remains. The same problem exists in Windows 10.
Can you tell me how to fix the problem so that the embed fonts function remains active? Because I can’t tell clients not to use embed fonts.
Thanks!
P.S.
Sorry, I can’t provide the actual file. It contains very important customer information. When editing or replacing text and after saving, the file is also saved damaged for the Word program. Therefore, I will leave a link to the image of the “normal” file and the damaged one, to make it clear what “corrupted” is.
Related
I use Apache PDFBox library to create pdf-files. It creates files with the XFA structure. Applications on PC, Mac or Linux can read these files without any problems. But Android devices cannot do it. I see the following error message in the pdf-file:
"Please wait... If this message is not eventually replaced by the proper contents of the document, your PDF viewer may not be able to display this type of document".
I am trying to find a solution to create pdf files that could be read by Android devices. I cannot find any information how to do it.
Did anyone do something like that?
If you generate a non-XFA PDF you'll probably have more luck with it. The XFA spec is large, complicated and not well supported. Adobe Reader supports it but not many other readers (on Android or on desktop).
I'm using docx4j to convert a microsoft word document into a pdf then displaying it in a browser http://www.docx4java.org/trac/docx4j and it works well for a preview. The problem I'm facing is that this conversion loses most of the microsoft word document formatting. Page breaks and fonts don't transfer into the PDF format properly and even though I'm using standard font types docx4j doesn't come with them. In a Linux Tomcat hosted scenario fonts are not found and throw exceptions as it falls back to sans serif or other generic types.
I have found this Microsoft tool to make documents render online, but I'm behind a firewall so I cannot include this tool as an option: https://products.office.com/en-us/office-online/view-office-documents-online
I'm open to suggestion on displaying a docx file as a preview and print option from within a browser. Pdf conversion appears to be the most promising, but I run into formatting issues.
Any ideas are welcome!
Have a play with http://converter-eval.plutext.com/viewer.html
Consider it an alpha level preview. We haven't quite released it yet, but you will be able to host it behind a firewall.
It isn't open source, I'm afraid, and we're still working out pricing (and whether/how there could be a free edition).
If you only need to render a docx document in a browser, u can use Google Documents Viewer for this as :
<iframe src="http://docs.google.com/gview?url=pathOfDocx&embedded=true" />
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
I already tested window.print() command for this purpose but it is not fulfill my requirement.
I also used print content of iframe in which source is pdf file but it is only work in chrome not in other browser.
I want to print pdf files automatically using code instead of open file and print it.
For example there are two files such as 1.pdf and 2.pdf in any directory and source is given then how can print both files using either javascript or php or both.
I already tested window.print() command for this purpose but it is not fulfill my requirement.
My required as image as:
Million thanks in advance.
This is not possible since most browsers, unlike google chrome (where it works) don't have a built in pdf viewer.
The printing of a pdf document is up to the pdf reader, whether or not it is installed as a browser plugin, not the browser.
I fix this issue of merging multiple pdf or image or both by using imageMagick.
Using below command we can merge pdf and image as:
<?
$cmd = "test.pdf test.jpeg final.pdf";
exec("convert $cmd");
?>
After completed merging process, open final.pdf automatically using code then user can print it easily.
You can find more.
I have a project which requires creating a Word (.doc) file with certain formatting and certain data fetched from my database. I want to output that file to user which he would edit and the upload the file back it back to the server. After which I want to perform the following conversion on the uploaded file.
.doc to .pdf (Intended to be downloaded and viewed on web)
.doc to .html (Intended for free text search on web)
I want to achieve this without opening the Open Office port. The earlier version was doing this but the port opened had tendency of crashing when the users are more. So I want to avoid doing that. The Open Office and the OS both were re-installed on other machines and tried in different ways but the OO port crashed every time the users increased.
Is there any other way to achieve this conversion? Continuing with this is not possible due to the crashing.
This is the host machine:
Tomcat server on Linux (RedHat 64 bit)
The application is developed in Java (JSP and Servlets)
The backend is Oracle
All users have:
A Linux machine, mostly 32bit Fedora or Suse
Any help is appreciated.
You could use http://poi.apache.org/ for handling the actual .doc files. For PDF, there are a number of PDF libraries available as well. The catch is that many are not free, but here is a list of open source PDF libraries: http://java-source.net/open-source/pdf-libraries
Here is a discussion on Word to HTML. Convert Word doc to HTML programmatically in Java