RAVE在处理中文时没有正确判断中文为双字节,所以在编码时出了问题!现在把修改后的源代码贴出,供感兴趣的同志们参考:{*************************************************************************} { Rave Reports version 5.1 } { Copyright (c), 1995-2002, Nevrona Designs, all rights reserved } {*************************************************************************} unit RpRenderPDF; functionTRvRenderPDF.IsCJKFont:boolean; begin caseConvertCharset((Converter.Font.Charset))of Windows.SHIFTJIS_CHARSET,//Japan Windows.HANGEUL_CHARSET,//Korea Windows.GB2312_CHARSET,//SimplifiedChinese(People'sRepublicofChina) Windows.CHINESEBIG5_CHARSET,//TraditionalChinese(Taiwan) Windows.JOHAB_CHARSET: begin Result:=true; end else begin Result:=false; end end;{case} end; procedureTRPPDFFontDescendant.InitData; //!!!CJK procedurePrintWidths; var i1:integer; begin RvRenderPDF.PrintLn('/W[');ifDescriptor.Panose.bProportion=PAN_PROP_MONOSPACEDthen begin ifCharSet=SHIFTJIS_CHARSET{Japanese}then begin RvRenderPDF.PrintLnF('%d[',[231]); end elseifCharSet=HANGEUL_CHARSET{Korea}then begin RvRenderPDF.PrintLnF('%d[',[8094]); end elseifCharSet=CHINESEBIG5_CHARSET{TraditionalChinese(Taiwan)}then begin RvRenderPDF.PrintLnF('%d[',[13648]); end else begin//SCYANGYU RvRenderPDF.PrintLnF('%d[',[814]);//SimplifiedChinese(People'sRepublicofChina) end; end else begin RvRenderPDF.PrintLnF('%d[',[1]); end;{else}i1:=32; whilei1<=126dobegin RvRenderPDF.Print(IntToStr(FontWidths[i1])+''); ifi1mod10=9thenbegin RvRenderPDF.PrintLn; end; Inc(i1); end;//while RvRenderPDF.PrintLn(']');RvRenderPDF.PrintLn(']');end;begin{InitData} RvRenderPDF.ActiveStream:=DataStream; RvRenderPDF.PrintLnF('%d0obj',[GetID]); RvRenderPDF.PrintLn('<<'); RvRenderPDF.PrintLn('/Type/Font'); RvRenderPDF.PrintLn('/Subtype/CIDFontType2'); RvRenderPDF.PrintLnF('/BaseFont/%s',[PDFFontName]); RvRenderPDF.PrintLnF('/FontDescriptor%d0R',[Descriptor.GetID]); RvRenderPDF.PrintLnF('/WinCharSet/%d',[CharSet]);//!!!CJK RvRenderPDF.PrintLnF('/CIDSystemInfo<>',[Registry,Ordering,Supplement]); RvRenderPDF.PrintLnF('/DW%d',[MaxCharWidth]);PrintWidths;RvRenderPDF.PrintLn('>>'); RvRenderPDF.PrintLn('endobj'); RvRenderPDF.PrintLn; RvRenderPDF.ActiveStream.Position:=0; end;{InitData} procedureTRPPDFFontComposite.SetFontData; type TABCArray=array[0..255]ofTABC;var OutlineTextMetric:POutlineTextMetric; Panose:TPanose; nSize:longint; lpABC:TABCArray; procedureSetWidths;var i1:integer;begin i1:=0; whilei1FontWidths[i1+FirstChar]:=lpABC[i1].abcA+word(lpABC[i1].abcB)+lpABC[i1].abcC; Inc(i1); end;//while end;begin ifRvRenderPDF.IsCJKFontthen begin withRvRenderPDF.FontBitmap.Canvasdo begin Font.Name:=FontName; Font.Style:=FontStyles; Font.Charset:=FontCharset; end;{with}nSize:=GetOutlineTextMetrics((RvRenderPDF.FontBitmap.Canvas.Handle), sizeof(OutlineTextMetric), nil); GetMem(OutlineTextMetric,nSize); try ifGetOutlineTextMetrics((RvRenderPDF.FontBitmap.Canvas.Handle), nSize, OutlineTextMetric)>0then begin Panose:=OutlineTextMetric.otmPanoseNumber; ifPanose.bProportion=PAN_PROP_MONOSPACEDthen begin ifFontCharSet=SHIFTJIS_CHARSETthen//Japan begin CompositeFontEncoding:='90ms-RKSJ-H'; end elseifFontCharSet=HANGEUL_CHARSETthen//Korea begin CompositeFontEncoding:='KSCms-UHC-HW-H'; end elseifFontCharSet=CHINESEBIG5_CHARSETthen//TraditionalChinese(Taiwan) begin CompositeFontEncoding:='ETenms-B5-H'; end else Begin//SCYANGYU CompositeFontEncoding:='GBK-EUC-H';//cc_simplified_chinese End;{else} end else begin ifFontCharSet=SHIFTJIS_CHARSETthen//Japan begin CompositeFontEncoding:='90msp-RKSJ-H'; end elseifFontCharSet=HANGEUL_CHARSETthen//Korea begin CompositeFontEncoding:='KSCms-UHC-H'; end elseifFontCharSet=CHINESEBIG5_CHARSETthen//TraditionalChinese(Taiwan) begin CompositeFontEncoding:='CNS-EUC-H'; end else begin//SCYANGYU CompositeFontEncoding:='GBpc-EUC-H';//cc_simplified_chinese end;{else} end;{else} Descriptor.PDFFontName:=PDFFontName; Descriptor.Setvalues(OutlineTextMetric,FontWidths[32]); Descendant.PDFFontName:=PDFFontName; Descendant.Descriptor:=Descriptor; Descendant.Registry:='Adobe'; ifFontCharSet=SHIFTJIS_CHARSETthen//Japan begin Descendant.Ordering:='Japan1'; end elseifFontCharSet=HANGEUL_CHARSETthen//Korea begin Descendant.Ordering:='Korea1'; end elseifFontCharSet=CHINESEBIG5_CHARSETthen//TraditionalChinese(Taiwan) begin Descendant.Ordering:='CNS1'; end else begin//SCYANGYU Descendant.Ordering:='GB1';//cc_simplified_chinese end;{else} ifFontCharSet=SHIFTJIS_CHARSETthen//Japan begin Descendant.Supplement:=2; end elseifFontCharSet=HANGEUL_CHARSETthen//Korea begin Descendant.Supplement:=1; end elseifFontCharSet=CHINESEBIG5_CHARSETthen//TraditionalChinese(Taiwan) begin Descendant.Supplement:=1; end else begin//SCYANGYU Descendant.Supplement:=0;//cc_simplified_chinese end;{else} Descendant.MaxCharWidth:=OutlineTextMetric.otmTextMetrics.tmMaxCharWidth; Descendant.AveCharWidth:=OutlineTextMetric.otmTextMetrics.tmAveCharWidth; Descendant.Charset:=RvRenderPDF.FontBitmap.Canvas.Font.Charset;FirstChar:=cardinal(OutlineTextMetric.otmTextMetrics.tmFirstChar); LastChar:=cardinal(OutlineTextMetric.otmTextMetrics.tmLastChar); ifGetCharABCWidths((RvRenderPDF.FontBitmap.Canvas.Handle), FirstChar, LastChar, lpABC)then begin SetWidths; Descendant.FirstChar:=FirstChar; Descendant.LastChar:=LastChar; Descendant.FontWidths:=FontWidths; end;{if} end;{if} finally FreeMem(OutlineTextMetric,nSize); end;{tryf} end; end;
{ Rave Reports version 5.1 }
{ Copyright (c), 1995-2002, Nevrona Designs, all rights reserved }
{*************************************************************************}
unit RpRenderPDF;
functionTRvRenderPDF.IsCJKFont:boolean;
begin
caseConvertCharset((Converter.Font.Charset))of
Windows.SHIFTJIS_CHARSET,//Japan
Windows.HANGEUL_CHARSET,//Korea
Windows.GB2312_CHARSET,//SimplifiedChinese(People'sRepublicofChina)
Windows.CHINESEBIG5_CHARSET,//TraditionalChinese(Taiwan)
Windows.JOHAB_CHARSET:
begin
Result:=true;
end
else
begin
Result:=false;
end
end;{case}
end;
procedureTRPPDFFontDescendant.InitData;
//!!!CJK
procedurePrintWidths;
var
i1:integer;
begin
RvRenderPDF.PrintLn('/W[');ifDescriptor.Panose.bProportion=PAN_PROP_MONOSPACEDthen
begin
ifCharSet=SHIFTJIS_CHARSET{Japanese}then
begin
RvRenderPDF.PrintLnF('%d[',[231]);
end
elseifCharSet=HANGEUL_CHARSET{Korea}then
begin
RvRenderPDF.PrintLnF('%d[',[8094]);
end
elseifCharSet=CHINESEBIG5_CHARSET{TraditionalChinese(Taiwan)}then
begin
RvRenderPDF.PrintLnF('%d[',[13648]);
end
else
begin//SCYANGYU
RvRenderPDF.PrintLnF('%d[',[814]);//SimplifiedChinese(People'sRepublicofChina)
end;
end
else
begin
RvRenderPDF.PrintLnF('%d[',[1]);
end;{else}i1:=32;
whilei1<=126dobegin
RvRenderPDF.Print(IntToStr(FontWidths[i1])+'');
ifi1mod10=9thenbegin
RvRenderPDF.PrintLn;
end;
Inc(i1);
end;//while
RvRenderPDF.PrintLn(']');RvRenderPDF.PrintLn(']');end;begin{InitData}
RvRenderPDF.ActiveStream:=DataStream;
RvRenderPDF.PrintLnF('%d0obj',[GetID]);
RvRenderPDF.PrintLn('<<');
RvRenderPDF.PrintLn('/Type/Font');
RvRenderPDF.PrintLn('/Subtype/CIDFontType2');
RvRenderPDF.PrintLnF('/BaseFont/%s',[PDFFontName]);
RvRenderPDF.PrintLnF('/FontDescriptor%d0R',[Descriptor.GetID]);
RvRenderPDF.PrintLnF('/WinCharSet/%d',[CharSet]);//!!!CJK
RvRenderPDF.PrintLnF('/CIDSystemInfo<>',[Registry,Ordering,Supplement]);
RvRenderPDF.PrintLnF('/DW%d',[MaxCharWidth]);PrintWidths;RvRenderPDF.PrintLn('>>');
RvRenderPDF.PrintLn('endobj');
RvRenderPDF.PrintLn;
RvRenderPDF.ActiveStream.Position:=0;
end;{InitData}
procedureTRPPDFFontComposite.SetFontData;
type
TABCArray=array[0..255]ofTABC;var
OutlineTextMetric:POutlineTextMetric;
Panose:TPanose;
nSize:longint;
lpABC:TABCArray;
procedureSetWidths;var
i1:integer;begin
i1:=0;
whilei1FontWidths[i1+FirstChar]:=lpABC[i1].abcA+word(lpABC[i1].abcB)+lpABC[i1].abcC;
Inc(i1);
end;//while
end;begin
ifRvRenderPDF.IsCJKFontthen
begin
withRvRenderPDF.FontBitmap.Canvasdo
begin
Font.Name:=FontName;
Font.Style:=FontStyles;
Font.Charset:=FontCharset;
end;{with}nSize:=GetOutlineTextMetrics((RvRenderPDF.FontBitmap.Canvas.Handle),
sizeof(OutlineTextMetric),
nil);
GetMem(OutlineTextMetric,nSize);
try
ifGetOutlineTextMetrics((RvRenderPDF.FontBitmap.Canvas.Handle),
nSize,
OutlineTextMetric)>0then
begin
Panose:=OutlineTextMetric.otmPanoseNumber;
ifPanose.bProportion=PAN_PROP_MONOSPACEDthen
begin
ifFontCharSet=SHIFTJIS_CHARSETthen//Japan
begin
CompositeFontEncoding:='90ms-RKSJ-H';
end
elseifFontCharSet=HANGEUL_CHARSETthen//Korea
begin
CompositeFontEncoding:='KSCms-UHC-HW-H';
end
elseifFontCharSet=CHINESEBIG5_CHARSETthen//TraditionalChinese(Taiwan)
begin
CompositeFontEncoding:='ETenms-B5-H';
end
else
Begin//SCYANGYU
CompositeFontEncoding:='GBK-EUC-H';//cc_simplified_chinese
End;{else}
end
else
begin
ifFontCharSet=SHIFTJIS_CHARSETthen//Japan
begin
CompositeFontEncoding:='90msp-RKSJ-H';
end
elseifFontCharSet=HANGEUL_CHARSETthen//Korea
begin
CompositeFontEncoding:='KSCms-UHC-H';
end
elseifFontCharSet=CHINESEBIG5_CHARSETthen//TraditionalChinese(Taiwan)
begin
CompositeFontEncoding:='CNS-EUC-H';
end
else
begin//SCYANGYU
CompositeFontEncoding:='GBpc-EUC-H';//cc_simplified_chinese
end;{else}
end;{else}
Descriptor.PDFFontName:=PDFFontName;
Descriptor.Setvalues(OutlineTextMetric,FontWidths[32]);
Descendant.PDFFontName:=PDFFontName;
Descendant.Descriptor:=Descriptor;
Descendant.Registry:='Adobe';
ifFontCharSet=SHIFTJIS_CHARSETthen//Japan
begin
Descendant.Ordering:='Japan1';
end
elseifFontCharSet=HANGEUL_CHARSETthen//Korea
begin
Descendant.Ordering:='Korea1';
end
elseifFontCharSet=CHINESEBIG5_CHARSETthen//TraditionalChinese(Taiwan)
begin
Descendant.Ordering:='CNS1';
end
else
begin//SCYANGYU
Descendant.Ordering:='GB1';//cc_simplified_chinese
end;{else}
ifFontCharSet=SHIFTJIS_CHARSETthen//Japan
begin
Descendant.Supplement:=2;
end
elseifFontCharSet=HANGEUL_CHARSETthen//Korea
begin
Descendant.Supplement:=1;
end
elseifFontCharSet=CHINESEBIG5_CHARSETthen//TraditionalChinese(Taiwan)
begin
Descendant.Supplement:=1;
end
else
begin//SCYANGYU
Descendant.Supplement:=0;//cc_simplified_chinese
end;{else}
Descendant.MaxCharWidth:=OutlineTextMetric.otmTextMetrics.tmMaxCharWidth;
Descendant.AveCharWidth:=OutlineTextMetric.otmTextMetrics.tmAveCharWidth;
Descendant.Charset:=RvRenderPDF.FontBitmap.Canvas.Font.Charset;FirstChar:=cardinal(OutlineTextMetric.otmTextMetrics.tmFirstChar);
LastChar:=cardinal(OutlineTextMetric.otmTextMetrics.tmLastChar);
ifGetCharABCWidths((RvRenderPDF.FontBitmap.Canvas.Handle),
FirstChar,
LastChar,
lpABC)then
begin
SetWidths;
Descendant.FirstChar:=FirstChar;
Descendant.LastChar:=LastChar;
Descendant.FontWidths:=FontWidths;
end;{if}
end;{if}
finally
FreeMem(OutlineTextMetric,nSize);
end;{tryf}
end;
end;
安装Acrobat完整版后控制面板的打印机设置中出现一个Acrobat PDFWriter打印机,
在rave里把打印机设成Acrobat PDFWriter打印机,打印时会保存一个PDF文件,
这个文件的中文就不是乱码了。
rave7 的怎么改?