Please, help with StampMetafile

  • Dear Support,


    I am seeking a way to add vector graphics and to save it over a PDF with the help of your WPViewPDF.


    I have tried your examle code from here https://www.wpcubed.com/manual…er_metafiles_to_pages.htm with both Scaling parameters (0 - like in the example, 72 - like in the recommendations) , but with no success so far -- no stemped MetaFile is seen...


    Could you please have a look and say what's wrong? Should I send you PDFs?


    procedure TForm1.Button2Click(Sender: TObject);

    var

    Metafile1 : TMetafile;

    begin

    Metafile1 := TMetafile.Create;

    try

    Metafile1 := WPViewPDF1.GetMetafile(0);

    // Metafile1.SaveToFile('c:\temp\pdftowmf.wmf'); // gives a nice wmf

    // WPViewPDF2.Command( COMPDF_StampMetafile_Scaling, 0 );

    WPViewPDF2.Command( COMPDF_StampMetafile_Scaling, 72 );


    if Metafile1<>nil then

    begin

    WPViewPDF2.CommandStrEx (COMPDF_StampMetafile, '1', MetaFile1.Handle);

    WPViewPDF2.Plus.SaveToFile('c:\temp\test_modified.pdf');

    end;

    finally

    Metafile1.Free;

    end;

    end;


    FYI: WPDFVIEW License owner : Aiiti Gmbh



    Many thanks for advance.


    Sinserely,

    Olena Vladykina

  • You cannot really stamp a metafile created with getmetafile and stamp it. The metafile stamping pnly supports very small, uncomplicated metafiles,i.e display COPY or something like this


    You can load a pdf and another and use pages from the first as watermark. This should be a better approach

  • From what I see, watermarks could not be saved over PDFs, could they?



    I would also much appreciate, if you can give some examples/clarification to what extend metafile stamping is supported. I tried with 'Hello,World!' texted transporant wmf file with the same results --'nothing is seen'....

  • This is a simple example for Stamp Metafile. Metafiles should always be EMF, not WMF.

    This is the sample code to convert a PDF file into a watermark


    The command COMPDF_LoadFileAsWatermark is used to load a PDF file and convert a certain page into a watermark. The ID of the new watermark is retuned. If the PDF file was already loaded, it will be reused. So it is possible to subsequently use different pages from the same PDF file.


    The command COMPDF_ApplyWatermark is used to apply the watermark with the given id to certain pdf pages. The string parameter of this command is used to select the destination pages. It is possible to select "all", "odd" or "even" pages. Alternatively a range can be specified, such as "1-3,5,7,9-1000".


    To add a positioning mode add it after ";". Positioning modes are 0=over page, 256=under page (default)


    Instead of page list also the text odd and even is allowed. Returns the number of modified pages