Printing isn't correct on every printers

General TRichView support forum. Please post your questions here
marcpleysier
Posts: 39
Joined: Sun Aug 13, 2006 12:46 pm
Contact:

Post by marcpleysier »

OK, it seem to work fine :-)
I will deploy on test sites tomorow.
marcpleysier
Posts: 39
Joined: Sun Aug 13, 2006 12:46 pm
Contact:

Post by marcpleysier »

Print out is correct now. Thanks :D

But the PDF and image exports, with TExtraDevice, didn't work anymore. It seems that the correction for the print output isn't compatible with TExtraDevice export.
See my bug report at http://www.trichview.com/forums/viewtopic.php?t=1426
marcpleysier
Posts: 39
Joined: Sun Aug 13, 2006 12:46 pm
Contact:

Post by marcpleysier »

Sergey...

Please look at the integration with TExtraDevice :(
It doesn't work till you correct the print out issue with RB.

PDF export of RB reports is very important for us.
Sergey Tkachenko
Site Admin
Posts: 17499
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I'll try to do it tomorrow or at the beginning of the next week. Sorry for the delay.
marcpleysier
Posts: 39
Joined: Sun Aug 13, 2006 12:46 pm
Contact:

Post by marcpleysier »

what week are you talking of?
Sergey Tkachenko
Site Admin
Posts: 17499
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

For printing in images, you need to fix ppRichView.pas.
For RB7 wrapper, you need to replace TppDrawRichView.DrawTo (I marked the lines to add)

Code: Select all

procedure TppDrawRichView.DrawTo(lCanvas: TCanvas; ADrawRect: TRect);
var
  lHelper: TRVReportHelper;
  lRVStyle: TRVStyle;
  PPI: Integer;
begin
  lHelper := TRVReportHelperRef.Create(nil);
  lRVStyle := TRVStyle.Create(Nil);

  try
    if not TPPRICHVIEWUSEPRINTERRES then
      lRVStyle.TextStyles.PixelsPerInch := TPPRICHVIEWREFCANVASPPI;
    SetHelperDefaults(lHelper);
    lHelper.RichView.Style := lRVStyle;
    FStream.Position := 0;
    lHelper.RichView.LoadRVFFromStream(FStream);
    lHelper.Init(FCanvasRef, FPageWidth);
    lHelper.FormatNextPage(FPageHeight * 2);

    if Transparent then begin
       lCanvas.CopyMode    := cmSrcAnd;
    end else begin
       lCanvas.CopyMode    := cmSrcCopy;
       lCanvas.Brush.Style := bsSolid;
       lCanvas.Brush.Color := FColor;
       lCanvas.FillRect(ADrawRect);
    end;

    lCanvas.Brush.Style := bsClear;

    IntersectClipRect(lCanvas.Handle, ADrawRect.Left, ADrawRect.Top, ADrawRect.Right, ADrawRect.Bottom);

    SetMapMode(lCanvas.Handle, MM_ANISOTROPIC);
    SetWindowExtEx(lCanvas.Handle, FPageWidth, FPageHeight, Nil);
    PPI := lCanvas.Font.PixelsPerInch;
    if not TPPRICHVIEWUSEPRINTERRES then
      lCanvas.Font.PixelsPerInch := TPPRICHVIEWREFCANVASPPI
    [color=blue]else
      lCanvas.Font.PixelsPerInch := FCanvasRef.Font.PixelsPerInch;[/color]

    SetViewportExtEx(lCanvas.Handle, ADrawRect.Right - ADrawRect.Left, ADrawRect.Bottom - ADrawRect.Top, Nil);
    SetViewportOrgEx(lCanvas.Handle, ADrawRect.Left, ADrawRect.Top, Nil);
    lHelper.TransparentBackground := FTransparent;
    if not Transparent then
      lHelper.RichView.Color := Color;

    lHelper.DrawPage(1, lCanvas, True, FPageHeight);

    lCanvas.Font.PixelsPerInch := PPI;
    SetMapMode(lCanvas.Handle, MM_TEXT);
    SetViewportOrgEx(lCanvas.Handle, 0, 0, Nil);
    SelectClipRgn(lCanvas.Handle, 0);
  finally
    lHelper.Free;
    lRVStyle.Free;
  end;
end;
Sergey Tkachenko
Site Admin
Posts: 17499
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Do you really mean TExtraDevices (www.waler.com)?
In my version of TExtraDevices, they do not use RichView drawing procedure when exporting to PDF. Instead, it saves RichView to RTF, then draw this RTF as it draws standard RichEdit.
So changes in ppRichView drawing do not affect PDF export with TExtraDevices.
marcpleysier
Posts: 39
Joined: Sun Aug 13, 2006 12:46 pm
Contact:

Post by marcpleysier »

OK, it works :-)
PDF and Image exports are OK now.

Yes I use TExtraDevices 2.8, and rich texts (TRichEdit or TRichView) can be exported as plain text or as image. Not as RTF (too bad).
Michael Pro
Posts: 42
Joined: Wed Feb 28, 2007 4:14 am

Post by Michael Pro »

