#1 Re: PDF Engine » PDF rendering not correct » 2022-08-03 12:40:10

Yes, you're right. I need only the UseUniscribe := True. All others have no effect.

#2 Re: PDF Engine » PDF rendering not correct » 2022-08-02 13:30:56

Thanks for your help.
But the top line looks good with 5,00 EUR. Only the lines below are wrong.

Now, I added:  pdf.UseMetaFileTextPositioning:= tpExactTextCharacterPositining, but no better result.


Now, it seems to be solved, hopefully.

I changed some parameters and now all of my test pdf files are OK.


procedure CreateReportAsPDF(aReport: TQuickRep; const aFileName: TFileName);
var Pdf: TPdfDocumentGdi;
     aMeta: TMetaFile;
     i: integer;
begin
  Pdf := TPdfDocumentGdi.Create;
  try
    aReport.Prepare;
    //pdf.UseMetaFileTextPositioning:= tpExactTextCharacterPositining;
    pdf.DefaultPaperSize := psA4;
    pdf.UseFontFallBack := True;
    pdf.UseUniscribe := True;
    pdf.FontFallBackName :='Arial';
    pdf.ScreenLogPixels :=96;

    for i := 1 to aReport.QRPrinter.PageCount
    do begin
      aMeta := aReport.QRPrinter.GetPage(i);
      try
       // Pdf.DefaultPageWidth := MulDiv(aMeta.Width,72,Pdf.ScreenLogPixels);
       // Pdf.DefaultPageHeight := MulDiv(aMeta.Height,72,Pdf.ScreenLogPixels);
        Pdf.AddPage;
        // draw the page content
        Pdf.Canvas.RenderMetaFile(aMeta,1,0,0);
      finally
        aMeta.Free;
      end;
    end;
    Pdf.SaveToFile(aFileName);
  finally
    Pdf.free;
  end;
end;

Have somebody any idea, what was wrong before? Or something wrong on my QR definitions?

#3 Re: PDF Engine » PDF rendering not correct » 2022-08-02 12:05:19

Now, I hope, you can download the files.

meta file:
https://www.dropbox.com/s/eoy8leijphzu0t0/meta.wmf?dl=0

pdf file
https://www.dropbox.com/s/k6zy5xenmr7ig … 2.PDF?dl=0

What's wrong:
- values on the right
- footer text

#4 Re: PDF Engine » PDF rendering not correct » 2022-08-02 11:06:45

Please forget the alignment problem. It was only a workaround but now I have used another invoice and it's wrong again.

I cannot understand why sometimes it's correct.

To debug the meta data, I'm not the expert and I see the problem to solve my problem. In the quick report, I'm using the font Arial Size 9.

I will try to upload my samples to dropbox and hopefully, I can create the link for you.

#5 Re: PDF Engine » PDF rendering not correct » 2022-08-02 10:26:57

Hi, sorry for my bad explanation, but I tried already to give you some sample results, but not possible for me to create the link ;-).

Now, I have created the meta WMF file and it looks correct, but the PDF file does not.
Additionally, I have created the WMF file out of QR and it looks perfect as well.

Pls have a look at my source:

procedure CreateReportAsPDF(aReport: TQuickRep; const aFileName: TFileName);
var Pdf: TPdfDocument;
     aMeta: TMetaFile;
     i: integer;
begin
  Pdf := TPdfDocument.Create;
  try
    aReport.Prepare;
   // pdf.DefaultPaperSize := psA4;
    for i := 1 to aReport.QRPrinter.PageCount do begin
      aMeta := aReport.QRPrinter.GetPage(i);
      aMeta.SaveToFile('C:\temp\WMF\meta.wmf');
      try
        Pdf.DefaultPageWidth := MulDiv(aMeta.Width,72,Pdf.ScreenLogPixels);
        Pdf.DefaultPageHeight := MulDiv(aMeta.Height,72,Pdf.ScreenLogPixels);
        Pdf.AddPage;
        // draw the page content
        Pdf.Canvas.RenderMetaFile(aMeta,1,0,0);
      finally
        aMeta.Free;
      end;
    end;
    Pdf.SaveToFile(aFileName);
  finally
    Pdf.free;
  end;
end;

.

I have no idea why it doesn't work.

BR, Klaus

#6 Re: PDF Engine » PDF rendering not correct » 2022-07-28 13:34:04

Sorry, for my bad explanation.
The QR has some labels to show the prices for net, vat and brut, like.

  lblSum4.Caption:= format('%7.2n',[Gesamtsumme]);  // 28.07.2022 changed from 11,2

#7 Re: PDF Engine » PDF rendering not correct » 2022-07-28 10:59:05

I found the problem, but still strange.
I changed the length of the format command from format('%11.2n) to format('%7.2n) and now it seems correct, but why?

It is very strange to me and I see the problem that I cannot trust them.

As I mentioned, If I print out the QR to freepdf it works in all cases.

Klaus

#8 PDF Engine » PDF rendering not correct » 2022-07-28 08:44:39

KlausV
Replies: 12

Hello,
I have to change a very old delphi program (delphi 7) to extend it by the PDF function.
I have installed the latest version of the PDF tool.

Source code:

procedure CreateReportAsPDF(aReport: TQuickRep; const aFileName: TFileName);
var Pdf: TPdfDocument;
     aMeta: TMetaFile;
     i: integer;
begin
  Pdf := TPdfDocument.Create;
  try
    aReport.Prepare;
    pdf.DefaultPaperSize := psA4;
    for i := 1 to aReport.QRPrinter.PageCount do begin
      Pdf.AddPage;
      aMeta := aReport.QRPrinter.GetPage(i);
      try
        Pdf.Canvas.RenderMetaFile(aMeta,1,0,0);
      finally
        aMeta.Free;
      end;
    end;
    Pdf.SaveToFile(aFileName);
  finally
    Pdf.free;
  end;
end;

I tried in that style, but no better result:

procedure CreateReportAsPDF(aReport: TQuickRep; const aFileName: TFileName);
var Pdf: TPdfDocument;
     aMeta: TMetaFile;
     i: integer;
begin
  Pdf := TPdfDocument.Create;
  try
    aReport.Prepare;
   // pdf.DefaultPaperSize := psA4;
    for i := 1 to aReport.QRPrinter.PageCount do begin
      Pdf.AddPage;
      aMeta := aReport.QRPrinter.GetPage(i);
      try
        Pdf.DefaultPageWidth := MulDiv(aMeta.Width,72,Pdf.ScreenLogPixels);
        Pdf.DefaultPageHeight := MulDiv(aMeta.Height,72,Pdf.ScreenLogPixels);
        Pdf.AddPage;
        // draw the page content
        Pdf.Canvas.RenderMetaFile(aMeta,1,0,0);
      finally
        aMeta.Free;
      end;
    end;
    Pdf.SaveToFile(aFileName);
  finally
    Pdf.free;
  end;
end;

When I create the invoice, sometimes the rendering works, but sometimes not. The quickreport result always looks perfect. When I print the quickreport report by FREEPDF it looks good as well.
What's wrong.
Thanks
BR, Klaus

Board footer

Powered by FluxBB