Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Readers > Sony Reader

Notices

Reply
 
Thread Tools Search this Thread
Old 12-16-2006, 02:57 AM   #31
mosh
Member
mosh began at the beginning.
 
Posts: 12
Karma: 10
Join Date: Dec 2006
Device: Sony Reader
Another way of preparing PDF files

Obtain the Multivalent PDF Tools (http://multivalent.sourceforge.net/Tools/index.html)

You can change a PDF's page size using:
java -cp multi.jar tool.pdf.Impose -dim 1x1 -paper 5.24x6.69in input.pdf

Multivalent also comes with a very useful PDF splitting and page deletion tool:
java -cp multi.jar tool.pdf.Split -page 2,4-end input.pdf (this deletes pages 1 and 3)

As for cropping, you may want to evaluate the the pdcrop/pdcat tool.

pdcrop.exe -nb MediaBox -shrink 80:60:-297:-421 input.pdf output.pdf

The pdcat tool can also set the MediaBox and CropBox using the following commands:
pdcat -box
pdcat -crop

Regards,
Mosh
mosh is offline   Reply With Quote
Old 12-16-2006, 05:08 PM   #32
alex_d
Addict
alex_d doesn't litteralex_d doesn't litter
 
Posts: 303
Karma: 187
Join Date: Dec 2006
Device: Sony Reader
mosh, but do those tools crop automatically? For page splitting i'm using pdftk (which seems a bit buggy, but I dunno). Another tool I could use is a good pdf decryptor (since pdftk doesn't want to touch encrypted files).

