Menu

#102 Patch for new tool to remove watermarks

SVN TRUNK
closed
None
2021-04-09
2020-08-09
No

Hi guys. Recently I need to remove watermarks in some pdfs and can't find tool for this. Unsure no good tools to modify pdfs in Linux. But I found PoDoFo library and wrote a tool which allows to do it. See patch in attachments.

1 Attachments

Discussion

  • Ivan Romanov

    Ivan Romanov - 2020-08-09

    This patch removes options content from pdf. It can handle whoe OCGs or select by name.
    Usage
    podofonooc <in.pdf> <out.pdf> [OC_name]...</out.pdf></in.pdf>

     
    👍
    1
    • Ricky Wei

      Ricky Wei - 2021-04-09

      Hi, thank you for provide such good things.
      By the way, I want to know how do you add watermark for the pdf? (I draw text as watermark but it can not be removed by this tool).

      Thanks.

       
  • Ivan Romanov

    Ivan Romanov - 2020-08-09

    Here the pdf in which I removed watermark.

     
  • Michal

    Michal - 2020-08-09
    PdfObject *ocgs = doc->GetTrailer()->GetIndirectKey("Root")->GetIndirectKey("OCProperties")->GetIndirectKey("OCGs");
    

    Would not it crash if these optional keys are not present?

     
  • Ivan Romanov

    Ivan Romanov - 2020-08-10

    Thanks. Fixed.

     

    Last edit: Ivan Romanov 2020-08-10
  • Michal

    Michal - 2020-08-12

    Similarly here:

    const string &ocgName = docObjects.GetObject(ocgRef)->GetIndirectKey("Name")->GetString().GetStringUtf8();
    

    Although "Name" is required key the pdf can be corrupt and does not contain it. Rule of thumb in podofo is to use MustGetIndirectKey on places which expects this key must be present as it will never return NULL but throw instead (mainly required keys). And use GetIndirectKey but always test for NULL for keys where one wants to do something if that key exists or maybe something else if does not (mainly optional keys). Or use MustGetIndirectKey when you want exception and GetIndirectKey when you do not want exception if the key does not exists.

     

    Last edit: Michal 2020-08-12
  • Ivan Romanov

    Ivan Romanov - 2020-08-12

    Thanks, fixed.

     
  • Dominik Seichter

    • status: open --> closed
    • assigned_to: Dominik Seichter
     
  • Dominik Seichter

    Nice tool, would be nice to also get a short man page for it. Still pushed the patch now as it is also a nice example!

    Thanks for your contribution, it will be part of 0.9.7.

     
  • Ricky Wei

    Ricky Wei - 2021-04-09

    Hi, thank you for provide such good things.
    By the way, I want to know how do you add watermark for the pdf? (I draw text as watermark but it can not be removed by this tool).

    Thanks.

     
  • Ivan Romanov

    Ivan Romanov - 2021-04-09

    I don't add watermarks. I only remove them. I use this tool to remove watermark from old Shimano bike components manuals. I don't know how they create such pdfs. Anyway I believe there are numbers of various ways to add watermarks. In worst case they won't be distinguish from regular text or images.

     
  • Ivan Romanov

    Ivan Romanov - 2021-04-09

    Also you can use podofobrowser to see what exactly add your tool. In this case you will PDF file as a tree of nodes. But in this case you need to read PDF Reference to understand what you see.

     
MongoDB Logo MongoDB