gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > PDF Proof of Concept

#166343 - albinofrenchy - Thu Feb 05, 2009 2:16 pm

Here is a proof of concept for a PDF viewer: link

(Hat tip to mupdf, whose slightly-tweaked library this is using.)

It is very prototypical right now; when the ROM loads it will give you a file browser. Double-tap a folder to go into it, double tap a pdf file to choose it. Double tap non-pdf files at your own peril (You'll just get an error message.)

Once inside, you can use your stylus to 'move' the page.

I've tested it with a number of PDF files, and the only limitation seems to be memory-wise; if the file or images in the file can't fit into memory it does not like that for obvious reasons. Other than that, if you find a PDF that doesn't load please post a copy here or email one to me.

The load time is pretty bad right now, but I have plans to make that less noticeable. The redrawing time is horrible; but that is without any kind of optimizations in place, so I think neither will be a barrier to a usable viewer.

Anyone with ideas on how they'd want to see this kind of thing work? I'll be putting the code up soon, if anyone wants it now though you can message me.

Also, anyone know whats up with the screen artifacting between buffer redraws?

EDIT:

The PDF reader works with FCSR for all those who are in the know on that and want to just see this thing run in an emulator. Just include the PDF's you want.

Edit x2:
I replaced the direct link with the link to the post on my blog about it. Forgive me the extra step, but I really want to gauge interest on this project, and this is an easy way to do this.


Last edited by albinofrenchy on Fri Feb 06, 2009 5:46 am; edited 2 times in total

#166346 - hacker013 - Thu Feb 05, 2009 5:08 pm

can you post the source, please?
_________________
Website / Blog

Let the nds be with you.

#166351 - samel - Thu Feb 05, 2009 6:48 pm

I get:
a bounce of error
a black screen with some pixel in the bottom screen [all at beginning of the screen]

I've tried 3 pdf, one with figure, and two only text, one 30Kb and the other 300Kb. I've a R4 and a ds lite.
Hope this will help, i'm here for any question.

#166354 - albinofrenchy - Thu Feb 05, 2009 7:48 pm

Hacker: I'm not home right now, and it will take me a bit to clean it up so that the code isn't embarrassing :). Do you want to see the main app code or the modified mupdf library too? Both will be up at somepoint, but the mupdf stuff will take longer to figure out the best way to do it (If you only want to see source for the main app, I'll provide the five or six libraries it needs to compile so you can play with it. Is there a repository for cross-compiled binaries for the DS?)

samel: Hrm. I should have kept the sub screen in console mode for errors.

The black screen with the pixels is semi normal since I'm not cleaning the video buffers; and so if the PDF isn't rendered then they won't be clean. My first thought is maybe the FAT filesystem stuff doesn't work right for the R4 like it does for my acekard, but it sounds like you can navigate and choose your file? Are any of these PDF's available for me to put on my system and try out?

Regardless, I'll go ahead tonight and put up a debug version which will keep the sub screen as a console, and we will be able to narrow it down that way. Thank you very much for trying it!

#166356 - samel - Thu Feb 05, 2009 8:33 pm

I could send you one of them, it's an index of RFC documents. Can you tell me your mail?

For the filesystem i think that's not a problem because i can browse file and one of them cause some debug information that say there where error in some object in the pdf. So the file can be opened.

I'll try with the debug version as soon as you post it.

#166364 - albinofrenchy - Fri Feb 06, 2009 5:44 am

I'm going to start putting all this stuff on my ds blog for now. At some point I want to get some kind of project hosting underway, but I'm not sure what I'm doing there yet. The debug version and a fixed alpha version are available there.

I think I found the problem. I'm a newb with C++ stuff, and so I missed the fact that c_str() reclaims the memory for the buffer it gives. Oops. It should be working fine now though; tell me if you still have the issues?

Source is forthcoming, I really want to clean house first though!

#166366 - albinofrenchy - Fri Feb 06, 2009 9:07 am

Source is up on the site with precompiled binaries. You'll probably have to do a bit of a dance with the makefiles depending on your configuration, but nothing too hard.

Hacker - If you do try to compile anything, please tell me how that turns out! I'm paranoid I left files out.

#166367 - elwing - Fri Feb 06, 2009 10:02 am

That is great, it was one of the most lacking feather on the DS in my opinion, i'll give a try on my dstt and on my m3perfect as soon as possible...
just an additional question if the main problem seem to be the memory limitation, do you plan do use additional ram from gba cart like m3perfect or the DSbrowser?

#166368 - albinofrenchy - Fri Feb 06, 2009 10:22 am

Elwing: It depends largely if there is anyone who wants to tackle that problem. I have neither of those, but it is possible I'll get one just because it would be cool to have. Hopefully though we will be able to get to a point where it simply isn't needed. Memory problems exist now because the library I ported the code from assumes (rightly so; it was made for the PC in mind) there is substantially more memory than there is. I want to shy away from going the extra ram amount immediately though, because I think that will drive development more to expect that extra ram; which I don't think the vast majority of people have.

#166369 - samel - Fri Feb 06, 2009 12:33 pm

May be you can load only one page a time?

#166374 - hacker013 - Fri Feb 06, 2009 4:39 pm

can you just provide one zip or rar with all the source instead of the links to every library.
_________________
Website / Blog

Let the nds be with you.

#166376 - elhobbs - Fri Feb 06, 2009 4:46 pm

hacker013 wrote:
can you just provide one zip or rar with all the source instead of the links to every library.
yeah, downloading three files is such a hardship... I seriously hope you are kidding...

#166377 - albinofrenchy - Fri Feb 06, 2009 5:11 pm

@Hacker: The problem with that is I'm guessing there is a sizable group that doesn't care about the fitz code at all, and just wants to use the compiled library for it. Unfortunately where I have a size cap on where I'm hosting the files now, so I don't want to put too many configurations up, but when I find a more permanent solution I'll do this.

@samel: The mupdf stuff does load only a single page into memory at a time, the problem is that there is a lot of 'shared' stuff in the PDF document that has to be all loaded at once. At least, I think thats the problem; I'll investigate more closely. I will say that if its all mostly text memory usage seems to be fairly independent of the number of pages.

#166506 - elwing - Mon Feb 09, 2009 8:20 am

hum, I tried with three pdf created with open office and the debug build.
-one is too large to load (470Ko a few pages and images) and report some out of memory errors.
-one report error while loading ressources & font (not related to memory it seems) and show a white screen.
-the last one does not report any error but only render a white screen...

#166512 - albinofrenchy - Mon Feb 09, 2009 10:18 am

Man, 0/3 :-/

I'm guessing the images are taking out the first one. I still have to mess with them.

I'm wondering if maybe the thing doesn't like OpenOffice's font, could you send me some test files?

I really appreciate the testing!

#166515 - elwing - Mon Feb 09, 2009 10:42 am

no problem trough I'll need to modify a bit my document I won't send you my resume :)

#166542 - albinofrenchy - Mon Feb 09, 2009 5:17 pm

Hrm. The thing shouldn't be loading the image until it gets to that page, so I'll figure out why it is. The second one is trying to find font resource files and failing; I'll see if I can't get it to work with a font resource folder. The third one actually works (it should, anyway), you just have to scroll to the left alot because it is non-standard paper size and my program assumes its a normal sheet. I'll see if I can't strip that assumption out for todays release.

#166559 - elwing - Mon Feb 09, 2009 7:05 pm

hum sorry for the false positive, scrolling on a blank page is counter intuitive :)

#166603 - albinofrenchy - Wed Feb 11, 2009 2:48 pm

(Mods forgive me -- should I make a thread in announcements for this kind of thing?)

I've got a new version of the pdf viewer up.

This one gives you scrolling, next/prev page, rotation and zoom.

My apologies to everyone who has tested it so far and found PDF's that haven't worked. The next thing I'm going to work on is figuring out to broaden pdf compatibility.

Thanks to anyone who has or will test it out!

#166936 - albinofrenchy - Tue Feb 24, 2009 2:17 pm

I've moved all announcements to this thread: http://forum.gbadev.org/viewtopic.php?t=16468

Which I think will be more appropriate... :)