kovidgoyal, the pdfcrop script is very buggy and doesn't seem capable of dealing with Windows paths. It doesn't understand spaces within quotes (ie "c:\documents and settings\") and even passing it temp\stage1\0001.pdf yields:

Code:
F:\Books\Sony Reader formatted\PDFrasterFarian 0.9.9>pdfcrop.exe --verbose --gscmd gs\gs8.54\bin\gswin32c.exe  --margins 0 temp\stage1\0001.pdf temp\stage1\0001.crop.pdf
PDFCROP 1.5, 2004/06/24 - Copyright (c) 2002, 2004 by Heiko Oberdiek.
* Running ghostscript for BoundingBox calculation ...
* Page 1: 0 14 540 736
* Running pdfTeX ...
This is pdfeTeX, Version 3.141592-1.30.6-2.2 (MiKTeX 2.5)
entering extended mode
(tmp-pdfcrop-41252.tex
! Undefined control sequence.
\pdffile ->temp\stage
                      1\0001.pdf
\page ...box 0=\hbox {\pdfximage page #1{\pdffile
                                                  }\pdfrefximage \pdflastxim...
l.43 \page 1 [0 14 540 736]

! Undefined control sequence.
\pdffile ->temp\stage 1\0
                         001.pdf
\page ...box 0=\hbox {\pdfximage page #1{\pdffile
                                                  }\pdfrefximage \pdflastxim...
l.43 \page 1 [0 14 540 736]


Error:  (file temp1001.pdf): cannot find image file
 ==> Fatal error occurred, the output PDF file is not finished!
!!! Error: pdfTeX run failed!
Why does it think there is a space between "stage" and "1"? Do you think you could take a look at the perl? I don't know that language. It would also be nice to know what pdfetex is doing and if something simpler could replace it. EDIT: If ghostscript is calculating the actual autocropping, why do I need anything besides ghostscript?

Anyway, at least I got automatic page resizing working (no need to enter DPI anymore).

I keep putting off fixing the image filter, but that's probably more important than autocropping.

Last edited by alex_d; 12-16-2006 at 05:47 PM.
alex_d is offline   Reply With Quote
Advert
Old 12-16-2006, 06:28 PM   #33
mosh
Member
mosh began at the beginning.
 
Posts: 12
Karma: 10
Join Date: Dec 2006
Device: Sony Reader
PDF crop

When you say "automatically crop" can you be more precise as to what you mean?

With PDcrop.exe I must manually choose how many points I take off of each edge.
mosh is offline   Reply With Quote
Old 12-16-2006, 06:51 PM   #34
Aprilbeginnings
Guru
Aprilbeginnings has a complete set of Star Wars action figures.Aprilbeginnings has a complete set of Star Wars action figures.Aprilbeginnings has a complete set of Star Wars action figures.Aprilbeginnings has a complete set of Star Wars action figures.Aprilbeginnings has a complete set of Star Wars action figures.
 
Aprilbeginnings's Avatar
 
Posts: 632
Karma: 404
Join Date: Nov 2006
Location: Southern CA
Device: Sony PRS-500 /prs 650 soon
Just call me totally confused, LMAO.
Aprilbeginnings is offline   Reply With Quote
Old 12-16-2006, 08:46 PM   #35
mosh
Member
mosh began at the beginning.
 
Posts: 12
Karma: 10
Join Date: Dec 2006
Device: Sony Reader
Ends and Means

To summarise what I am trying to accomplish:

1st approach:

Taking regular 8.5x11in PDF files and resizing the pages to 5.24x6.69in (377x482points) for the reader using multivalent tools. Then by using the PDcrop tool to trim the excess white space around the page edges. The result is nearly acceptable PDF file display on my reader.

One issue that I still encounter is the anti-aliasing font thinning as described earlier on this forum.

2nd approach:

The PDFrastafarian tool attempts to "raster" the PDF pages to PNG and then compile them to an "image" LRF (BBeB) format.

3rd approach:

PDF text extraction using, for example, multivalent tools, or some other utility and converting the results to RTF for display on the reader.

4th approach:

Performing PDF text extraction, again, and then converting the text to LRF (BBeb) format.
java -cp multi.jar tool.doc.ExtractText input.pdf >output.txt

Are there any other methods or approaches that I have neglected to mention?

Mosh

Last edited by mosh; 12-16-2006 at 09:19 PM. Reason: update
mosh is offline   Reply With Quote
Advert
Old 12-16-2006, 10:21 PM   #36
baker101
Member
baker101 began at the beginning.
 
Posts: 22
Karma: 10
Join Date: Dec 2006
would it be possible to take a picture of the reader before and after the pdf conversion?

i do alot of programming and would like to see if the reader would be a good choice.

thanks for any help.
baker101 is offline   Reply With Quote
Old 12-17-2006, 03:06 AM   #37
alex_d
Addict
alex_d doesn't litteralex_d doesn't litter
 
Posts: 303
Karma: 187
Join Date: Dec 2006
Device: Sony Reader
alright, i took a little breather and realized that all that other software is pointless and i just have to read through ghostscript's help files a couple of more times (boy are they neither concise nor verbose). ghostscript can be used for decryption, autocropping, and everything else except printing out the ToC.

baker, i'll take pics after I get it working

edit: mosh, pdcat turned out useful since ghostscript can't easily change the cropping

Last edited by alex_d; 12-17-2006 at 04:44 AM.
alex_d is offline   Reply With Quote
Old 12-18-2006, 06:43 PM   #38
alex_d
Addict
alex_d doesn't litteralex_d doesn't litter
 
Posts: 303
Karma: 187
Join Date: Dec 2006
Device: Sony Reader
ok. Autocropping is working, the UI has had many improvements, and I restored the option to use the older (0.9.0), faster image filter which I think gives better, higher-contrast results (even if the letters are a bit jaggied). Also, there's new install/uninstall scripts which put an option in the context menu when you right-click a pdf (so specifying input/output files isn't annoying).

I started working on writing an image filter for imagemagick, but hit another snag. Imagemagick is slow. Incredibly slow. Half an hour per page slow. So i'll have to find something else.

Anyway, I'm calling this 1.0 beta 1. Let me know any bugs!


Todo: Get quarter-page mode working (like the iliad). Figure out a better image filtering method (sigh). And see if the context menu works for everyone (it might have a weird dependency on Adobe Reader).
EDIT: playing with it some more I've concluded that the double-res (0.9.6) mode hurts contrast and isn't usually desirable. I'll see if I can add some contrast-enhancing step somewhere, but I should've made the UI more clear that it isn't usually better..
Attached Files
File Type: rar PDFrasterFarian 1.0beta1.part1.rar (4.98 MB, 294 views)
File Type: rar PDFrasterFarian 1.0beta1.part2.rar (4.98 MB, 287 views)
File Type: rar PDFrasterFarian 1.0beta1.part3.rar (1.24 MB, 278 views)

Last edited by alex_d; 12-18-2006 at 09:47 PM.
alex_d is offline   Reply With Quote
Old 12-19-2006, 01:58 AM   #39
mosh
Member
mosh began at the beginning.
 
Posts: 12
Karma: 10
Join Date: Dec 2006
Device: Sony Reader
1.0 beta 1 bugs

Alex,

I have encountered the following bugs:

PDFrastafarian refused to output to the requested file and I had to remove the following section to force it to work:

ECHO __test__ > "%outputFile%"
FOR /F %%A in ('more "%outputFile%"') DO SET contents=%%A
IF NOT "%contents%"=="__test__" (
ECHO.
ECHO.
ECHO !!!!ERROR: Output file cannot be written to!
ECHO %outputFile%
ECHO.
GOTO :askOutputFile
) ELSE del /Q "%outputFile%"

When choosing the autocrop option the following error occurs:

Generating preview....
rasterizing...
Error: Failed to open PDF file:
G:\pdf\PDFr\lawx.pdf
Errors encountered. No output created.
Done. Input errors, so no output created.
Too many arguments in command line.
Error: /undefinedfilename in (G:\\pdf\\PDFr\\\\temp\\stage2\\0004)
Operand stack:

Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-
- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- fa
lse 1 %stopped_push
Dictionary stack:
--dict:1128/1686(ro)(G)-- --dict:0/20(G)-- --dict:70/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
AFPL Ghostscript 8.54: Unrecoverable error, exit code 1
filtering...
convert.exe: unable to open image `G:\pdf\PDFr\\temp\stage3\0004': No such file
or directory.
convert.exe: missing an image filename `G:\pdf\PDFr\\temp\stage4\0004'.
convert.exe: unable to open image `G:\pdf\PDFr\\temp\stage4\0004': No such file
or directory.
convert.exe: missing an image filename `G:\pdf\PDFr\\temp\preview.png'.
mosh is offline   Reply With Quote
Old 12-19-2006, 03:54 AM   #40
alex_d
Addict
alex_d doesn't litteralex_d doesn't litter
 
Posts: 303
Karma: 187
Join Date: Dec 2006
Device: Sony Reader
"PDFrastafarian refused to output to the requested file and I had to remove the following section to force it to work:"

did it work without those lines? The point of that code is to test writing to the output file and reading back. If the script can't do it, it assumes that lrs2lrf won't be able to write to the output file either. Possible reasons are an invalid filename, the file is open somewhere, or you don't have correct ntfs permissions (i'll put that in the error message). Another reason, of course, is that the code's broken, and if the output lrf gets created just fine then obviously that's the problem. It's pretty simple code, though.

