Page 1 of 1

Scalerichview - export to pdf

Posted: Wed Apr 08, 2015 1:06 pm
by RobertoVG
Hi,

I exported to pdf file with serious problem
there is a paragraph of duplication (justified) when it involves two pages.
For some reason the first page, it duplicates part of the paragraph invading the footer, and the second page prints the end of the paragraph correctly.

see this file:
http://www.sispaic.com.br/PFNsis/testepdf.pdf


below the code generate with synopse:

procedure ExportaParaPdf ( handle:HWND; srve :TSRichViewEdit; Arquivo:String);
var
i: Integer;
Metafile: TMetafile;
RVUnit: TRVUnits;
R : TRect;
//synopse
PdfDoc : TPDFDocument;

begin
srve.Update; //srve is ScaleRichViewComponent

RVUnit := srve.UnitsProgram; //Get the current value
srve.UnitsProgram := rvuPixels; //Change DBSRichviewEdit to pixels for PDF Conversion

PdfDoc := TPdfDocument.Create;
PdfDoc.GeneratePDF15File:=true;

for i := 1 to srve.PageCount do
begin

Metafile := MakePageMetafile(srve,i, Round(srve.PageWidth100Pix), Round(srve.PageHeight100Pix));

try

PdfDoc.DefaultPageWidth := MulDiv(srve.PageWidth100Pix,72,PdfDoc.ScreenLogPixels);
PdfDoc.DefaultPageHeight := MulDiv(srve.PageHeight100Pix,72,PdfDoc.ScreenLogPixels);

PdfDoc.AddPage;

PdfDoc.Canvas.RenderMetaFile(MetaFile,1,0,0);


finally
Metafile.Free;
end;
end;

PdfDoc.SaveToFile(Arquivo);
PdfDoc.Free;

ShellExecute(Handle, nil, PChar(Arquivo), nil, nil, SW_SHOWNORMAL);

srve.UnitsProgram := RVUnit; //Change back to the previous value before converted to pixels

end;

some reference already solved involving about this occurrence?

Thanks

Posted: Wed Apr 08, 2015 1:49 pm
by egal
possible solution for your problem:
http://www.trichview.com/forums/viewtop ... 8042#28042 ?

Posted: Wed Apr 08, 2015 2:18 pm
by RobertoVG
hello thank you!

I realized this test but this solution does not affect/fix the problem reported / export to pdf

Posted: Fri Apr 10, 2015 7:51 am
by Sergey Tkachenko
There is a similar issue not related to tables, but resulting the same problem:
- SRichViewEdit draws extra content at the beginning/end of pages
- drawing and printing is correct because this extra content is clipped
- problems in PDF output, if PDF tool does not handle clipping correctly.

This similar issue is related to multiline text items.
We fixed it in our working version, his fix will be uploaded in the next update for registered users.

Posted: Fri Apr 10, 2015 11:30 am
by RobertoVG
Hi Sergey, thanks

The problem is synpdf and edocengine and I have reported it to them.

I realized a temporary solution reviewing all paragraph (dividing 2 pages) of the second page onwards. Note that the error does not occur in paragraph between the first page and the second page. Thus forced a "soft line break" on the line "dividing" the parágrafros involving this situation:

procedure PreencheCtrlShift(Editor:TSRichViewEdit);
var CurrentPage,
FirstItemNo,FirstOffs,LastItemNo, LastOffs,Offs,item:integer;
begin
if (Editor.PageCount<=2) then exit;
Editor.CanUpdate:=false;
item:=Editor.RichViewEdit.CurItemNo;
Offs:=Editor.RichViewEdit.OffsetInCurItem;
CurrentPage := 2;


while CurrentPage <= Editor.PageCount do begin
//se existir página seguinte à página corrente
if (CurrentPage+1 <= Editor.PageCount) then begin
//pega o ultimo item da página corrente
Editor.GetPageLastItemNo(CurrentPage, LastItemNo, LastOffs);
//pega o primeiro item da página seguinte
Editor.GetPageStartItemNo((CurrentPage+1), FirstItemNo, FirstOffs);
//se o item for o mesmo então refere-se a mesmo parágrafo
if FirstItemNo=LastItemNo then begin
//move o cursor para o final e insere "soft Line break"
// RVSetSelection(Editor.RichViewEdit, Offs,1);
Editor.RichViewEdit.SetSelectionBounds(LastItemNo,LastOffs,LastItemNo,LastOffs);
Editor.RichViewEdit.InsertTextW(WideChar($2028));

end;

end;
CurrentPage := CurrentPage + 1;
end;

Editor.RichViewEdit.SetSelectionBounds(Item,Offs,Item,Offs);
Editor.CanUpdate:=true;
end;


in my case, as previous routine, the call was so:

procedure ExportaParaPdf ( handle:HWND; srve :TSRichViewEdit; Arquivo:String);
...
...
begin
PreencheCtrlShift(srve);
srve.Update;

......
......
......
end;