#1 Re: PDF Engine » Fails to compile in 64-bit Delphi XE2 and XE3 » 2013-03-15 10:32:02

ab wrote:

You may have save you some time... all those modifications are not necessary.


Thanks for the feedback!

Thanks, I will have a look. What I had was the "Latest stable version is available directly from in SynPdf.zip"

Marvel

#2 PDF Engine » Fails to compile in 64-bit Delphi XE2 and XE3 » 2013-03-15 09:39:44

marvel
Replies: 3

This simple test I collect in this forum fails to compile:

var
 lPdf   : TPdfDocument;
 lPage  : TPdfPage;
begin
  lPdf := TPdfDocument.Create;
  try
    lPdf.Info.Author        := 'Tester';
    lPdf.Info.CreationDate  := Now;
    lPdf.Info.Creator       := 'Tester';
    lPdf.DefaultPaperSize   := psA4;
    lPage := lPDF.AddPage;
    lPDF.Canvas.SetFont('Helvetica',10.0,[]);
    lPDF.Canvas.SetLeading(lPDF.Canvas.Page.FontSize);
    lPDF.Canvas.SetLineWidth(0.1);

    lPdf.Canvas.BeginText;
    lPdf.Canvas.TextOut( 300, 700,  'This is some text.');
    lPdf.Canvas.EndText;
    lPdf.SaveToFile(extractfilepath(application.exename)+'test.pdf');
  finally
    lPdf.Free;
  end;

I tracked the issue to 3 problem areas and was able to fix it (at least for the above sample) as follows:

1) In SynCommons.pas move this to the beginning of the Implementation section:

var
  SynLogExceptionEnabled: Boolean = false;

type
  /// an array to all available per-thread TSynLogFile instances
  TSynLogFileIndex = array [0 .. MAX_SYNLOGFAMILY] of integer;

var
  /// internal list of created TSynLog instance, one per each log file on disk
  // - do not use directly - necessary for inlining TSynLogFamily.SynLog method
  SynLogFile: TObjectList = nil;

  threadvar
  /// each thread can access to its own TSynLogFile
  // - TSynLogFile instance is SynLogFile[SynLogFileIndex[TSynLogFamily.Ident]-1]
    SynLogFileIndex: TSynLogFileIndex;
  /// used internaly by function GetHandleExceptionSynLog

  CurrentHandleExceptionSynLog: TSynLog;
  { ************ some fast UTF-8 / Unicode / Ansi conversion routines }

2) In SynCommons.pas, Initialization section replace Assert(SizeOf(TSynTableData) = 16); with

 {$ifdef CPU64}
         Assert(SizeOf(TSynTableData) = 24);
 {$else}
        Assert(SizeOf(TSynTableData) = 16);
{$endif}

3) In SynCommons.pas and SynGDIPlus.pas
Remove packed from every instance of 64-bit compilation, for example do as follows:

TVarData {$ifdef CPU64} record {$else} packed record {$endif}

This will make it compile (AND run well) in 64-bit.

Marvel

Board footer

Powered by FluxBB