Hmm... what happens when you go to start>run and enter
cmd /k more
(should be a black screen with a blinking underscore)
or how about
cmd /k FOR /F %A in ('more "C:\boot.ini"') DO @ECHO %A
(should be a few lines from your boot.ini file)
and, for that matter,
cmd /k echo __test__ > c:\test.txt & more c:\test.txt
(should read __test__ at the very top)

Thanks a lot for your help! p.s., what's your OS? I'm pretty sure only win2k and up will work properly.

EDIT: if you're calling the script manually, remember you have to put filenames with spaces inside "". (e.g. "c:\documents and settings\")

Last edited by alex_d; 12-19-2006 at 03:56 AM.
alex_d is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Tips and tricks for PocketBook kacir PocketBook 170 07-04-2012 05:03 PM
Tips, Tricks, and Hints Nate the great Amazon Kindle 44 03-22-2011 04:15 AM
PRS-600 PRS-600 tips and tricks maxbookworm Sony Reader 77 09-17-2010 02:41 AM
PRS-600 Shortcuts or Tips and Tricks CarolB Sony Reader 3 12-14-2009 03:55 PM
PRS-600 Tips & Tricks Oh, Why Not? Sony Reader 1 09-23-2009 07:49 PM


All times are GMT -4. The time now is 10:08 PM.


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