1
function ExportMapToFile(pActiveView: IActiveView; filetypes: FileType; fileName: string): Boolean;
2
var
3
pExport: IExport;
4
iOutputResolution: SmallInt;
5
iScreenResolution: SmallInt;
6
exportRect: tagRECT;
7
pPixelBounds: IEnvelope;
8
hdc: Integer;
9
10
pExportPdf: IExportPDF;
11
begin
12
case filetypes of
13
ftBmp: pExport := CoExportBMP.Create as IExport;
14
ftGif: pExport := CoExportGIF.Create as IExport;
15
ftJpg: pExport := CoExportJPEG.Create as IExport;
16
ftSvg: pExport := CoExportSVG.Create as IExport;
17
ftEps: pExport := CoExportPS.Create as IExport;
18
ftPng: pExport := CoExportPNG.Create as IExport;
19
ftEmf: pExport := CoExportEMF.Create as IExport;
20
ftAI: pExport := CoExportAI.Create as IExport;
21
ftTif: pExport := CoExportTiff.Create as IExport;
22
ftPdf:
23
begin
24
pExport := CoExportPdf.Create as IExport;
25
pExportPdf := pExport as IExportPDF;
26
pExportPdf.EmbedFonts := True;
27
pExportPdf.ImageCompression := esriExportImageCompressionLZW;
28
pExportPdf.Compressed := True;
29
end;
30
end;
31
32
if Length(fileName) = 0 then
33
begin
34
Result := False;
35
Exit;
36
end;
37
38
pExport.ExportFileName := fileName;
39
iScreenResolution := 96;
40
iOutputResolution := 300;
41
42
pPixelBounds := CoEnvelope.Create as IEnvelope;
43
exportRect.left := 0;
44
exportRect.top := 0;
45
exportRect.right := pActiveView.ExportFrame.right * Round(iOutputResolution / iScreenResolution);
46
exportRect.bottom := pActiveView.ExportFrame.bottom * Round(iOutputResolution / iScreenResolution);
47
48
pPixelBounds.PutCoords(exportRect.left, exportRect.top, exportRect.right, exportRect.bottom);
49
50
pExport.PixelBounds := pPixelBounds;
51
52
hdc := pExport.StartExporting;
53
pActiveView.Output(hdc, Round(pExport.Resolution), exportRect, pActiveView.Extent, nil);
54
pExport.FinishExporting;
55
pExport.Cleanup;
56
Result := True;
57
end;

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57
