Printing Orientation Issue

If you are having problems with QCAD, post here. Please report bugs through our Bug Tracker instead.

Always attach your original DXF or DWG file and mentions your QCAD version and the platform you are on.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files and screenshots.

Post one question per topic.

jbergen
Junior Member
Posts: 11
Joined: Mon Oct 10, 2022 5:11 pm

Re: Printing Orientation Issue

Post by jbergen » Sun Sep 21, 2025 2:15 am

After months and months of trying everything I could possibly think of, I finally solved this printing issue on my Linux computer.

I actually had three printing issues:

1) This one, where QCAD always prints in portrait when it's supposed to print in Landscape.
2) Double-sided prints from OnlyOffice always print single-sided.
3) Printing a quantity of more than one only printed one copy.

I am using QCAD/CAM 3.31.2.0, a networked HP Color LaserJet PRO MFP M281cdw, a Lenovo ThinkPad E16 (Intel), and LMDE7.

I tried numerous Distros and numerous Printer Settings and here is what I found:

In Print Settings app there is a "Device URI" setting which handles communication with the printer, and a "Make and Model" setting for the printer driver.

Linux auto-detects my printer and defaults to "implicitclass" for the URI and "driverless" for the driver.

With this default setup, I had all 3 of the problems listed above.

Changing the "Device URI" from "implicitclass" to something else eliminates problem 2.
Changing the "Make and Model" from "driverless" to a driver for my specific printer eliminates problem 3.

But those changes do not solve problem 1. QCAD still prints in portrait mode.

After trying countless different Distros with the same results, I finally found a combo that works:

1) Debian 13 Trixie (KDE and Cinnamon both worked). I am currently using LMDE7 which is based on Debian 13 Trixie.
2) A generic driver. Instead of the driver for my HP M281, I used the generic "HP Color Laserjet - Series PCL 6 CUPS" driver.

This is the only combo that has solved all 3 problems for me.

I don't think this is a problem with QCAD. I think it's a problem with CUPS and/or the printer drivers supplied with most Linux distros.

eugeniobonifacio
Registered Member
Posts: 1
Joined: Thu Feb 05, 2026 7:01 pm

Re: Printing Orientation Issue

Post by eugeniobonifacio » Thu Feb 05, 2026 8:18 pm

Hello,

I've been struggling with this issue for months, without finding a solution. I'm a software engineer but I have little experience with C++ and Qt, so I decided to analyze the problem starting from the source code with the help of Claude Code.

My system is the following:

Code: Select all

Operating System: Ubuntu 24.04
KDE Plasma Version: 5.27.12
KDE Frameworks Version: 5.115.0
Qt Version: 5.15.13
Kernel Version: 6.8.0-94-generic (64-bit)
Graphics Platform: X11
Processors: 16 × AMD Ryzen 7 5800X 8-Core Processor
Memory: 31.2 GiB of RAM
Graphics Processor: NVIDIA GeForce RTX 4060 Ti/PCIe/SSE2

CUPS: v2.4.7
Printer: Samsung M2020 Series (IPP, tested with both proprietary driver and driverless)

QCAD CE
Version: 3.32.5.0 (3.32.5)
Build Date: Dec 18 2025
Revision: ad10f93
Qt Version: 5.8.0
Architecture: x86_64
Compiler: gcc 4.8.1
This is the resulting analysis by Claude. I only created a prompt with the way to proceed, in subsequent steps to break down the problem:
1) I got the CUPS spool files
2) Source code

The proposed solution works.

Get the scripts/File/Print/Print.js from source code (use the same version of QCAD you have).

Apply the following patch to it and copy it to your QCAD installation folder (create the path, if it does not exist).

Code: Select all

diff --git a/scripts/File/Print/Print.js b/scripts/File/Print/Print.js
index 71563bcd44..d0d099d1e9 100644
--- a/scripts/File/Print/Print.js
+++ b/scripts/File/Print/Print.js
@@ -117,16 +117,21 @@ Print.prototype.createPrinter = function(pdfFile, printerName, pdfVersion) {
     }
 
     // always use custom page size to work around Qt page size limitations:
