Recent

Author Topic: Printing under Linux - paper dimentions  (Read 1669 times)

toplek

  • Jr. Member
  • **
  • Posts: 53
Printing under Linux - paper dimentions
« on: April 10, 2018, 02:44:35 pm »
Hello,
I need to print something under Linux and I have a problem with non-standard paper dimentions (5.5"x2.38"). On Windows I use DevMode to set paper size:

dmPaperLength := ...
dmPaperWidth := ...

Do you possibly know any way to do the same under Linux?

Thank you in advance
toplek

Alextp

  • Hero Member
  • *****
  • Posts: 723
    • UVviewsoft
Re: Printing under Linux - paper dimentions
« Reply #1 on: April 10, 2018, 05:01:14 pm »
On Linux you have only CUPS api, example to get current page sizes is in PageSetupDialog code. dialog gets size into its properties PageWidth/Height.

toplek

  • Jr. Member
  • **
  • Posts: 53
Re: Printing under Linux
« Reply #2 on: April 11, 2018, 03:12:53 pm »
Well, I am trying to use CUPS, I have succesfully set the paper dimentions, but I am encountering another problem. If I try printing text like this:

Code: Pascal  [Select]
  1. Printer.Canvas.TextOut(100,100,'TEST');

everything works fine. But if I want to print a canvas like this:

Code: Pascal  [Select]
  1. SetPrinter(DefaultLabelPrinter, DefaultLabelPaperSizeName, 1);
  2.  
  3. Printer.Orientation := poLandscape;
  4. Printer.BeginDoc;
  5.  
  6. r := Rect(0,0,1400,1400);
  7. Printer.Canvas.CopyRect(r,Panel4.Canvas,Panel4.Canvas.ClipRect);
  8.  
  9. Printer.EndDoc;

then it prints only blank page. The same code under Windows works fine.
Do you have any idea how to solve this problem? I am using Lazarus 1.6.2.

Alextp

  • Hero Member
  • *****
  • Posts: 723
    • UVviewsoft
Re: Printing under Linux - paper dimentions
« Reply #3 on: April 11, 2018, 08:04:28 pm »
Maybe try to paint Line first and print it. Then Rectangle.

toplek

  • Jr. Member
  • **
  • Posts: 53
Re: Printing under Linux - paper dimentions
« Reply #4 on: April 12, 2018, 09:17:32 am »
Painting rectangle, lines and text works just fine. Only copying from other canvas to printer canvas does not work. Do you possibly know any solution?

Alextp

  • Hero Member
  • *****
  • Posts: 723
    • UVviewsoft
Re: Printing under Linux - paper dimentions
« Reply #5 on: April 12, 2018, 10:03:38 am »
CopyRect is incomplete so. maybe because canvases have different color depth.

toplek

  • Jr. Member
  • **
  • Posts: 53
Re: Printing under Linux - paper dimentions
« Reply #6 on: April 16, 2018, 08:25:33 am »
It might be possible. How can I change color depth for example in printer canvas?

Alextp

  • Hero Member
  • *****
  • Posts: 723
    • UVviewsoft
Re: Printing under Linux - paper dimentions
« Reply #7 on: April 16, 2018, 08:54:45 am »
you are right. Im not sure how to change color depth of a canvas.

toplek

  • Jr. Member
  • **
  • Posts: 53
Re: Printing under Linux - paper dimentions
« Reply #8 on: May 09, 2018, 09:51:37 am »
To end the topic, it looks like a problem with HtmlViewer, please follow the link: https://forum.lazarus.freepascal.org/index.php/topic,40930.0.html