#1 2012-11-11 13:00:13

amnon
Member
Registered: 2012-10-26
Posts: 10

problem with Landscape

Hi,

I try to print metafiles to PDF using the following code

var
  i:integer;
  _PDF:TPdfDocumentGDI;
  FN:ansiString;
  aMeta:TMetaFile;
begin
  _PDF:= TPdfDocumentGDI.Create;
  with _PDF do begin
    UseUniscribe:= true;
    try
      _PDF.Canvas.RightToLeftText:= true;
      ScreenLogPixels:= 600;
      with PagePrinter do for i:= 1 to PagesList.count do begin
        with AddPage do begin
          aMeta:= TMetaFile(Pages);
          if PagePrinter.Orientation=poLandscape then begin
//            Orientation:= poLandscape;
//            DefaultPaperSize:= PSA5;
            _Pdf.DefaultPageWidth := MulDiv(aMeta.Width,72,_Pdf.ScreenLogPixels);
            _Pdf.DefaultPageHeight := MulDiv(aMeta.Height,72,_Pdf.ScreenLogPixels);
          end;
//          _pdf.VCLCanvas.Draw(0,0,aMeta);   // from "http://forum.quickreport.co.uk/default. … osts&t=589"
          _PDF.Canvas.RenderMetaFile(aMeta); // from "http://synopse.info/forum/viewtopic.php?id=138"
        end;
      end; // with PagePrinter
      with TSaveDialog.Create(NIL) do begin
        DefaultExt:= 'PDF';
        Title:= 'PDF שמור קובץ';
        if Execute then begin
          FN:= FileName;
          SaveToFile(FileName);
          WinExecAndWait(pchar(FN),'','',SW_SHOWNORMAL,{_Wait=}false);
        end;
      end;
    finally
      _PDF.free;
    end;
  end;

My problem is that the 1st page is size A4 and the data is cut.

The next 100 pages are ok

thanks

Amnon

Offline

#2 2012-11-11 20:34:00

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

Re: problem with Landscape

Set the page dimension before adding the page.

Offline

#3 2012-11-12 06:05:17

amnon
Member
Registered: 2012-10-26
Posts: 10

Re: problem with Landscape

Thanks smile

Just a stupid bug

Offline

Board footer

Powered by FluxBB