View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0034932 | Lazarus | Widgetset | public | 2019-01-23 10:23 | 2020-03-05 12:08 |
Reporter | Timl | Assigned To | Jesus Reyes | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Platform | i586 | OS | Magiea | ||
Product Version | 2.0RC3 | ||||
Target Version | 2.0.2 | Fixed in Version | 2.0.2 | ||
Summary | 0034932: Printing not correct with gtk | ||||
Description | When printing in landscape, the first page prints correctly. Subsequent pages are rotated to portrait layout but the content is still in landscape. | ||||
Steps To Reproduce | Run attached project under Lazarus 1.8.4 and printing is correct. Run under 2.0rc3 or trunk and printing is wrong. | ||||
Additional Information | Printing works OK on the same maching running the test project as win32 with wine. | ||||
Tags | No tags attached. | ||||
Fixed in Revision | 60732 | ||||
LazTarget | 2.0.2 | ||||
Widgetset | GTK 2 | ||||
Attached Files |
|
related to | 0034680 | closed | Jesus Reyes | Regression. Printing under linux broken. |
related to | 0036753 | resolved | Juha Manninen | TCairoCanvas PDF doesn't work properly with landscape |
|
|
|
Can confirm. FPC 3.3.1 and Lazarus 2.1 svn 2nd page is wrongly rotated. with strange warning cairoprinter.pas(238,8) Warning: (4040) Class types "TCairoFileCanvas" and "TDocAccess" are not related |
|
May be related to 0034680 and r59492. I removed the useless accessor class TDocAccess completely in r60207. |
|
Jesus, could you please look into this. |
|
gtkprnfix.diff (3,748 bytes)
Index: lcl/printers.pas =================================================================== --- lcl/printers.pas (revisión: 60701) +++ lcl/printers.pas (copia de trabajo) @@ -747,7 +747,7 @@ procedure TPrinter.SetOrientation(const AValue: TPrinterOrientation); begin - CheckPrinting(False); + //CheckPrinting(False); DoSetOrientation(aValue); end; Index: components/cairocanvas/cairocanvas.pas =================================================================== --- components/cairocanvas/cairocanvas.pas (revisión: 60701) +++ components/cairocanvas/cairocanvas.pas (copia de trabajo) @@ -163,6 +163,11 @@ { TCairoPsCanvas } TCairoPsCanvas = class(TCairoFileCanvas) + private + fPaperWidth, fPaperHeight: double; + fHandle: Pcairo_t; + procedure GetPageProperties(out aWidth, aHeight: double; out orStr:string); + procedure UpdatePageTransform; protected function CreateCairoHandle: HDC; override; public @@ -1515,21 +1520,53 @@ { TCairoPsCanvas } +procedure TCairoPsCanvas.GetPageProperties(out aWidth, aHeight: double; out + orStr: string); +begin + if Orientation in [poLandscape, poReverseLandscape] then begin + orStr := '%%PageOrientation: Landscape'; + aWidth := PaperHeight*ScaleY; //switch H, W + aHeight := PaperWidth*ScaleX; + end else begin + orStr := '%%PageOrientation: Portait'; + aWidth := PaperWidth*ScaleX; + aHeight := PaperHeight*ScaleY; + end; + +end; + +procedure TCairoPsCanvas.UpdatePageTransform; +var + W, H: double; + Dummy: string; +begin + GetPageProperties(W, H, Dummy); + + cairo_identity_matrix(fHandle); + + case Orientation of + poLandscape: begin + cairo_translate(fHandle, 0, H); + cairo_rotate(fHandle, -PI/2); + end; + poReverseLandscape: begin + cairo_translate(fHandle, W, 0); + cairo_rotate(fHandle, PI/2); + end; + poReversePortrait: begin + cairo_translate(fHandle, W, H); + cairo_rotate(fHandle, PI); + end; + end; + +end; + function TCairoPsCanvas.CreateCairoHandle: HDC; var s: string; W, H: Double; - acr: Pcairo_t; begin - if Orientation in [poLandscape, poReverseLandscape] then begin - s := '%%PageOrientation: Landscape'; - W := PaperHeight*ScaleY; //switch H, W - H := PaperWidth*ScaleX; - end else begin - s := '%%PageOrientation: Portait'; - W := PaperWidth*ScaleX; - H := PaperHeight*ScaleY; - end; + GetPageProperties(W, H, s); //Sizes are in Points, 72DPI (1pt = 1/72") if fStream<>nil then @@ -1536,7 +1573,7 @@ sf := cairo_ps_surface_create_for_stream(@WriteToStream, fStream, W, H) else sf := cairo_ps_surface_create(PChar(FOutputFileName), W, H); - acr := cairo_create(sf); + fHandle := cairo_create(sf); cairo_ps_surface_dsc_begin_setup(sf); cairo_ps_surface_dsc_comment(sf, PChar(s)); @@ -1549,26 +1586,23 @@ end; //rotate and move - case Orientation of - poLandscape: begin - cairo_translate(acr, 0, H); - cairo_rotate(acr, -PI/2); - end; - poReverseLandscape: begin - cairo_translate(acr, W, 0); - cairo_rotate(acr, PI/2); - end; - poReversePortrait: begin - cairo_translate(acr, W, H); - cairo_rotate(acr, PI); - end; - end; - result := {%H-}HDC(acr); + UpdatePageTransform; + + result := {%H-}HDC(fHandle); end; procedure TCairoPsCanvas.UpdatePageSize; +var + W, H: Double; + S: string; begin - cairo_ps_surface_set_size(sf, PaperWidth*ScaleX, PaperHeight*ScaleY); + GetPageProperties(W, H, S); + + cairo_ps_surface_dsc_begin_page_setup(sf); + cairo_ps_surface_dsc_comment(sf, PChar(s)); + cairo_ps_surface_set_size(sf, W, H); + + UpdatePageTransform; end; constructor TCairoPngCanvas.Create(APrinter: TPrinter); |
|
Attached is a patch for fixing this problem, please test. |
|
I have applied the patch to lazarus trunk and all looks OK. Attached image with the results (printing to PDF). |
|
|
|
I applied the change, please test. |
Date Modified | Username | Field | Change |
---|---|---|---|
2019-01-23 10:23 | Timl | New Issue | |
2019-01-23 10:23 | Timl | File Added: printtest.tar.lzma | |
2019-01-23 21:24 | Anton Kavalenka | Note Added: 0113601 | |
2019-01-24 01:02 | Juha Manninen | Relationship added | related to 0034680 |
2019-01-24 01:04 | Juha Manninen | Note Added: 0113605 | |
2019-01-24 21:20 | Juha Manninen | Note Edited: 0113605 | View Revisions |
2019-03-16 18:21 | Juha Manninen | Assigned To | => Jesus Reyes |
2019-03-16 18:21 | Juha Manninen | Status | new => assigned |
2019-03-16 18:22 | Juha Manninen | Note Added: 0114872 | |
2019-03-19 15:31 | Jesus Reyes | File Added: gtkprnfix.diff | |
2019-03-19 15:36 | Jesus Reyes | LazTarget | => - |
2019-03-19 15:36 | Jesus Reyes | Note Added: 0114926 | |
2019-03-19 15:36 | Jesus Reyes | Status | assigned => feedback |
2019-03-19 16:40 | Julio Jiménez Borreguero | Note Added: 0114927 | |
2019-03-19 16:41 | Julio Jiménez Borreguero | File Added: Captura de pantalla de 2019-03-19 16-35-39.png | |
2019-03-19 16:41 | Julio Jiménez Borreguero | Note Edited: 0114927 | View Revisions |
2019-03-20 04:15 | Jesus Reyes | Fixed in Revision | => 60732 |
2019-03-20 04:15 | Jesus Reyes | LazTarget | - => 2.0.2 |
2019-03-20 04:15 | Jesus Reyes | Note Added: 0114934 | |
2019-03-20 04:15 | Jesus Reyes | Status | feedback => resolved |
2019-03-20 04:15 | Jesus Reyes | Fixed in Version | => 2.0.2 |
2019-03-20 04:15 | Jesus Reyes | Resolution | open => fixed |
2019-03-20 04:15 | Jesus Reyes | Target Version | => 2.0.2 |
2020-03-05 12:08 | Juha Manninen | Relationship added | related to 0036753 |