Find empty space

  • HamburgerJungeJr


    is it possible to find the empty space in a pdf document.
    I want to place there a new text (Barcode)

    I hope you can help me.


  • Hakan

    Hakan - 2013-12-11

    I think the author of this project stopped helping long ago, but
    Yes, it is possible
    render the PDF page to a PNG using Ghostscript or MuPDF at 36 or 72 dpi, that goes very fast & reliable.
    Then use an ImageTraverser ( ) and scan the bitmap for an empty space that is large enough for your purpose. The Traverser I linked you to on codeproject is significantly faster then .net's 'getpixel'
    You'll need to write your own algorithm to 'scan' the bitmap and detect empty rectangular spaces, if you know what your doing with pixels (and colour/grayscale detection) that part should be no more then 1~2 days of coding.
    I have done similar work before on large drawings.
    Good luck

    • HamburgerJungeJr

      Thanks for your reply.
      Sorry for answering so late but I had a lot to do during the last weeks. ;-)
      I will try your tip these days.

      I hope it'll work.


  • HamburgerJungeJr


    I managed to find an empty space in my PDF document.
    But I have another problem. I want to add a barcode to a PDF. I have a special Barcode-Font. This works on PDFs which are created on the Pc but not on scanned PDFs. On scanned PDFs I get an eror in Adobe Reader "Font ?????? could not be displayed".
    Has anyone an idea?


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks