1

In a Delphi 10.4.2 Win32 Console application, i try to export an SVG file to PDF using the TMS libraries and following the example here:

Edit: (The page at: https://www.tmssoftware.com/site/blog.asp was still available a few hours ago, but now it seems it shows another page)

program TestSVGToPDF;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  AdvPDFLib,
  System.Types,
  System.SysUtils;

procedure ExportSVGToPDF(const ASVG, APDF: string);
// https://www.tmssoftware.com/site/blog.asp
var
  p: AdvPDFLib.TAdvPDFLib;
begin
  p := AdvPDFLib.TAdvPDFLib.Create;
  try
    p.BeginDocument(APDF);
    p.NewPage;
    p.Graphics.DrawImageFromFile(ASVG, System.Types.RectF(50, 50, p.PageWidth - 50, 500));
    p.EndDocument(True);
  finally
    p.Free;
  end;
end;

begin
  try
    ExportSVGToPDF('C:\DELPHI\_test\TestSVGToPDF\flower.svg', 'C:\DELPHI\_test\TestSVGToPDF\flower.pdf');
    // Compiler error: [dcc32 Fatal Error] AdvTypes.pas(95): F2613 Unit 'Graphics' not found.
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

Unfortunately, I get this Compiler error: [dcc32 Fatal Error] AdvTypes.pas(95): F2613 Unit 'Graphics' not found.

This is the SVG file used for my test:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE 
svg SYSTEM "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%"
     height="100%"
     viewBox="0 0 600 590"
     version="1.1"
     xmlns="http://www.w3.org/2000/svg">
<g id="#f285b9ff">
<path fill="#f285b9"
      opacity="1.00"
      d="M 210.63 0.00 L 218.25 0.00 C 233.21 0.64 248.13 4.96 260.62 13.34 C 274.42 22.45 285.03 35.71 292.85 50.15 C 302.26 67.62 308.11 86.78 312.08 106.16 C 315.42 87.00 321.01 67.94 331.11 51.19 C 340.36 35.69 354.23 22.67 371.11 15.93 C 391.48 7.61 414.34 8.12 435.53 12.75 C 461.88 18.69 486.69 30.27 509.49 44.58 C 526.79 55.68 543.17 68.75 555.72 85.18 C 565.00 97.31 572.02 111.58 573.77 126.90 C 575.44 140.73 572.45 154.88 566.28 167.30 C 554.64 190.36 534.84 208.12 513.89 222.64 C 531.93 221.56 550.86 223.91 566.66 233.22 C 579.00 240.39 588.37 252.10 593.48 265.36 C 597.81 276.24 599.48 287.96 600.00 299.59 L 600.00 305.63 C 599.56 327.22 594.69 348.44 588.14 368.93 C 580.98 391.46 572.65 413.88 560.00 433.98 C 551.53 447.14 540.60 459.40 526.26 466.22 C 514.12 472.12 500.07 473.19 486.91 470.70 C 470.08 467.56 454.49 459.86 440.02 450.95 C 425.65 441.91 412.02 431.67 399.31 420.42 C 408.17 436.04 414.92 453.07 417.60 470.89 C 420.21 488.06 418.29 506.10 410.89 521.91 C 402.96 539.14 389.29 553.20 373.59 563.59 C 347.83 580.46 317.07 589.14 286.40 590.00 L 281.69 590.00 C 260.67 589.36 239.73 584.83 220.47 576.36 C 205.14 569.54 190.82 560.02 179.60 547.47 C 167.97 534.59 160.18 518.22 158.01 500.98 C 155.16 479.41 160.23 457.52 168.85 437.79 C 149.46 450.95 126.78 460.74 103.00 460.74 C 83.67 460.87 64.66 453.47 49.94 441.06 C 34.48 428.18 23.24 410.84 15.59 392.36 C 9.15 376.97 5.62 360.57 2.87 344.18 C 1.36 335.24 0.63 326.21 0.00 317.18 L 0.00 307.56 C 0.56 287.21 5.38 265.82 19.28 250.27 C 31.35 236.52 49.00 228.98 66.73 225.87 C 87.19 222.28 108.17 223.20 128.68 225.90 C 111.22 218.43 94.50 208.43 81.28 194.64 C 68.87 181.82 60.51 164.83 59.45 146.90 C 57.95 123.79 66.81 101.28 79.25 82.20 C 99.77 50.92 129.93 26.25 164.19 11.38 C 178.88 5.01 194.60 0.86 210.63 0.00 M 308.48 190.70 C 283.15 192.78 258.68 204.75 241.89 223.90 C 228.02 239.55 219.60 260.04 219.02 280.99 C 218.30 300.33 224.16 319.78 235.26 335.61 C 248.25 354.33 268.10 367.98 290.03 373.97 C 314.13 380.63 340.69 378.25 363.08 367.04 C 383.85 356.82 400.92 338.98 409.53 317.43 C 417.55 297.65 418.12 274.98 411.13 254.82 C 404.47 235.36 390.98 218.47 373.86 207.15 C 354.79 194.39 331.29 188.69 308.48 190.70 Z" />
</g>
<g id="#ffffffff">
<path fill="#ffffff"
      opacity="1.00"
      d="M 308.48 190.70 C 331.29 188.69 354.79 194.39 373.86 207.15 C 390.98 218.47 404.47 235.36 411.13 254.82 C 418.12 274.98 417.55 297.65 409.53 317.43 C 400.92 338.98 383.85 356.82 363.08 367.04 C 340.69 378.25 314.13 380.63 290.03 373.97 C 268.10 367.98 248.25 354.33 235.26 335.61 C 224.16 319.78 218.30 300.33 219.02 280.99 C 219.60 260.04 228.02 239.55 241.89 223.90 C 258.68 204.75 283.15 192.78 308.48 190.70 Z" />
</g>
</svg>
user1580348
  • 5,721
  • 4
  • 43
  • 105

1 Answers1

2

Adding Vcl and Vcl.Imaging to the "Unit Scope Names" in the Project Options solves the problem.

Now the PDF Export works.

user1580348
  • 5,721
  • 4
  • 43
  • 105