|08-29-2010, 06:52 AM||#1|
Join Date: Aug 2010
Removing headers from pdf file
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):
and also (for example; the number increases each page):
What do I need to enter into the line of code in the wizard to remove these?
Cheers in advance!
|08-29-2010, 08:44 AM||#2|
Join Date: Dec 2009
Location: Southern Sweden, far out in the quiet woods
I will give you several answers:
Just write a regular expression that match the header/footer.
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
Try to ask on a online forum, and hope that someone can be bothered to answer you.
Follow these directions.
I did a footer removal on a PDF. The footer looks like this:
_<br> www.eboat.net Page eboat.net<br> 1<br> <hr>
() surround a part to match. So we need () around it all.
The first part is easy:
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:
The next few parts should now be obvious:
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:
Just a few finishing touches, and we are done:
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.
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):
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 08:58 AM.
|Thread Tools||Search this Thread|
|Thread||Thread Starter||Forum||Replies||Last Post|
|Removing Headers/Footers Help?||Anarel||Workshop||10||11-09-2010 01:53 PM|
|Removing headers/page numbers||greycobalt||Calibre||3||10-10-2010 02:57 PM|
|Pls help with removing headers /footers||Mamaijee||Calibre||0||09-19-2010 02:29 PM|
|Removing Headers - yet again||jjansen||Calibre||1||02-18-2010 06:24 PM|
|Scanning and removing footers/headers||monsieurms||Workshop||8||12-14-2009 07:12 PM|