Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Thu Mar 11, 2021 7:36 pm

Hello,
I am currently facing a problem with the Free Java Library on a linux machine.
I am using the artifact
Code: Select all
<dependency>
            <groupId> e-iceblue </groupId>
            <artifactId>spire.pdf.free</artifactId>
            <version>4.3.0</version>
        </dependency>


and the linux plugin version. There are no access restrictions on any file inside the plugin folder and I am unzipping the linux_plugin archive directly on system startup.

My code looks like this:

Code: Select all
        HtmlConverter.setPluginPath("/home/plugins_linux/");
        HtmlConverter.convert("/home/test.html", "test.pdf", false, 100 * 1000, new Size(283F,425F), new PdfMargins(0));


The exact problem is, that the file will not be created (the application is running as root, so no access restrictions) and if I create it before, it will be empty.
I also tried to get the pdf content via OutputStream instead of filename as parameter, but the stream will also be empty.

System information:
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.12.4
PRETTY_NAME="Alpine Linux v3.12"


I did read this post from bradjen, but none of the answers worked for me, such as installing the libraries etc.

If I use the same code, but a windows machine and the windows plugin, it works perfectly. But we cant use windows machines in production mode :)

Thank you and I am looking forward to your reply :)

dglaefcke
 
Posts: 3
Joined: Thu Mar 11, 2021 7:04 pm

Fri Mar 12, 2021 11:18 am

Hello,

Thanks for your inquiry.
We recommend that you can test the following commands in the path where you put the plugin on your Alpine Linux system, and tell us your test results, and our Dev team will investigate further.
Code: Select all
echo /usr/local/input.html | ./Html2Pdf "placeholder" "/usr/local/output.pdf" 800 600 0 0 0 0 0

screenshot.png

screenshot2.png


Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Fri Mar 12, 2021 1:06 pm

Thx for the help.
We get this error message.

Code: Select all
root@f4c16f05c15b:/home/plugins_linux# echo /home/plugins_linux/input.html | ./Html2Pdf "placeholder" "/home/plugins_linux/output.pdf" 800 600 0 0 0 0 0
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
qt.qpa.screen: QXcbConnection: Could not connect to display
Could not connect to any X display.


I guess it is not possible to use the library inside a docker container on a cluster? :) Without UI ^^

dglaefcke
 
Posts: 3
Joined: Thu Mar 11, 2021 7:04 pm

Mon Mar 15, 2021 7:35 am

Hello,

Thanks for your feedback.
Kindly note that our QT plugin conversion method requires GUI support. For servers without GUI, please install the xvfb tool first, and then use the xvfb-run command to run your application, as shown below.
Code: Select all
#1. install xvfb
apk add xvfb xvfb-run
#2. use the xvfb-run command to run your application
xvfb-run java -jar xxx.jar

If there are still some problems, please provide your input HTML file for further investigation. Thanks in advance.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Tue Mar 16, 2021 8:59 am

This worked! But you have to execute this in bash context (inside a docker container) to get the application logs printed to the console ^^
Thx

dglaefcke
 
Posts: 3
Joined: Thu Mar 11, 2021 7:04 pm

Tue Mar 16, 2021 10:14 am

Hello,

Thanks for your feedback.

You do not want to execute this command in the bash context, but build the image and run the application directly via dockerfile?
Could you please describe your requirement in more detail to help us look into it further? Thanks in advance.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Return to Spire.PDF