Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 08-29-2010, 05:52 AM   #1
fotobox
Junior Member
fotobox began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Aug 2010
Device: Kindle
Removing headers from pdf file

Hi All

I apologise in advance if this has been asked before, but I've been trying to get what is probably quite a straightforward header and footer removed from a pdf when I convert it to .mobi

If I go to the remove header/footer wizard the code shows (for example; the number increases each page):
<b>Page 1</b><br>

and also (for example; the number increases each page):
<A name=6></a>

What do I need to enter into the line of code in the wizard to remove these?

Cheers in advance!
fotobox is offline   Reply With Quote
Old 08-29-2010, 07:44 AM   #2
Adoby
Handy Elephant
Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.Adoby ought to be getting tired of karma fortunes by now.
 
Adoby's Avatar
 
Posts: 1,054
Karma: 3824376
Join Date: Dec 2009
Location: Southern Sweden, far out in the quiet woods
Device: Ubuntu Linux, Cybook Opus, Motorola Xoom with Mantano Premium
I will give you several answers:

Answer 1:
Just write a regular expression that match the header/footer.

Answer 2:
Learn how to write regular expressions, and then try Answer 1 above. It is a really fun and exciting skill to have: http://docs.python.org/library/re.html#re-syntax

Answer 3:
Try to ask on a online forum, and hope that someone can be bothered to answer you.

Answer 4:
Follow these directions.

I did a footer removal on a PDF. The footer looks like this:

Code:
_<br>
www.eboat.net                                              Page                                                           eboat.net<br>
1<br>
<hr>
The pattern to match this might be built using the following parts:

() surround a part to match. So we need () around it all.

The first part is easy:

(_<br>)

This match the first line. In order to skip ahead to the next line we match some whitespace. Tabs, spaces and newlines. A special code exists for this, namely \s. There may not be any whitespace, or a lot. A * after a pattern will make the pattern match from 0 to many times. So now we have:

(_<br>\s*)

The next few parts should now be obvious:

(_<br>\s*www.eboat.net\s*Page\s*eboat.net<br>\s*)

Next comes a page number. That can change so we match one or more digits instead. The code \d will match a digit. If we add a + it will match one or more digits:

(_<br>\s*www.eboat.net\s*Page\s*eboat.net<br>\s*\d +)

Just a few finishing touches, and we are done:

(_<br>\s*www.eboat.net\s*Page\s*eboat.net<br>\s*\d +\s*<br>\s*<hr>)

I don't actually remember all these codes. I look them up when I need them. But some I do remember. Write a few regular expressions, and it will become easier every time.

http://docs.python.org/library/re.html#re-syntax

Now it should be easy for you to write your own regular expression that match your examples.

One of them would be (have not tested, so it could be wrong):

(<b>Page\s*\d+</b><br>)

The other:

(<A\s*name=\d+></a>)

But this might actually be useful to keep, to allow navigation in the book. It is a bookmark that you can navigate to from a table of contents.

Regular expressions are written using a rudimentary language, with synonyms and many different ways to express the same thing. Some ways may be better/smarter/prettier/more robust than others.

Last edited by Adoby; 08-29-2010 at 07:58 AM.
Adoby is offline   Reply With Quote
Old 08-30-2010, 03:59 AM   #3
fotobox
Junior Member
fotobox began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Aug 2010
Device: Kindle
@ Adoby: Worked a treat, thanks so much!
fotobox is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Removing Headers/Footers Help? Anarel Workshop 10 11-09-2010 12:53 PM
Removing headers/page numbers greycobalt Calibre 3 10-10-2010 01:57 PM
Pls help with removing headers /footers Mamaijee Calibre 0 09-19-2010 01:29 PM
Removing Headers - yet again jjansen Calibre 1 02-18-2010 05:24 PM
Scanning and removing footers/headers monsieurms Workshop 8 12-14-2009 06:12 PM


All times are GMT -4. The time now is 08:16 AM.


MobileRead.com is a privately owned, operated and funded community.