QuickReport 4.04 版用後有些疑問 |
尚未結案
|
nick167
中階會員 發表:86 回覆:133 積分:53 註冊:2003-02-12 發送簡訊給我 |
http://www.qusoft.com/ -> QuickReport4.04版用後有一個問題 ?就是轉PDF
中文出現亂碼? 待高手提供一點意見
QRRTFFilter:轉rtf後word(可開啟)
QRPDFFilter:轉pdf後中文出現亂碼(不知有解嗎 ? )
與delphi7 RvRenderPDF(也是轉中文出現亂碼)
不知有解嗎?
QRExcelFilter:轉excel(成功 )
QRWMFFilter,QRXMLSFilter,QRHTMLFilter (成功)
QuickReport4.04 有增加很多元件,目前普遍轉用 word,excel,pdf,HTM 只有pdf有待中文解決,如果成功對QuickReport 4.04 應是完美
不知研究過 4.04版 高手提供一點意見,解決 pdf 中文問題
謝謝
|
hahalin
版主 發表:295 回覆:1698 積分:823 註冊:2002-04-14 發送簡訊給我 |
|
crispin2k
初階會員 發表:7 回覆:42 積分:33 註冊:2002-07-24 發送簡訊給我 |
引言: http://www.qusoft.com/ -> QuickReport4.04版用後有一個問題 ?就是轉PDF 中文出現亂碼? 待高手提供一點意見 QRRTFFilter:轉rtf後word(可開啟) QRPDFFilter:轉pdf後中文出現亂碼(不知有解嗎 ? ) 與delphi7 RvRenderPDF(也是轉中文出現亂碼) 不知有解嗎? QRExcelFilter:轉excel(成功 ) QRWMFFilter,QRXMLSFilter,QRHTMLFilter (成功) QuickReport4.04 有增加很多元件,目前普遍轉用 word,excel,pdf,HTM 只有pdf有待中文解決,如果成功對QuickReport 4.04 應是完美 不知研究過 4.04版 高手提供一點意見,解決 pdf 中文問題 謝謝根據Acrobat的PDF文件規格,匯出中文PDF檔的規格與英文PDF規格的字型描述的方法不同,且QR 4.04採用的匯出PDF元件係採用Gnostice公司的QRPDFFilter,該元件會出的PDF文件並未參考字型檔的規格產生PDF文件,因此產生的文件與ACROBAT產生的文件差異頗多,但顯示的效果差異並不大。 要讓QR 4.04匯出的PDF支援中文並不是下載亞洲字型套件就可以解決的,你必須修正該元件中文字型的描述才可以,否則是白費力氣的。中文字型的描述請使用記事本開啟.pdf文件觀看具有中文pdf文件即可看出端倪,要注意的是描述中文字型的有兩段。 |
nick167
中階會員 發表:86 回覆:133 積分:53 註冊:2003-02-12 發送簡訊給我 |
crispin2k您好 根據Acrobat的PDF文件規格,匯出中文PDF檔的規格與英文PDF規格的字型描述的方法不同,且QR 4.04採用的匯出PDF元件係採用Gnostice公司的QRPDFFilter,該元件會出的PDF文件並未參考字型檔的規格產生PDF文件,因此產生的文件與ACROBAT產生的文件差異頗多,但顯示的效果差異並不大。
要讓QR 4.04匯出的PDF支援中文並不是下載亞洲字型套件就可以解決的,你必須修正該元件中文字型的描述才可以,否則是白費力氣的。中文字型的描述請使用記事本開啟.pdf文件觀看具有中文pdf文件即可看出端倪,要注意的是描述中文字型的有兩段。 我有用記事本開啟可看到中文,是否指 /Font <<
/F00 28 0 R
>>
找到 ...\delphi7\Quickrpt\qrpdffilt.pas
可是不知該改那行 ? 對於修改元件,我尚未有此功力可否幫幫我? 另外有時轉. rtf 到word 會出現 不知為何? 我用win2000 (FA32格式,登入administrator) 謝謝您
|
nick167
中階會員 發表:86 回覆:133 積分:53 註冊:2003-02-12 發送簡訊給我 |
|
TAN2004
一般會員 發表:3 回覆:4 積分:1 註冊:2004-10-06 發送簡訊給我 |
請試試以下代碼方法:
procedure TForm1.SpeedButton2Click(Sender: TObject);
var
aPDF : TQRPDFDocumentfilter;
begin
aPDF := TQRPDFDocumentfilter.Create('fish new filter.pdf');
aPDF.CompressionOn := true;
aPDF.FontHandling := fhNoEmbedding; // also fhSubstitute, fhAutoEmbed,
fhNoEmbedding
repform.QuickRep1.ExportToFilter(aPDF);
aPDF.free;
end; 如不行.... 有一方法一定行:
用 QRRichText 並設定 Font.Charset = 'CHINESEBIG5_CHARSET'
|
nick167
中階會員 發表:86 回覆:133 積分:53 註冊:2003-02-12 發送簡訊給我 |
謝謝 TAN2004 熱情回覆真的感謝您
aPDF.FontHandling := fhNoEmbedding;
[Error] DataSetup_Print.pas(69): Undeclared identifier: 'FontHandling'
fhNoEmbedding
設定 Font.Charset = 'CHINESEBIG5_CHARSET' 也沒用 看 QRPDFFilt 有
procedure TQRPDFDocumentFilter.TextOut(X, Y : extended; Font : TFont; BGColor : TColor;
Alignment : TAlignment; Text : string);
var
xp, yp, textsize :integer;
parentrep : TQuickrep;
tmap : TBitmap;
begin
tmap := TBitmap.Create;
try
// make a pdf textitem
fpdfitem.ItemType := IT_TEXT;
parentrep := tquickrep( self.owner );
// text pos is in 1/10 mm
// map the same as graphic elements
xp := parentrep.QRPrinter.XPos( X );
yp := parentrep.QRPrinter.YPos( Y );
//Alignment - recalculate positions
case alignment of
taLeftJustify : ;// do nothing
taRightJustify :
begin
// the xpos is the right of the text pos
tmap.canvas.Font.Assign( font );
textsize := tmap.canvas.textwidth( text );
xp := xp - textsize;
end;
taCenter:
begin
// the xpos is the center of the text pos
tmap.canvas.Font.Assign( font );
textsize := tmap.canvas.textwidth( text );
xp := xp - (textsize div 2);
end;
end;
fpdfitem.Xpos := xp * PointsperpixelX;
fpdfitem.Ypos := yp * PointsperpixelY + font.size;
fpdfitem.FText := allocmem( length(text)+1);
strpcopy( fpdfitem.FText,Text );
fpdfitem.Fontname := allocmem( length(Font.Name)+1);
strpcopy( fpdfitem.Fontname,Font.Name );
fpdfitem.fontsize := Font.Size;
if font.color < 0 then font.color := font.color and $00FFFFFF;
fpdfitem.rgbfcolor.blue := getBvalue(ColorToRGB(font.color));
fpdfitem.rgbfcolor.red := getRvalue(ColorToRGB(font.color));
fpdfitem.rgbfcolor.green := getGvalue(ColorToRGB(font.color));
fpdfitem.fbold := fsBold in font.Style;
fpdfitem.fitalic := fsItalic in font.Style;
AddPDFItem( fpdfitem );
finally
tmap.free;
end;
end; 我功力尚淺不會使用 TQRPDFDocumentFilter.TextOut(.......
不知裡的FONT是否有可改善PDF轉中文亂碼問題?
aPDFFilt.TextOut(0,100,CHINESEBIG5_CHARSET,clBlack.....); 不會用 或者會是下列 Ascii碼轉換問題 需要像crispin2k 說 改某部分貼上懇請高手指點
procedure Hexit( var c1 : char; var c2 : char; b : byte );
var
b1, b2 : byte;
begin
b1 := b shr 4;
b2 := b and $0F;
if b1 < 10 then
c1 := chr( b1 + ORD0 )
else
c1 := chr( (b1-10) + ORDA );
if b2 < 10 then
c2 := chr( b2 + ORD0 )
else
c2 := chr( (b2-10) + ORDA );
end; procedure AsciiHexToString(Source: TStream; var outstr : string);
const
REC_SIZE = 2048;
CRLF = chr($0D) + chr($0A);
var
C1, C2 : char;
cc : array[0..REC_SIZE] of byte;
bytesin : longint;
lineout : string;
i : integer;
begin
source.Seek( 0, 0 );
bytesin := Source.Read( cc, REC_SIZE );
lineout := '';
while( bytesin > 0 ) do
begin
for i := 0 to bytesin-1 do
begin
Hexit( C1, C2, cc[i] );
lineout := lineout +C1+C2;
end;
outstr := outstr + lineout;
lineout := '';
bytesin := Source.Read( cc, REC_SIZE );
end;
end; procedure AsciiHex(Source: TStream; imgfilename : string);
const
REC_SIZE = 2048;
CRLF = chr($0D) + chr($0A);
var
C1, C2 : char;
cc : array[0..REC_SIZE] of byte;
bytesin : longint;
lineout : string;
i : integer;
imgfile : TextFile;
begin
assignfile( imgfile, imgfilename);
rewrite( imgfile );
source.Seek( 0, 0 );
bytesin := Source.Read( cc, REC_SIZE );
lineout := '';
while( bytesin > 0 ) do
begin
for i := 0 to bytesin-1 do
begin
Hexit( C1, C2, cc[i] );
lineout := lineout +C1+C2;
end;
writeln( imgfile, lineout );
lineout := '';
bytesin := Source.Read( cc, REC_SIZE );
end;
closefile( imgfile);
end; // Standard run-length encoding code - translated from C
procedure RunLength(Source, Target: TStream);
var
Buffer, C, LastOut, LastBuf: String;
LastCnt: Integer;
begin C := ' ';
Buffer := '';
LastOut := '';
LastCnt := 0;
Source.Position := 0;
Target.Position := 0; while Source.Position < Source.Size do
begin
Source.Read(C[1], 1);
if (C = LastOut) and (LastCnt <= 127) then
begin
if Length(LastBuf) > 0 then
begin
Buffer := Buffer + CHR(Length(LastBuf) - 1) + LastBuf;
LastBuf := '';
end;
Inc(LastCnt);
end
else
begin
if LastCnt = 0 then
begin
end
else
if LastCnt > 1 then
begin
Buffer := Buffer + CHR(257 - LastCnt) + LastOut;
end
else
begin
LastBuf := LastBuf + LastOut;
if Length(LastBuf) >= 128 then
begin
Buffer := Buffer + CHR(Length(LastBuf) - 1) + LastBuf;
LastBuf := '';
end;
end;
LastCnt := 1;
LastOut := C;
end; if Length(Buffer) > 0 then
begin
Target.Write(Buffer[1], Length(Buffer));
end;
Buffer := ''; end; if Length(LastBuf) > 0 then begin
Buffer := Buffer + CHR(Length(LastBuf) - 1) + LastBuf;
end; if LastCnt = 1 then begin
Buffer := Buffer + CHR(0) + LastOut;
end; if LastCnt > 1 then begin
Buffer := Buffer + CHR(257 - LastCnt) + LastOut;
end; Buffer := Buffer + CHR(128) + '>';
Target.Write(Buffer[1], Length(Buffer)); Source.Position := 0;
Target.Position := 0;
end;
|
nick167
中階會員 發表:86 回覆:133 積分:53 註冊:2003-02-12 發送簡訊給我 |
|
a07272
一般會員 發表:2 回覆:8 積分:2 註冊:2002-03-12 發送簡訊給我 |
PDF 的問題還在改啦,不過轉WORD問題改好囉.....^_^
請修改 QRExport 中的 TQRRTFExportFilter.TextOut 為下列就沒問題啦 procedure TQRRTFExportFilter.TextOut(X, Y : Extended; Font : TFont; BGColor : TColor; Alignment : TAlignment; Text : string);
var
aQRRTFItem: TQRRTFItem;
function RTFSafeText(const str: string): string;
var ll: integer;
vStr : WideString; //Modify By Allen 2004/12/19
begin
result := '';
vStr := Str; for ll := 1 to length(vstr) do begin
if (vstr[ll] = '\') or (vstr[ll] = '}') or (vstr[ll] = '{') then
result := result '\';
result := result vstr[ll];
end;
end;
begin
... 如果有問題,要跟我說喔....@_@
|
cosmonaut
一般會員 發表:0 回覆:1 積分:0 註冊:2005-12-04 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |