Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Use a page as a watermark

Help
Equalizer
2014-08-04
2014-08-08
  • Equalizer
    Equalizer
    2014-08-04

    Hi,

    Is it possible to use a page from a PDF file to watermark a page instead of drawing your watermark?

    Below is the C/AL code I'm using, may look a bit weird but you should get the jest.

    PDFSourceFile := PDFSourceFile.File('C:\Temp\Pages\Sales Document - Test.pdf');
    PDFWatermarkFile := PDFWatermarkFile.File('C:\Temp\Pages\blah.pdf');
    
    PDFSourceDocument := PDFSourceFile.Document;
    PDFWatermarkDocument := PDFWatermarkFile.Document;
    
    PDFSourcePages := PDFSourceDocument.Pages();
    
    PDFSourcePage := PDFSourcePages.Item(0);
    PDFWatermarkSourcePage := PDFWatermarkDocument.Pages().Item(0);
    
    PDFPageStamper := PDFPageStamper.PageStamper();
    PDFPageStamper.Page := PDFSourcePage;
    
    PDFComposer := PDFPageStamper.Foreground;
    PDFComposer.ShowXObject(
        PDFWatermarkSourcePage.ToXObject(PDFWatermarkDocument));
    PDFComposer.Flush();
    
    PDFSourceFile.Save(
        'C:\Temp\Pages\Sales Document - Test - PDFClown2.pdf',
        PDFClownSerializationModeEnum.Incremental);
    

    When I open the saved document I cannot see the watermark :(

     
    Last edit: Equalizer 2014-08-04
  • Equalizer
    Equalizer
    2014-08-07

    I have solved the issues I was having by writing a wrapper in C# and it works now.

     
  • Andreas Pinter
    Andreas Pinter
    2014-08-07

    If it is possibly to embody it into pdfclown i'm sure stefanio would be happy to get a patch for it?

     
  • Equalizer
    Equalizer
    2014-08-08

    There is only one more thing I would like to be able to do before creating a patch:

    Change the alpha value for the page used as a watermark.

    I'm guessing that would involve scanning the contents and changing the FillAplha value for each object but I'm not sure how to apply the new FillAplha to each object within an existing page.

    It is also possible that I'm missing a much easier way to do this :E

    Apart from creating a page that is already faded for use as a watermark of course :P

     
  • Andreas Pinter
    Andreas Pinter
    2014-08-08

    you might want to have a look at chapter "7.5.5 Transparency Group XObjects" of the PDF Specification (Version 1.6).
    That might be the way to do it. Unfortunately I can't currently look at it myself.