Using the pdfPrintW-Function

  • How am I able to print the loaded PDF with the Function pdfPrintW?

    My Code:

    TfrmMain = class(TForm)

    PDF: TWPViewPDF;

    ……
    function pdfPrintW(filename: PWideChar; password: PWideChar;

    licname, lickey: PWideChar; liccode: Cardinal;

    options: PWideChar;

    data: Pointer; datalen: Integer): Integer; stdcall;

    external 'wPDFViewPlus04.dll' name 'pdfPrintW';


    pdfPrintW('','',

    PWideChar(WPViewPDF_LicName),

    PWideChar(WPViewPDF_LicKey),

    WPViewPDF_LicCode,

    PWideChar(sOption),

    PDF,100000);

    I get an exception with "Unknown file Format" !

    Is there a Delphi-sample?

    Best regards

    Bernd

  • Sorry, the documentation says (Site 183):

    pdfPrintW has two additional parameters data and datalen. If not 0, a buffer

    with PDF data is expected which is loaded or, if a file was also specified, appended

    prior to printing.

    How can i understand this???

    • Offizieller Beitrag

    data und datalen spezifiziert einen Speicherbereich falls data nicht nil ist.

    Ansonsten wird aus dem angegebenen "filename" geladen.

    Falls filename angegeben ist, also nicht '' wird dieser zuerst geladen und dann die PDF daten aus dem speicherbereich data/datalen.

    Zur übergaben eignet sich ein memorystream, also

    memorystream.Memory, memorystream.Size für data, datalen.

  • Ah, das habe ich mir nämlich gedacht. Wir arbeiten hier immer mit PDF-Dateien aus Blob-Feldern die dann als memorystream

    geladen werden (pdf.Loadfromstream(Blob-Feld....)).

    Das war der entscheidende Hinweis: memorystream.Memory !!! Damit funktionierts!

    var

    sWideOption : WideString;

    oStream : TMemoryStream;

    ….

    sWideOption := '"HEADERR='+dateTimetostr(now)+'"';

    if lDuplex then

    sWideOption := sWideOption + ','+'"DUPLEX=2"';

    ……
    pdfPrintW('','',

    PWideChar(WPViewPDF_LicName), PWideChar(WPViewPDF_LicKey), WPViewPDF_LicCode,

    PWideChar(sOption),

    oStream.Memory, oStream.Size);

    Danke!