Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Wed Dec 23, 2020 11:58 am

Hi,

I'm simply trying to print a .docx document. The problem is, when I print my document, the result doesn't fit with the page. Here's my original document:
Capture.JPG

And here's what I have when I print it
Capture2.JPG


My code is simple, I don't know what to put inside to settle this:
Code: Select all
com.spire.doc.Document document = new com.spire.doc.Document();
document.loadFromFile("src/main/resources/test.docx");

PrinterJob printerJob = PrinterJob.getPrinterJob();

PageFormat format = printerJob.defaultPage();
Paper paper = format.getPaper();
paper.setImageableArea(0,0, format.getWidth(), format.getHeight());
format.setPaper(paper);

printerJob.setPrintable(document, format);
if (printerJob.printDialog()){
       try {
              printerJob.print();
       } catch (PrinterException ex) {
              ex.printStackTrace();
       }
}
document.close();

gomon83500
 
Posts: 2
Joined: Wed Dec 23, 2020 11:49 am

Thu Dec 24, 2020 7:12 am

Hello,

Thanks for your inquiry.
I simulated a Word file and tested your scenario with the latest Spire.Doc for Java Version:3.12.5, but did not reproduce your issue. If you are using an older version, please download the latest version and try again.
If the issue still occurs, to help us investigate further, please provide the following information. Thanks in advance.
1) Your input file.
2) Your OS information (e.g. Windows 7, 64bit) and region settings (e.g. China, Chinese).
3) Your JDK version (e.g. jdk1.8.0_131).

Sincerely,
Brian
E-iceblue support team
User avatar

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

Thu Dec 24, 2020 9:21 am

Hello,

Thank you for your answer.

It's because I use the free version 3.9.0.

I'm on Windows 10, 64-bit in France region settings.
The file that I use is a simple .docx file from word office 365. I tried to create other files from this word version and it doesn't work either.
I'm on the JDK 13.0.2.

gomon83500
 
Posts: 2
Joined: Wed Dec 23, 2020 11:49 am

Thu Dec 24, 2020 11:21 am

Hello,

Thanks for your response.
I tested your scenario with the Free Spire.Doc v3.9.0 in a similar environment, but still did not reproduce your issue. Here is my executable .jar file, please run it on your side and then let us know your test results.

Besides, are there any special settings related to resolution and display on your computer? If so, please provide some screenshots to help us investigate further. Thanks in advance.

Sincerely,
Brian
E-iceblue support team
User avatar

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

Wed Jan 06, 2021 3:15 am

Hello,

Have you run the project we provided to you? What is the result? Any feedback will be greatly appreciated.

Sincerely,
Brian
E-iceblue support team
User avatar

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

Return to Spire.Doc