Issue with PySide6 and Oki-Microline-8480 Printer
-
I am using PySide6 version 6.5.2 to interface with an impact printer model, specifically the Oki-Microline-8480. My goal is to print a value at a specific coordinate with a Y-coordinate of 27 inches, but I'm encountering difficulties achieving this.
To customize the printable area size, I have attempted to use the following code snippet:
from PySide6.QtCore import QSizeF from PySide6.QtGui import QPageSize from PySide6.QtPrintSupport import QPrinter # assuming this code connect the printer to the Oki-Microline-8480 impact printer printer = QPrinter() # set custom page size for printer size_object = QSizeF() # setting height as 21 inch will succesfully set printer height to 21 inches # buf If I try 21.1 inch, the printer size will be at A4 page size size_object.setHeight(21.00) size_object.setWidth(16.01) custom_page_size = QPageSize(size_object, QPageSize.Unit.Inch, "CUSTOM", QPageSize.SizeMatchPolicy.FuzzyMatch) printer.setPageSize(custom_page_size) # set full page to make the printable area as big as possible printer.setFullPage(True) # print out printer height and width to test printable area print(f"{printer.width()=} and {printer.height()=}")
However, I've observed that the maximum height I can set is 21 inches. When attempting to set the height beyond this value, the printer reverts to the default paper size height (A4 size, which is approximately 11.69 inches).
If anyone has experience working with PySide6 and the Oki-Microline-8480 printer model or similar devices, I would greatly appreciate any advice or solutions on how to print at a Y-coordinate of 27 inches using this library and printer combination. Thank you!
I also posted this concern in Stackoverflow https://stackoverflow.com/questions/78400213/issue-with-pyside6-and-oki-microline-8480-printer
-
Hi and welcome to devnet,
On which OS are you ?
I just tested your code on macOS with PySide6 6.7.0 (QCoreApplication is missing by the way) and got
printer.width()=1601 and printer.height()=2100
. -
@SGaist thanks for replying. I used Window 10. I believe Printer.width and height value are measured in points, we can calculate height in point from inch using this formula : Printer height = height in inch * printer logical DPIY
In my case, my logical DPIY is 144, and the maximum height in inch I can set is 21 inch => So my maximum value from printer.height is 3024
Similar to the width, I figure out the maximum width is 16 inch => maximum printer width from printer.width() is 2304
In my case, I want to reach the height of 27 inch => my printer.height() value should be 27 * 144 ( my logical DPIY ) = 3888
-
@sontrantls Can you achieve that when printing from another application ?
Are there settings for that printer that might control these values ?
-
@SGaist Based on information from individuals familiar with this printer, they are able to utilize an IBM tool to print at a specific coordinate with Y = 24 inches. Therefore, I believe this capability is not limited by the printer itself.
-
@sontrantls that's the trick: does the utility do something at a lower level to communicate with this printer ?
-
that's part I'm not sure as I cannot access their source code .., but it might be the case
-
Problem Description:
There is an issue with the setPageSize method of QPrinter in certain versions of PySide6, PyQt6, and some versions of PyQt5.
Solution:The setPageSize method works properly in the PyQt 5.13.0 version.
Recommendation:If possible,downgrade to PyQt 5.13.0 version, or look for specific fixes regarding the setPageSize issue.
bug i have not solution in PySide6 version, I need solution too!!!!!