#1 PDF Engine » synpdf last version » 2016-01-26 21:25:03

BetoVG
Replies: 0

Hi,

I have used that code below in previous version, but after last update (1.18) when i have the image, after show that the after text do not show

-----image---------- show
text           --------- not show
text           --------- not show


procedure ExportaParaPdf ( handle:HWND; srve :TSRichViewEdit; Arquivo:String);
var
    LDocument: TPdfDocumentGDI;
    i: Integer;
    LPage: TPdfPage;
    LCanvas: TCanvas;
    LPageSize: TSize;
    LTextRect: TRect;
    RVUnit: TRVUnits;
   
    function CalcTextRect(const ADocument: TPdfDocumentGDI; const AText: TSRichViewEdit): TRect;
    var
        LMultiPixels: Extended;
    begin
        LMultiPixels := 1.0;
        Result.Left := Round(AText.LeftMargin100Pix * LMultiPixels);
        Result.Top := Round(AText.TopMargin100Pix * LMultiPixels);

       Result.Right := Round((AText.PageWidth100Pix )  * LMultiPixels);

        Result.Bottom := Round((AText.PageHeight100Pix )  * LMultiPixels);
    end;

begin

  srve.Update; //srve is ScaleRichViewComponent

  RVUnit := srve.UnitsProgram; //Get the current value
  srve.UnitsProgram := rvuPixels; //Change DBSRichviewEdit to pixels for PDF Conversion
 
    LDocument :=  TPdfDocumentGDI.Create(False, 0, True, nil); //With PDF/A//
    try
        LDocument.DefaultPaperSize := psA4;

       // LDocument.ScreenLogPixels := 300;  -> here work in previous version but not in 1.18
        LDocument.EmbeddedTTF := True;
        LDocument.EmbeddedWholeTTF := True;
        if srve.PageProperty.Orientation=poPortrait then
          LDocument.DefaultPageLandscape:=false
        else
          LDocument.DefaultPageLandscape:=true;

        for i := 1 to srve.PageCount do
        begin
            LPage := LDocument.AddPage();

            LCanvas := LDocument.VCLCanvas;
            LPageSize := LDocument.VCLCanvasSize;
            LTextRect := CalcTextRect(LDocument, srve);

            srve.DrawPageEx(i, LPageSize.cx, LPageSize.cy,
                0, 0, LCanvas, LTextRect, True, False, False);


        end;

        LDocument.SaveToFile(Arquivo);
    finally
        LDocument.Free();
    end;

    ShellExecute(Handle, nil, PChar(Arquivo), nil,  nil, SW_SHOWNORMAL);
    srve.UnitsProgram := RVUnit; //Change back to the previous value before converted to pixels

end;


thanks

Beto

#2 Re: PDF Engine » Symbol fonts in PDF » 2015-05-23 00:48:18

Hi, Thanks

your code worked! just had to cash margins

 
  function CalcTextRect(const ADocument: TPdfDocumentGDI; const AText: TSRichViewEdit): TRect;
    var
        LMultiPixels: Extended;
    begin
        LMultiPixels := 1.0;
        Result.Left := Round(AText.LeftMargin100Pix * LMultiPixels);
        Result.Top := Round(AText.TopMargin100Pix * LMultiPixels);
 //       Result.Right := Round((AText.PageWidth100Pix - AText.LeftMargin100Pix - AText.RightMargin100Pix)  * LMultiPixels);
       Result.Right := Round((AText.PageWidth100Pix )  * LMultiPixels); 
//        Result.Bottom := Round((AText.PageHeight100Pix - AText.TopMargin100Pix - AText.BottomMargin100Pix)  * LMultiPixels);
        Result.Bottom := Round((AText.PageHeight100Pix )  * LMultiPixels);
    end;
 

below the code I used:

 

function MakePageMetafile(srve:TSRichViewEdit;aPageNo, aWidth, aHeight: Integer): TMetafile;
var
  savTextDraw: Boolean;
begin
  savTextDraw := ScaleRichViewTextDrawAlwaysUseGlyphs;
  ScaleRichViewTextDrawAlwaysUseGlyphs := false;

  Result := TMetafile.Create;
  Result.Width := aWidth;
  Result.Height := aHeight;
  srve.CanUpdate := False;
  srve.UseDrawHyperlinksEvent := True;
  srve.DrawMetafile(aPageNo, Result, False, True, False);
  ScaleRichViewTextDrawAlwaysUseGlyphs := savTextDraw;
  srve.CanUpdate := True;
  srve.UseDrawHyperlinksEvent := False;
end;
procedure xExportaParaPdf ( handle:HWND; srve :TSRichViewEdit; Arquivo:String);
var
  i: Integer;
  Metafile: TMetafile;
  RVUnit: TRVUnits;
  R : TRect;
  //synopse
  PdfDoc : TPDFDocument;


begin
  PreencheCtrlShift(srve);
  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;

#3 Re: PDF Engine » Symbol fonts in PDF » 2015-05-21 18:12:42

