#1 2011-09-20 22:39:30

Leander007
Member
From: Slovenia
Registered: 2011-04-29
Posts: 113

Invalid output of TGDIPages using PDF Export and WordWrapLeftCols

Hello Arnaud.

I found some invalid behavior with PDF export when WordWrapLeftCols is used. Content rendered with ShowPreviewForm is correctly shown on the screen, but when exporting report to the pdf is done, all texts which are short (word wrapping is not needed) following the first column which needs word wrapping are "INVISIBLE" (they are there, if you try to copy data, but not visible ?!).

This code snippet will reproduce the issue:

(...)
    WordWrapLeftCols := true;
    AddColumns([10,22,22,22,22]);
    AddColumnHeaders(['#','Two','Three','4','5'],true,true);
    for i := 1 to 50 do
      DrawTextAcrossCols([IntToStr(i),'Column '+IntToStr(i),
      'This is some big text which must be justified on multiple lines. Text "four" and "five" will be invisible in pdf...',
      'four','five']);
(...)

As it's already written only short texts ('four', 'five') following at least one long text will be invisible in PDF output.

Please, could you look at it.
You will find the causing problem faster then me.


"Uncertainty in science: There no doubt exist natural laws, but once this fine reason of ours was corrupted, it corrupted everything.", Blaise Pascal

Offline

#2 2011-09-23 09:45:20

Leander007
Member
From: Slovenia
Registered: 2011-04-29
Posts: 113

Re: Invalid output of TGDIPages using PDF Export and WordWrapLeftCols

I have been investigating what is wrong in output pdf. First I converted output pdf to plain pdf commands (/FlateDecode).
Then I moved the "invisible" text (Td command) via Y axis for some amount and the content was shown.
So obviously the content is overwritten via some "pdf object".

I thought that pdf content is wrongly generated, but then I used ForcePrintAsBitmap of TGDIPages and result was the same.
So the problem is already at TMetafile level.


Why is content rendered correctly in preview form, but not when flushed to the BMP via ForcePrintAsBitmap?
Flushing of PreviewSurfaceBitmap is obviously ok.

Arnaud do you have a clue what is going on?

Last edited by Leander007 (2011-09-23 10:26:50)


"Uncertainty in science: There no doubt exist natural laws, but once this fine reason of ours was corrupted, it corrupted everything.", Blaise Pascal

Offline

#3 2011-09-23 10:51:29

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,238
Website

Re: Invalid output of TGDIPages using PDF Export and WordWrapLeftCols

Perhaps there is some white filled brushed rectangles painted after the text is printer...
Did you set Canvas.Brush.Style to not solid state?

I did not have time to investigate yet.

Offline

#4 2011-09-23 11:16:54

Leander007
Member
From: Slovenia
Registered: 2011-04-29
Posts: 113

Re: Invalid output of TGDIPages using PDF Export and WordWrapLeftCols

This is somehow related to the scaling of the "elements", because in BMP (print as bitmap) case
following code works well (copied from PaintPreview, case for GDI+):

rec := Rect(0,0,Bmp.Width,Bmp.Height);
if not ForceNoAntiAliased then
   DrawEmfGdip(BMP.Canvas.Handle,TMetaFile(Pages.Objects[i]), rec,ForceInternalAntiAliased);

and this does not (original code for ForcePrintAsBitmap in TGDIPages.PrintPages function), which does some stretching (scaling)  - I'm guessing from the name of procedure:

BMP.Canvas.StretchDraw(Rect(0,0,Bmp.Width,Bmp.Height), TMetaFile(Pages.Objects[i]));

and with pdf export must be same issue when using "metafile to pdf commands".

Hopefully this narrow the problem down...
For me this solution becomes from "show stopper" to "accepted workaround", because at least I need working printing (pdf export is fine feature, but not the requirement in my application).

Last edited by Leander007 (2011-09-23 11:22:28)


"Uncertainty in science: There no doubt exist natural laws, but once this fine reason of ours was corrupted, it corrupted everything.", Blaise Pascal

Offline

#5 2011-09-23 12:17:10

Leander007
Member
From: Slovenia
Registered: 2011-04-29
Posts: 113

Re: Invalid output of TGDIPages using PDF Export and WordWrapLeftCols

It is not the stretch part, because plain draw fails too:

BMP.Canvas.Draw(0,0, TMetaFile(Pages.Objects[i]));

So, for now only your DrawEmfGdip does the job, when you wish to print as it is shown on the screen!


"Uncertainty in science: There no doubt exist natural laws, but once this fine reason of ours was corrupted, it corrupted everything.", Blaise Pascal

Offline

#6 2011-09-23 12:18:02

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,238
Website

Re: Invalid output of TGDIPages using PDF Export and WordWrapLeftCols

There is an issue with the TGDIPages.DrawTextAcrossCols.

The clipping region (as specified by RowRect) was not reset as expected after a word wrapped cell (in RowRect).

Fixed by http://synopse.info/fossil/info/908cb32f20

Thanks for the feedback.

Offline

#7 2011-09-26 09:07:17

Leander007
Member
From: Slovenia
Registered: 2011-04-29
Posts: 113

Re: Invalid output of TGDIPages using PDF Export and WordWrapLeftCols

Thanks to you for finding the real issue smile.
Now works as expected.


"Uncertainty in science: There no doubt exist natural laws, but once this fine reason of ours was corrupted, it corrupted everything.", Blaise Pascal

Offline

Board footer

Powered by FluxBB