#1 PDF Engine » Graphics are distorted when DrawMeta function is used in GDIPages » 2024-09-10 10:07:46

pjain
Replies: 1

Hi,
   I am using GDIPages to print out a report  with graphics on each page. My data source is a list of meta file.
   When I am trying to use whole page space on either A3/A4 pages, my image is loosing colours . basically it looks like the text is there but the colours are gone.
   I have a doubt that if its an issue because of the graphic is stretched or something else. I am just using below code to draw the meta file in a specific rectangle.

   

      LPdfGDI.DrawMeta(R, TMetafile(AMetafilesList[i])); 
  

Thanks.

#2 Re: PDF Engine » Rendering issue of metafile in TGDIPages. » 2024-07-10 07:56:36

Could you please suggest which method to use, i tried using PrinterToMM but its giving me pretty small rectangle. Also i can see that inside DrawMeta, there is again mm to printer is used.

procedure TGDIPages.DrawMeta(rec: TRect; meta: TMetafile);
var old: Integer;
begin
  if Self=nil then exit; // avoid GPF
  CheckHeaderDone;
  rec := MmToPrinter(rec);
  old := SaveDC(fCanvas.Handle);   // ensure safe metafile embedding
  PlayEnhMetaFile(fCanvas.Handle, meta.Handle, rec);
  RestoreDC(fCanvas.Handle,old);
end;

#3 Re: PDF Engine » Rendering issue of metafile in TGDIPages. » 2024-07-09 08:57:52

Hi,

thanks for your reply.  I've changed the function a bit to make calculation a bit simpler for now. still the pdf doesnt look good.
It seems like the bitmap is streched a lot inside the rectangle.

would it be possible to change the interface so that DrawMeta accepts R in pixels just to do less calculations.

LPdfGDI := TGDIPages.Create(Self)
LPdfGDI.BeginDoc;
for I := 0 to AMetaFilesList.Count - 1 do
begin
    R.Left := 0;
    R.Right := TMetafile(AMetafilesList[i]).mmwidth ;
    R.Top := 0;
    R.Bottom := TMetafile(AMetafilesList[i]).height;
    LPdfGDI.DrawMeta(R, TMetafile(AMetafilesList[i]));
    LPdfGDI.NewPage;
end;
LPdfGDI.EndDoc;
LPdfGDI.ExportPDF('f:\gdipdf.pdf',false,false);
LPdfGDI.Free;

#4 PDF Engine » Rendering issue of metafile in TGDIPages. » 2024-07-04 13:33:30

pjain
Replies: 4

Hi,

I have a list of metafiles which i need to render in pdf file along with header and footer. for that purpose i am using TGDIPages. below is sample code i have
my meta file's width and height are : 1500 and 1000 respectively. Unfortunately the resolution of graphic in pdf is reduced to a very small size.

LPdfGDI := TGDIPages.Create(Self)
LPdfGDI.BeginDoc;
for I := 0 to AMetaFilesList.Count - 1 do
begin
    R.Left := LPdfGDI.PageMargins.Left;
    R.Right := TMetafile(AMetafilesList[i]).width - LPdfGDI.PageMargins.Right;
    R.Top := LPdfGDI.PageMargins.Top;
    R.Bottom := TMetafile(AMetafilesList[i]).height -LPdfGDI.PageMargins.Top;
    LPdfGDI.DrawMeta(R, TMetafile(AMetafilesList[i]));
    LPdfGDI.NewPage;
end;
LPdfGDI.EndDoc;
LPdfGDI.ExportPDF('f:\gdipdf.pdf',false,false);
LPdfGDI.Free;

Just wondering if anyone has faced similar issue and have any solution or other way to do this.

Thanks.

#6 PDF Engine » TGDIPages : How to add multiple pages in report » 2024-07-02 14:14:05

pjain
Replies: 2

Hi,
I've a list of metafiles and i would like to export these in a pdf . I am using TGDIPages to do that.
I also have header and footer to add to each page. I am not sure how can i generate multiple pages using TGDIPages. I've done similar with TPdfDocumentGDI but could not add header/footer hence using this.
Any help is apprciated. Thanks.

Board footer

Powered by FluxBB