I made these corrections but as you can see this link using bullet and editing the paragraph below it, the text was distorted
(http://www.sispaic.com.br/PFNSis/Test.pdf)

the bullet's image here is in symbol but the texts are in Times New Roman

#4 Re: PDF Engine » pdf engine v1.18 - paragraph 2 between pages is created incorrectly » 2015-04-07 20:06:04

metafile generated before render with pdfdoc create using the statement:

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

  MakePageMetafile is TRichView function that return page metafile below
  (page where the error occurred)

file:
  http://www.sispaic.com.br/PFNsis/teste- … tafile.zip

#5 PDF Engine » pdf engine v1.18 - paragraph 2 between pages is created incorrectly » 2015-04-07 16:31:54

BetoVG
Replies: 1

I'm using "good" synpdf 1 year ago with TRichView, but this latest version, 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.
To avoid doubt, I tested the same situation using BullZip that printed correctly.

(http://bullzip-pdf-printer.1800download … gQoddVoA9w)

comparing pdf
(http://www.sispaic.com.br/PFNsis/teste-synpdf.pdf)

the "test" of metafile first page generated in creating the synpdf
(http://www.sispaic.com.br/PFNsis/teste-synpdf.emf)


code:
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;

Thanks

Béto

#6 Re: PDF Engine » convert freereport to pdf using synpdf » 2014-05-03 23:01:14

after several attempts, I found that solution for my case:

procedure TForm1.SpeedButton6Click(Sender: TObject);
var i,w,h:integer;
EMF: TMetafile;
EMFCanvas: TMetafileCanvas;
PageInfo: PfrPageInfo;
vpdf : TPdfDocumentGDI;
OutDC: HDC;
begin
OutDC := Canvas.Handle;
LogX := GetDeviceCaps(OutDC, LOGPIXELSX);
LogY := GetDeviceCaps(OutDC, LOGPIXELSY);

PDFEscx :=strtofloat(edit1.text);
PDFEscy :=strtofloat(edit1.text);


frReport1.LoadFromFile('C:\Program Files (x86)\Delphi7SE\Testes\FreeReport\Simples\TESTE.frf');
frReport1.ShowProgress:=false;
frReport1.PrepareReport;

vpdf := TPdfDocumentGDI.Create;
vpdf.GeneratePDF15File:=true;
vpdf.CompressionMethod := cmNone;

vPdf.DefaultPaperSize := psA4; // setup for standard 8.5x11 Letter
vPdf.ScreenLogPixels := 72;
for i:=0 to frReport1.EMFPages.Count-1 do begin
PageInfo :=frReport1.EMFPages[i];

EMF := TMetafile.Create;
w:=trunc(PageInfo.prninfo.pgw/logX*vpdf.ScreenLogPixels); 
h:=trunc(PageInfo.prninfo.pgh/logY*vpdf.ScreenLogPixels);


EMF.Width := w;
EMF.Height := h;

EMFCanvas := TMetafileCanvas.Create(EMF, 0);


PageInfo.Visible := True;
frReport1.EMFPages.Draw(i, EMFCanvas,
Rect(0, 0, w, h));


vpdf.AddPage;

EMFCanvas.Free;

vPdf.Canvas.RenderMetaFile(emf, 1, 0, 0, tpExactTextCharacterPositining);


EMF.Free;
end;

vpdf.SaveToFile('C:\Users\BetoVG\Documents\teste.pdf');
vpdf.free;

ShellExecute(Handle, nil, PChar('C:\Users\BetoVG\Documents\teste.pdf'), nil, nil, SW_SHOWNORMAL);
end;

#7 Re: PDF Engine » Delphi 7, Quickreport 3 and Teechart series width » 2014-05-03 04:08:33

a path as you investigate is:

you can evaluate a metafile file generated to assess whether the problem is the
synpdf or between QuickReport and the metafile

example

 
. . . . . 
pagemeta: = QuickRep1.QRPrinter.GetPage (p); 
if i = 0 then pagemeta.SaveToFile ('teste.wmf'); 
. . . . . 

Note: (*) in your example, do not forget to release the memory of the variable pagemeta to prevent leak 

... . . . . . . 

       pagemeta: = QuickRep1.QRPrinter.GetPage (p); 
       vpdf.VCLCanvas.Draw (0,0, pagemeta); 
       pagemeta.free;/ / (*) 
      
  . . . . . . . .

#8 PDF Engine » convert freereport to pdf using synpdf » 2014-05-03 03:55:41

BetoVG
Replies: 1
I am trying to export to pdf, but the pdf page is generated inconsistent where the height, width and font size are not equivalent to the previewed page FreeReport. 

Could anyone help me?

procedure TForm1.SpeedButton6Click(Sender: TObject);
var i:integer;
EMF: TMetafile;
EMFCanvas: TMetafileCanvas;
PageInfo: PfrPageInfo;
vpdf : TPdfDocumentGDI;
begin

frReport1.LoadFromFile('TESTE.frf');
frReport1.ShowProgress:=false;
frReport1.PrepareReport;

vpdf := TPdfDocumentGDI.Create;
vpdf.GeneratePDF15File:=true;
vpdf.CompressionMethod := cmNone;

for i:=0 to frReport1.EMFPages.Count-1 do begin
PageInfo :=frReport1.EMFPages[i];

EMF := TMetafile.Create;

EMF.Width := PageInfo.prninfo.pgw;
EMF.Height := PageInfo.prninfo.pgh;

EMFCanvas := TMetafileCanvas.Create(EMF, 0);
PageInfo.Visible := True;

frReport1.EMFPages.Draw(i, EMFCanvas,
Rect(0, 0, PageInfo.PrnInfo.pgw, PageInfo.PrnInfo.pgh));

vpdf.DefaultPageWidth := MulDiv(PageInfo.PrnInfo.pgw,72,vPdf.ScreenLogPixels);
vPdf.DefaultPageHeight := MulDiv(PageInfo.PrnInfo.pgw,72,vPdf.ScreenLogPixels);


vpdf.AddPage;

EMFCanvas.Free;

vpdf.VCLCanvas.Draw(0,0,EMF);

EMF.Free;
end;

vpdf.SaveToFile('teste.pdf');
vpdf.free;

ShellExecute(Handle, nil, PChar('teste.pdf'), nil, nil, SW_SHOWNORMAL);

end;

Thanks

Board footer

Powered by FluxBB