Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7512687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:56:35+00:00 2026-05-29T23:56:35+00:00

I need some sort of an algorithm, that would try to find free space

  • 0

I need some sort of an algorithm, that would try to find free space on a specified page of a PDF.

The space I’m looking for is a square 100×100 pixel large. I would like to start searching from the bottom right, move further left in a row, and then gradually move up rows, until I either find a suitable space (free-space/white-space), or return error, that there is no free space.

Anyone aware of such a possibility in Android? And if not, how could I implement it?

Edit

I have been doing quite a bit of research on this lately, and am I right in assuming, that finding a free spot is not possible, until the document is rendered? Because if I’m getting it, right, every vector and every object should be put in it’s place, just to find the free spaces? Meaning, the places which no vectors intersect?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T23:56:38+00:00Added an answer on May 29, 2026 at 11:56 pm

    You definitely need to render the PDF. You can use something like poppler, and then search for white regions. Here is an open source Android app using poppler that you could modify/use as inspiration:

    http://code.google.com/p/apdfviewer/

    Once you have the rendered PDF, you can use something like the Boyer-Moore string search algorithm to find space. I.e. in 1D you are trying to find the string “…….” in “+++…++…..+………..” where . = white and + = not white.

    In 2D it will be more complicated, the most efficient thing I can think of is something like this:

    1. Search along the row until you find sufficient space.
    2. Go to the next row and search along it up to the point you were at in the row above.
    3. If you find space before that, repeat step 2, then continue.

    If you see what I mean… something like this:

    void search(int row, int space_pos, int space_height_so_far)
    {
      for (int x = find_next_space(row, 0); x < space_pos; x = find_next_space(row, x+1))
      {
         search(row+1, x, 0);
      }
      if (is_space(row, space_pos))
      {
         if (space_height_so_far > ?)
            cout << "Space found at " << row << ", " << space_pos << endl;
         else
            search(row+1, previous_space_pos, space_height_so_far);
      }
    }
    

    Hmm I can see several things wrong with that code already.. but hopefully you get the idea. I expect that algorithm exists already but I don’t know the name for it unfortunately.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some sort of node-graph editor, that hopefully works on both Mac and
I need some sort of interactive chart control for my .NET-based web app. I
To preface I am using Borland C++ and the VCL. I need some sort
We are starting a rather complex new project at work, and need some sort
I need to develop some sort of application featuring Editing Movie slices, Adding and
Is there some sort of built-in authentication in WCF? I need to expose a
I have some sort of recursive function, but I need to parse a string,
I've written the following IComparer but I need some help. I'm trying to sort
Brainstorming request I need an idea for an authentication algorithm with some unusual requirements.
I need to find an algorithm for generating every possible permutation of a binary

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.