+    // Swap dimensions for landscape orientation so the PDF is generated with
+    // correct page size. Do NOT set orientation on QPrinter as that would cause
+    // double rotation when printing via CUPS.
     var paperSizeMM = Print.getPaperSizeMM(this.document);
+    if (Print.getPageOrientationEnum(this.document) === RS.Landscape) {
+        // swap width and height for landscape
+        paperSizeMM = new QSizeF(paperSizeMM.height(), paperSizeMM.width());
+    }
     if (RSettings.getQtVersion() >= 0x060000) {
         printer.setPageSize(new QPageSize(paperSizeMM, QPageSize.Millimeter));
         printer.setFullPage(true);
-        printer.setPageOrientation(Print.getPageOrientationEnum(this.document));
     }
     else {
         printer.setPaperSize(paperSizeMM, QPrinter.Millimeter);
         printer.setFullPage(true);
-        printer.setOrientation(Print.getPageOrientationEnum(this.document));
     }
 
     var colorMode = Print.getColorMode(this.document);
@@ -188,6 +193,7 @@ Print.prototype.createPrinter = function(pdfFile, printerName, pdfVersion) {
             destr(printer);
             return undefined;
         }
+
     }
 
     return printer;
I hope this could be useful to solve this issue. The direct print is important to keep the correct scale.

Following you can find the full analysis.

Landscape printing from QCAD on Linux: double rotation with CUPS

The problem

When printing from QCAD in landscape mode on Linux, the document is printed in portrait even though the print preview shows it correctly. The issue occurs with direct printing, while PDF export produces a correct file.

Analysis

By examining the CUPS spool files (control file c* and data file d*) we found that:
  • The PDF generated by Qt has correct dimensions: 842 × 595 pts (A4 landscape)
  • However, the CUPS job also contains the landscape option
This causes a double rotation: the PDF content is already oriented in landscape, but CUPS also receives the instruction to rotate the page, effectively cancelling the correct orientation.

Root cause in the code

The file scripts/File/Print/Print.js, in the createPrinter method, performs two conflicting operations:
  1. Page dimensions are already swapped for landscape in the getPages() function (used for rendering and print preview)
  2. printer.setOrientation(Landscape) (Qt 5) or printer.setPageOrientation(Landscape) (Qt 6) is also called on the QPrinter object
Step 2 causes Qt to communicate the landscape option to CUPS, which is then applied on top of an already rotated PDF.

Fix

In the createPrinter method of Print.js (around line 119), you need to:
  1. Swap the page dimensions when orientation is landscape, before passing them to QPrinter
  2. Remove the setOrientation() / setPageOrientation() calls on QPrinter
Original code:

Code: Select all

var paperSizeMM = Print.getPaperSizeMM(this.document);
if (RSettings.getQtVersion() >= 0x060000) {
    printer.setPageSize(new QPageSize(paperSizeMM, QPageSize.Millimeter));
    printer.setFullPage(true);
    printer.setPageOrientation(Print.getPageOrientationEnum(this.document));
}
else {
    printer.setPaperSize(paperSizeMM, QPrinter.Millimeter);
    printer.setFullPage(true);
    printer.setOrientation(Print.getPageOrientationEnum(this.document));
}
Replace with:

Code: Select all

var paperSizeMM = Print.getPaperSizeMM(this.document);
if (Print.getPageOrientationEnum(this.document) === RS.Landscape) {
    paperSizeMM = new QSizeF(paperSizeMM.height(), paperSizeMM.width());
}
if (RSettings.getQtVersion() >= 0x060000) {
    printer.setPageSize(new QPageSize(paperSizeMM, QPageSize.Millimeter));
    printer.setFullPage(true);
}
else {
    printer.setPaperSize(paperSizeMM, QPrinter.Millimeter);
    printer.setFullPage(true);
}
This way the PDF is generated with the correct landscape dimensions (297×210 mm) and CUPS receives the job without the landscape option, avoiding the double rotation.

How to apply the fix without recompiling

QCAD loads scripts from the scripts/ folder with priority over those compiled in the libqcadscripts.so plugin. Simply copy the modified Print.js file (from the source code) to:

Code: Select all

<qcad-installation-folder>/scripts/File/Print/Print.js
and restart QCAD.

Post Reply

Return to “QCAD Troubleshooting and Problems”