通过代码把word文档转换为html页面文件,字体和格式基本没变化(只是少了分页信息)。但是用浏览器打印或打印预览该文档时,字体却会变小,使打印结果比原始word出现一点差异,怎样解决呢?

解决方案 »

  1.   

    type
      TFileTimeType = (fttCreation, fttLastAccess, fttLastWrite);
      //分别对应文件创建时间,访问时间,修改时间
    function GetFileDateTime(const FileName: string; FileTimeType: TFileTimeType): TDateTime;
    var
      Handle: THandle;
      FindData: TWin32FindData;
      LocalFileTime: TFileTime;
      DosDateTime: Integer;
    begin
      Handle := FindFirstFile(PChar(FileName), FindData);
      if Handle <> INVALID_HANDLE_VALUE then
      begin
        Windows.FindClose(Handle);
        if (FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) = 0 then
        begin
          case FileTimeType of
          fttCreation:
            FileTimeToLocalFileTime(FindData.ftCreationTime, LocalFileTime);
          fttLastAccess:
            FileTimeToLocalFileTime(FindData.ftLastAccessTime, LocalFileTime);
          fttLastWrite:
            FileTimeToLocalFileTime(FindData.ftLastWriteTime, LocalFileTime);
          end;
          if FileTimeToDosDateTime(LocalFileTime, LongRec(DosDateTime).Hi,
            LongRec(DosDateTime).Lo) then
          begin
            Result := FileDateToDateTime(DosDateTime);
            Exit;
          end;
        end;
      end;
      Result := -1;
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
       if self.OpenDialog1.Execute then
       ShowMessage(DateTimeToStr(GetFileDateTime(self.OpenDialog1.FileName,fttLastWrite)));
       ShowMessage(DateTimeToStr(GetFileDateTime(self.OpenDialog1.FileName,fttLastAccess)));end;
      

  2.   

    uses   CommCtrl;   
        
      procedure   TForm1.ListView1CustomDrawItem(Sender:   TCustomListView;   
          Item:   TListItem;   State:   TCustomDrawState;   var   DefaultDraw:   Boolean);   
      var   
          r:   TRect;   
          i:   Integer;   
      begin   
          with   ListView1.Canvas   do   
          if   cdsSelected   in   State   then   begin   
              Brush.Color   :=   clRed;   
              r   :=   Item.DisplayRect(drLabel);   
              //   Item   
              FillRect(r);   
              TextOut(r.Left+2,   r.Top,   Item.Caption);   
              //   SubItem   
              for   i   :=   0   to   Item.SubItems.Count   -   1   do   begin   
                  ListView_GetSubItemRect(ListView1.Handle,   Item.Index,   i+1,   LVIR_LABEL,   @r);   
                  FillRect(r);   
                  TextOut(r.Left+5,   r.Top,   Item.SubItems[i]);   
              end;   
              DefaultDraw   :=   False;   
          end;   
      end;   
      
      

  3.   

    procedure TForm1.FormCreate(Sender: TObject);
    begin
       FBkBmp:=TBitmap.Create;
       FBkBmp.LoadFromFile(''''D:\Shuzi\Resource\图标\背景\Gone Fishing.bmp'''');
       FBKBmp.Transparent:=True;
    end;procedure TForm1.FormDestroy(Sender: TObject);
    begin
      FBkBmp.Free;
    end;procedure TForm1.ListView1CustomDraw(Sender: TCustomListView;
      const ARect: TRect; var DefaultDraw: Boolean);
    begin
      Sender.Brush.Bitmap:=FBkBmp;
      Sender.Canvas.Brush.Bitmap:=FBkBmp;
      Sender.Canvas.FillRect(ARect);
    end;
    procedure TForm1.ListView1CustomDrawItem(Sender: TCustomListView;
      Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
    var
      i,x:integer;
      Images:TCustomImageList;
      R:TRect;
    begin
      with Sender as TListView do
      begin
        if ViewStyle=vsIcon then
          Images:=LargeImages
        else
          Images:=SmallImages;
        if Images<>nil then
         begin
           R:=Item.DisplayRect(drIcon);
           ImageList_DrawEx(Images.Handle, Item.ImageIndex, Canvas.Handle,
                       R.Left+(R.Right-R.Left-Images.Width) div 2,
                       R.Top+(R.Bottom-R.Top-Images.Height) div 2,0, 0,
                       clNone, clNone, ILD_Transparent);     end;
        R:=Item.DisplayRect(drLabel);
        if cdsSelected in State then
         begin
           Canvas.Brush.Style := bsSolid;
           SetTextColor(Canvas.Handle,clWhite);
           SetBkColor(Canvas.Handle,clNavy);
           SetBkMode(Canvas.Handle,Windows.OPAQUE);
           Canvas.TextRect(R,R.Left,R.Top,Item.Caption);
           if RowSelect and (ViewStyle=vsReport) then
           begin
             R:=Item.DisplayRect(drBounds);
             R.Left:=R.Left+Columns[0].Width;
             Canvas.Brush.Color := clNavy;
             Canvas.FillRect(R);
           end;
         end
        else
         begin
          Canvas.Brush.Style:=bsClear;
          SetBkMode(Canvas.Handle,Windows.TRANSPARENT);
          Canvas.TextRect(R,R.Left,R.Top,Item.Caption);
         end;
        if ViewStyle=vsReport then
        begin
          Canvas.Brush.Style:=bsClear;
          SetBkMode(Canvas.Handle,Windows.TRANSPARENT);
          R:=Item.DisplayRect(drBounds);
          X:=R.Left+Columns[0].Width+Item.Indent;
          for i:=0 to Item.SubItems.Count-1 do
           begin
            Canvas.TextRect(R,X,R.Top,Item.SubItems[i]);
            X:=X+Columns[i+1].Width+Item.Indent;
           end;
        end;
        DefaultDraw:=False;
      end;
    end;