WPCubed Product Support

AddDataFile

10.4k Views 2 users read 2 min
support

I just sent You a new WPObj_Container.pas unit for correct operation in Delphi 2010, too.

#6 ♥ 0
support

Please make sure to use the latest wPDF DLL

#5 ♥ 0
support

I now understand what You mean.

Please open the filöe WPOBJ_Container.pas and make sure the record TPDFEmbeddedFileElement is code like this:

TPDFEmbeddedFileElement = packed record
DataLen: Integer; // Length, this recod + data !
DataNr: Integer; // Incremented Nr, will be assigned
FS: Integer; // TPDFEmbeddedFileElementFS;
SubType: array[0..39] of AnsiChar; // MIME Type
ModDate, CreateDate: Extended; // Time Values
Compress: Integer; // TPDFEmbeddedFileElementCompress
Data: array of Byte; // data follows
end;

#4 ♥ 0

Hello Julian,

I do not understand your reply. The AddDataFile is being used before the exporting has begun, the RTF file already has the embedded data.

Did you see the line ?

Editor.SaveToFile('c:\embed.rtf'); // This has the embedded manual

The latest manual has the statement; "Using WPTools 6 and wPDF V3 it is now possible to add an object to the PDF file which holds embedded data.", and has some example code very similar to what I have posted.

Cheers,
Paul

#3 ♥ 0
support

Hi,

TWPPDFExport is used for export from WPTools. So you cannot use the AddDataFile after a StartPage command.

But there is the event OnAfterPrintPage which can be used to print additional data on a page and also to use embed a file.

Julian

#2 ♥ 0

Hello Julian,

Having trouble getting embedded data in a PDF. I can embed data in an RTF file using AddDataFile method, but when exporting using TWPPDFExport there is no embedded data.

Regards,
Paul Cunningham

Test console code.

program EmbedPdf;

{$APPTYPE CONSOLE}

uses
  SysUtils, WPPDFR1, WPCtrMemo, WPOBJ_Container, WPPDFWP, WPRTEDefs;

var
  Editor : TWPCustomRtfEdit;
  pdf : TWPPDFExport;
  obj : TWPTextObj;
begin
  try
    WPDF_Start('', '');
    Editor := TWPCustomRtfEdit.CreateDynamic;
    try
      obj := Editor.InputMergeField('FIELD_MANUAL', 'Manual');
      obj := Editor.TextObjects.InsertClass('TWPODataContainer', 360, 360 );
      obj.Mode := obj.Mode + [wpobjSizingDisabled];
      (obj.ObjRef as TWPODataContainer).AddDataFile('c:\manual.pdf', wpembDefault);
      (obj.ObjRef as TWPODataContainer).Icon := wpemPaperClip;
      (obj.ObjRef as TWPODataContainer).AddParam('Contents','Dies ist eine Datei');
      (obj.ObjRef as TWPODataContainer).AddParam('Title', 'Julian Ziersch');
      Editor.InsertPointAttr.Hidden := true;
      Editor.ReformatAll();
      Editor.SaveToFile('c:\embed.rtf'); // This has the embedded manual
      pdf := TWPPDFExport.Create(nil);
      try
        pdf.Source := Editor;
        pdf.FileName := 'c:\embed.pdf'; // this doesn't
        pdf.AutoLaunch := true;
        pdf.Print;
      finally
        pdf.Free;
      end;
    finally
      Editor.Free;
    end;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.
#1 ♥ 0