Greetings!
Sergey, I've got some troubles trying to print my RichView Document with TRVPrint on HP LaserJet 1100.
The main trouble is that TRVPrint doesn't print line spacings correctly - lines on a page looks overlapped :(
How should I solve this problem?
On Rich Preview everything looks just fine, but on paper it doesn't look like WISYWIG.
PS In my editor, I didn't change any linespacing parameters in paragraphs - so it's default - measured in percents and set to 100.
PPS In my situation it seems like printing doesn't implement linespacing feature at all :(
Well, I've tested source from demos - it looks ok, but I couldn't find, why it's wrong, then I'm trying to print my docs. The only thing, that I do - I loading document from database blob and trying to print it. Maybe I need to reformat it first - or something else - but on initalization I use FormatPages method - and everything looks fine. :(
PPPS I've found, that this doesn't work with files, created in my overrided RichViewEditor. Maybe, the problem is in creating new styles and paragraphs? I didn't make them standard - is where any additional parameters needed?
Actually, I didn't make any criminal actions in creating new styles (as I think :) )
It looks like that

Code: Select all

  FHyperlinkStyle := TFontInfo.Create(nil);
  FHyperlinkStyle.Style := FHyperlinkStyle.Style + [fsUnderline];
  FHyperlinkStyle.Color := clBlue;
  FHyperlinkStyle.Jump := True;
  FHyperlinkStyle.JumpCursor := crHandPoint;
  FHyperlinkStyle.HoverColor := clWhite;
  FHyperlinkStyle.HoverBackColor := clBlue;
  FHyperlinkStyle.Protection := [rvprModifyProtect, rvprStyleProtect, rvprDoNotAutoSwitch];
  Style.TextStyles.Add;
  NewStyleNo := Style.TextStyles.Count - 1;
  Style.TextStyles[NewStyleNo].Assign(FHyperlinkStyle);
  Style.TextStyles[NewStyleNo].Standard := False;
And for ParaInfo

Code: Select all

pi.Assign(Style.ParaStyles[GetItemPara(i)]);
      pi.LeftIndent := ListLevel.MarkerIndent;
      NewStyleNo := Style.ParaStyles.FindSuchStyle(0, pi, RVAllParaInfoProperties);
      if NewStyleNo = -1 then begin
        Style.ParaStyles.Add;
        NewStyleNo := Style.ParaStyles.Count-1;
        Style.ParaStyles[NewStyleNo].Assign(pi);
        Style.ParaStyles[NewStyleNo].Standard := False;
      end;
      GetItem(i).ParaNo := NewStyleNo;
      CurParaStyleNo := NewStyleNo;
Sergey Tkachenko
Site Admin
Posts: 17499
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Does the problem persist if you save document created by your program and load it in demo?
If yes, please send this document to me.
Michael Pro
Posts: 42
Joined: Wed Feb 28, 2007 4:14 am

Post by Michael Pro »

Sergey Tkachenko wrote:Does the problem persist if you save document created by your program and load it in demo?
If yes, please send this document to me.
Well, from your demo my documents are printed wonderfully well. But I couldn't find, what can make it work so bad from my inherited class :) - everything formatted and showed in the best way. :)
I'll try to make invisible standard component on my form to assign RVData and RVStyle for printing - if nothing helps, I'll post the load method here.
In my case it looks like it printing whole document, using standard style - Arial 10 pt - for page marking and defining border of items in page.
Hyperlinks are also printed - but with strange overlapping - like they aren't text items at all.
Michael Pro
Posts: 42
Joined: Wed Feb 28, 2007 4:14 am

Post by Michael Pro »

Well, I didn't find this bug :(
First, I thought, that rvData is not assign properly.
I've traced program in AssignSource and found that all data is assigned properly.
For example

Code: Select all

PChar(TCustomRVItemInfo(rv.RVData.Items.Objects[5]).Tag)
It's string tag in text for hyperlink - and it's seems, that all works correctly in this stage.
Despite that I'm using inherited class in my editor, I didn't noticed any troubles in a stage of variables initialization.
Styles object and RVData created correctly - but something inside of TRVPrint makes correct work impossible :(
Sergey, do you have any ideas about this situation? Your demos works perfectly - but for some reasons it won't work in my situation.
PS I've traced all stages of printing - even OnSendingToPrinter - page by page - all RVData with all links, styles and other things exists, but it printed in described way - with marking of Arial 10 pt for whole text :(
Hyperlink doesn't look marked at all.
Sergey Tkachenko
Site Admin
Posts: 17499
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

May be data was converted to wrong styles BEFORE calling AssignSource?
May be you loaded/saved document using trichview that is not "allow adding styles dynamically" mode?
Michael Pro
Posts: 42
Joined: Wed Feb 28, 2007 4:14 am

Post by Michael Pro »

Sergey Tkachenko wrote:May be data was converted to wrong styles BEFORE calling AssignSource?
May be you loaded/saved document using trichview that is not "allow adding styles dynamically" mode?
It's sadly - but "no" for a two times.
The first thing that I've traced, was AssignSource method - before and after - it takes correct pointer to RVData and correct pointer to RVStyle :(
All flags are set properly :( I've examined this part numerous times - and it loads saved rvfs from demos correctly.
Also, I've implemented Format for RichViewEdit and FormatPages methods directly before calling Print method. But big rvf file from demo (I've converted demo.rtf to rvf) still looks totally unformatted :(
On the 10th of May I'll test my preview dialog and print setup from base RichViewEdit, not from inherited class, and shall try to print rvf documents from richview demo package.
Michael Pro
Posts: 42
Joined: Wed Feb 28, 2007 4:14 am

Post by Michael Pro »

Sergey, I've just sent you a letter with a test form.
Please, examine it and tell, what I doing wrong.
I've made some simplifications - it only makes preview in dialog and simply prints.
Post Reply