LifeAlgorithm / VitalSourcePrinter

Code to legally and automatically print your purchased e-books from VitalSource.com
MIT License
76 stars 24 forks source link

Printing Limited to 1 Chapter #3

Open TallCoderDude opened 7 years ago

TallCoderDude commented 7 years ago

Hi, VitalSource will only let you print within the pages in that chapter. Could you adapt the "Chapter-page" code of VitalSourcePrinter to still prompt for the number of chapters and number of pages in each chapter, but then utilize the normal page format? Then, as you are printing, when you get to the last page in a particular chapter, prompt the program to go to the next chapter using "Ctrl +PageDn" ?

That would be awesome! Thanks.

LifeAlgorithm commented 7 years ago

Hi TallCoderDude, I just created a script for this based off what you told me called VitalSourcePrinter_ChapPageV2.py

Since I don't have that style of book, I can't see it for myself. Test and let me know if it works.

TallCoderDude commented 7 years ago

My initial comment wasn't very clear, sorry. VitalSource books that only allow printing of one chapter at a time are in the regular page format (e.g. i,ii,iii,iv,v,...1,2,3,4,5...) not the "Chapter-Page" format (e.g. 1-1, 1-2, 1-3, ...) So I wasn't able to verify if the "CTRL +PageDn" functionality worked. But, I looked at your code and it looks like it would do the right thing, just the format needs to be changed.

I would help out with the coding, but 1.) I'm a novice at python and 2.) I am crazy busy right now. But, dude thanks soooo much for putting these programs together!

LifeAlgorithm commented 7 years ago

No problem, And ah, it looks like a 4th script will need to be created, for pages of the normal style with the Ctrl + PageDn format. I'm busy as well right now, but feel free to contribute if you want to/have time. I'll get on this next week either way.

LifeAlgorithm commented 7 years ago

Finally got around to making the ctrl+pagedown requirement for standard pages. Let me know if it works.

TallCoderDude commented 7 years ago

First off, thanks again. One issue that I noticed: The data validation that you were trying to do in Line 120 has some issues. It appears that the variable "printList" was not defined before it was called.

Ok, it didn't really work correctly, but the format is there. The program should prompt the user in the following order for: 1.)Number of chapters in the book 2.)Starting page number. (The very first page to be printed in the entire book.) 3.)End page number. (The very last page to be printed in the entire book.) 4.)The page number of the last page in every chapter that was requested to be printed. 5.)Location to save the generated PDF's.

And so far the program's got that, so sweet. But there was an issue. After inputing values, the program starts printing but skips over the "Ebook.pdf" and goes straight to "File2.pdf". But then it gets stuck because there isn't an "Ebook.pdf" in the destination folder.

On your end, even though you don't have a book that has the PageDown requirement, any book in the normal page number format (e.g. 1, 2, 3, 4, etc.) that also is a chapter book could be used to troubleshoot. The program would just get all the same data as written above and when it got to the end of a chapter it would "PageDown" and then loop again through the next chapter.

Toss in as many annotations as you want, lol I kinda need them to decipher the Python, and it helps me learn.

Thanks again!!!

TallCoderDude commented 7 years ago

To keep the coding clean you might define a function called "PrintChapter" that could be used in a "for" loop for each chapter in the book. Such as:

def PrintChapter ()

for i in range (1, NumberOfChapters) PrintChapter(i) Just a suggestion, do what you feel works best.
LifeAlgorithm commented 7 years ago

Great feedback. In regards to modularizing the script by making a PrintChapter function, that's definitely something that can be done as there are repeated code segments. And you're right about me still being able to test even without having that style of book, so that's what I did.

I fixed the printList bug and another bug I caught. printList is a variable that I used in another script that I copy/pasted by mistake. printList was supposed to be named NumberList, the original list variable for standard pages. It contains all page numbers between the first and the last page inclusive.

The other bug occurred because I forgot to include the countdown timer, so there was no delay, and I believed the the initial print of the ebook.pdf was skipped out on.

So I fixed the two bugs and ran the script, and it ran to completion. The page+down of course didn't do anything. Try the new script and see if it works.