Convert PDF into watermark

<< Click to Display Table of Contents >>

Navigation:  Tasks >

Convert PDF into watermark

If you have licensed the PLUS edition it is also possible to save to a new PDF file with the new watermarks.

 

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 of the page number passed as IntParam is returned. 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. If IntParam<0, the count of pages is returned instead.

 

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

 

Example - apply page one to all pages

 

i := wpviewpdf1.CommandStr( COMPDF_LoadFileAsWatermark, OpenDialog1.FileName );

if i>0 then

  wpviewpdf1.CommandStrEx( COMPDF_ApplyWatermark, '1-1000', i );

 

 

Example:

 

        i := WPViewPDF1.CommandStrEx( COMPDF_LoadFileAsWatermark, 

               OpenDialog1.FileName, 

               StrToInt(edSourcePage.Text)-1);

        if i<=0 then

           ShowMessage('The PDF file cannot be loaded as watermark 

              - Code=' + IntToStr(i))

        else

        begin

          if rbOddPages.Checked then

             i := WPViewPDF1.CommandStrEx( COMPDF_ApplyWatermark, 'odd', i)

          else if rbEvenPages.Checked then

               i := WPViewPDF1.CommandStrEx( COMPDF_ApplyWatermark, 'even', i)

          else i := WPViewPDF1.CommandStrEx( 

                   COMPDF_ApplyWatermark, edPageRange.Text, i);

 

          if i<=0 then

           ShowMessage('The PDF page cannot be applied as watermark');

        end;