Announcement

Collapse
No announcement yet.

How can i change pdf text color?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Feedback How can i change pdf text color?

    How can i change pdf text color? For example: I want to use black background and white text color.

    OP : Win 7 64 , XP Professional SP3
    Delphi 7
    Foxit PDF SDK DLL 3.1.0.1018 (Trial version)

    I can print PDF on Form canvas with this code, but i want to use white text color. (Original document text color is black)

    Code:
    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, ExtCtrls;
    
    type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
      function FPDF_LoadDocument(DosyaAdi: String; Sifre: String = ''): Pointer; stdcall;
      function FPDF_CloseDocument(Dokuman: Pointer): Integer; stdcall;
      procedure FPDF_InitLibrary(Handle: THandle); stdcall;
      procedure FPDF_UnlockDLL(LicenseID: String; UnLockCode: String); stdcall;
      procedure FPDF_DestroyLibrary; stdcall;
      function FPDF_LoadPage(Dokuman: Pointer; SayfaNo: Integer): Pointer; stdcall;
      function FPDF_ClosePage(Sayfa: Pointer): Integer; stdcall;
      function FPDF_GetPageWidth(Sayfa: Pointer): Double; stdcall;
      function FPDF_GetPageHeight(Sayfa: Pointer): Double; stdcall;
      function FPDFText_PDFToText(SourceFile: String; Destinationfile: String; Flag: Integer; Password: String): BOOL; stdcall;
      procedure FPDF_RenderPage(CanvasHandle: HDC; Sayfa: Pointer; Left: Integer; Top: Integer; Width: Integer; Height: Integer; Rotate: Integer; Flag: Integer); stdcall;
      procedure FPDF_RenderPageBitmap(Resim: TBitmap; Sayfa: Pointer; Left: Integer; Top: Integer; Width: Integer; Height: Integer; Rotate: Integer; Flag: Integer); stdcall;
    
    const
      FPDF_ANNOT = 1;
      FPDF_LCD_TEXT = 2;
      FPDF_NO_GDIPLUS = 4;
      FPDF_GRAYSCALE = 8;
      FPDF_DEBUG_INFO = 128;
      FPDF_NO_CATCH = 256;
    
    var
      Form1: TForm1;
    
    implementation
    
      function FPDF_LoadDocument; external 'fpdfsdk.dll' name 'FPDF_LoadDocument';
      function FPDF_CloseDocument; external 'fpdfsdk.dll' name 'FPDF_CloseDocument';
      procedure FPDF_InitLibrary; external 'fpdfsdk.dll' name 'FPDF_InitLibrary';
      procedure FPDF_UnlockDLL; external 'fpdfsdk.dll' name 'FPDF_UnlockDLL';
      procedure FPDF_DestroyLibrary; external 'fpdfsdk.dll' name 'FPDF_DestroyLibrary';
      function FPDF_LoadPage; external 'fpdfsdk.dll' name 'FPDF_LoadPage';
      function FPDF_ClosePage; external 'fpdfsdk.dll' name 'FPDF_ClosePage';
      function FPDF_GetPageWidth; external 'fpdfsdk.dll' name 'FPDF_GetPageWidth';
      function FPDF_GetPageHeight; external 'fpdfsdk.dll' name 'FPDF_GetPageHeight';
      function FPDFText_PDFToText; external 'fpdfsdk.dll' name 'FPDFText_PDFToText';
      procedure FPDF_RenderPage; external 'fpdfsdk.dll' name 'FPDF_RenderPage';
      procedure FPDF_RenderPageBitmap; external 'fpdfsdk.dll' name 'FPDF_RenderPageBitmap';
    
    {$R *.dfm}
    
    procedure TForm1.Button1Click(Sender: TObject);
    var
      ActivePDF, ActivePage: Pointer;
    begin
      try
        FPDF_InitLibrary(Application.Handle);
        FPDF_UnlockDLL('XXXXXXXXXXX','XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');    
        ActivePDF := FPDF_LoadDocument('C:\Any.pdf');
        ActivePage := FPDF_LoadPage(ActivePDF, 1);
    
        FPDF_RenderPage(Canvas.Handle, ActivePage, 0, 0, Round(FPDF_GetPageWidth(ActivePage)), Round(FPDF_GetPageHeight(ActivePage)), 0, 0);
    
        FPDF_ClosePage(ActivePage);
        FPDF_CloseDocument(ActivePDF)
      finally
        FPDF_DestroyLibrary;
      end;
    end;
    
    end.
    I'm Sorry for bad English

  • #2
    Sorry, currently there is no parameter to change pdf text color.

    Comment

    Working...
    X