WPCubed GmbH
Wordprocessing and PDF components 

WPViewPDF Sourcecode License

WPViewPDF-PLUS source code addon

 

License

THE LICENSE DOES *NOT ALLOW* PRODUCTION OF MODULES, DLLS, ActiveX OR COMMAND LINE UTILITIES.   THE LICENSE DOES NOT ALLOWED TO USE THIS CODE TO CREATE UNIVERSAL PDF TOOLS WHICH WORK SIMILAR TO ACROBAT PRO, FOXIT EDITOR AND SIMILAR.

 

THE LICENSE CAN ONLY BE PURCHASED DIRECTLY FROM US. WE SELL IT TO COMPANIES WE HAVE KNOWN FOR A WHILE.

 

Functionality

The WPViewPDF-PLUS source code addon allows you to compile your projects without having to include the main WPViewPDF-PLUS DLL later.

However, you still need to use the DLL for TrueType support and JBig2 decryption. Note that the license does not include the source code for the WPViewPDF-PLUS itself. Instead, it includes source code that is used in place of this DLL.

 

The usual WPViewPDF-PLUS component can still be used. You just need to add a compiler symbol and include some units. Since the source code of the DLL is not available, functions like pdfMerge, that require calls to the DLL, are not supported.

 

Limitations

The WPViewPDF-PLUS source code does not contain the specific code required to support JPEGs in CMYK format. Therefore, only JPEGs in RGB format are displayed correctly.

This is not the source code for the DLL, the exported DLL functions (pdfPrint etc) and also the windows sub classing code is not included.  Additionally, AES decryption is missing, but it is practically never needed. The code for converting PDF files to TIFF files is not included.

 

Notes

With the source the component "TWPViewPDF" is implemented as completely native VCL class.

PLEASE NOTE THAT YOU NEED DELPHI 10.1 OR LATER TO COMPILE IT.

 

Source-Code excerpt:

TWPViewPDF = class(TWPViewPanel);

TWPViewPanel = class( TPanel)
protected ....
public
    constructor Create(aOwner: TComponent); override;
    procedure InitMenus;  virtual;
    procedure InitThisInstance; virtual;
    destructor Destroy; override;
    function InternalCommand(id: Integer; StrPar: WideString; IntPar: Integer;
      Ptr: Pointer; pcom : PWPComRecStruct = nil): Integer; virtual;
    function LoadFromFile( Filename: String; Append: Boolean = false; InMemory: Boolean = false ) : Boolean;
    function PageCount : Integer;
    procedure Clear;
    function command(id: Integer): Integer; overload;
    function command(id: Integer; intpar: Integer): Integer; overload;
    function command(id: Integer; strpar: string; intpar: Integer;
      Ptr: Pointer = nil): Integer; overload;
    function command(command: Integer;
          IntParam: {$IFDEF WIN64} IntPtr {$ELSE} Integer {$ENDIF};
          IntParam1: Integer;  IntParam2: Integer = 0;  IntParam3: Integer = 0;  IntParam4: Integer = 0 ): Integer; overload;
    function command(command: Integer; Param: AnsiString; IntParam: {$IFDEF WIN64} IntPtr {$ELSE} Integer {$ENDIF} = 0)
      : Integer; overload;
    function command(command: Integer; Param: WideString; IntParam: {$IFDEF WIN64} IntPtr {$ELSE} Integer {$ENDIF} = 0)
      : Integer; overload;
    // PASS a pointer!
    function CommandEx(command: Integer; Param: {$IFDEF WIN64} IntPtr {$ELSE} Cardinal {$ENDIF} ): Integer;
    {:: This command packs the X and Y paramter into one Integer value and sends it to the engine }
    function CommandXY(command: Integer; X,Y : Smallint): Integer;
    function CommandStr(command: Integer; str: AnsiString): Integer; overload;
    function CommandStrEx(command: Integer; str: AnsiString; Param: Cardinal)
      : Integer; overload;
    function CommandStr(command: Integer; str: WideString): Integer; overload;
    function CommandStrEx(command: Integer; str: WideString; Param: {$IFDEF WIN64} IntPtr {$ELSE} Cardinal {$ENDIF} )
      : Integer; overload;
    function CommandGetStr(command: Integer; str: String; Param: Integer)
      : WideString;
    function CommandGetStrA(command: Integer; str: String; Param: Cardinal)
      : AnsiString;
    property ViewOptions: TWPPDFViewOptions read GetViewOptions
      write SetViewOptions;
    property ViewControls: TWPPDFViewControls read GetViewControls
      write SetViewControls;
    property SecurityOptions: TWPPDFSecurityOptions read GetSecurityOptions write SetSecurityOptions;
    property Document: TLoadedPDFDoc read pdfview;
    property PageNumber : Integer read GetPageNumber write SetPageNumber;
    property MinZoomPanelHeight : Integer read fMinZoomPanelHeight write SetMinZoomPanelHeight;
    property MinZoomPanelWidth : Integer read fMinZoomPanelWidth write SetMinZoomPanelWidth;
    property OnCommand : TWPViewPDFCommandEvent read FOnCommand write FOnCommand;
end;

 

Important: The internal code (accessible through property Document: TLoadedPDFDoc) is not publicly documented. It may also be updated in future version.

 

The code uses parts of some open source projects - see Credits.

(JBIG2 and support for embedded TTF support (FreeType) is linked as DLL.)

 

Example:

How to use use the source code to load the X-Factur XML from a PDF. This code also uses our open source units XOrder.

1) Add the compiler symbol WPVIEWSOURCE to the project which is using the source code (Project/Options)

2) Add WPViewPDF3 to the uses clause

3) Add a variable to the form:

WPViewPDF1 : TWPViewPDF;

4) Now you can use this code

procedure TFacturDemo.btnLoadClick(Sender: TObject);
var mem : TMemoryStream;
begin
  if OpenDialog1.Execute then
  begin
      Memo1.Lines.Clear;

      if SameText(ExtractFileExt(OpenDialog1.FileName),'.pdf') then
      begin
        WPViewPDF1.LoadFromFile(OpenDialog1.FileName);
        mem := WPViewPDF1.GetAttachmentStream(['factur-x.xml','zugferd-invoice.xml']);
        if mem<>nil then
        try
              try
                 XOrder1.LoadFromStream(mem);
              except
                 on e:EWPXorderXMLNotLinked do
                 begin
                   ShowMessage('XML Support was not linked.');
                   mem.Position := 0;
                   Memo1.Lines.LoadFromStream(mem, TEncoding.UTF8);
                   exit;
                 end;
                 else raise;
              end;
              mem.Position := 0;
              Memo1.Lines.LoadFromStream(mem, TEncoding.UTF8);
              if XOrder1.Defaults.Messages.Count>0 then
              begin
                ShowMessage(XOrder1.Defaults.Messages.Text);
              end;
        finally
          mem.Free;
        end;
      end;
  end;
end;