Log of #ghostscript at irc.freenode.net.

Search:
 <<<Back 1 day (to 2017/02/21)20170222 
Diemex_ Robin_Watts: Okay. So there are 2 repositories mupdf and mupdf-android-viewer-old. Which should I use to build for android? Last time I used the viewer. Copied the compiled .so binaries and java classes to my project. 11:09.12 
Robin_Watts mupdf has the basic JNI classes in.11:09.40 
  mupdf-android-viewer-old has the hacked-together-just-enough-for-the-apps-needs JNI classes in.11:10.09 
Diemex_ The libmupdf folder seems to be a copy of mupdf11:10.24 
  But I dont think its used yet? Right?11:10.45 
Robin_Watts Sorry, where are you looking?11:11.00 
tor8 Diemex_: the android viewers now live in their own repositories, and include the mupdf project in a folder called 'libmupdf'11:11.48 
  if you want to build for android, clone one of the android-viewer repositories (and don't forget --recursive to git clone)11:12.31 
Diemex_ Yes that is what I meant. Its a one to one copy. Even code for windows and other platforms is still included haha11:12.33 
Robin_Watts Diemex_: A git 'submodule' is a reference to another git repo.11:13.08 
Diemex_ The instructions to build the android viewer are still for the old app not the jni bindings?11:13.27 
Robin_Watts so we keep the core mupdf stuff in the mupdf repo, and the projects (like viewers etc) refer to that (and hence on a clone, get a copy).11:13.55 
  Diemex_: Depends which instructions you look at :)11:14.11 
Diemex_ https://mupdf.com/docs/how-to-build-mupdf-for-android11:15.11 
  I would just like to know how to get the .so files to include in my project. I don't think I will bother trying the "new" Android Studio support for c/c++ Code as I will most likely not modifying mupdf anytime soon. 11:16.31 
Robin_Watts Diemex_: Those instructions are indeed for 'mupdf-android-viewer-old.git'11:17.15 
tor8 Diemex_: there is a new project 'mupdf-android-viewer-mini.git' which is a LOT simpler code, and uses the new JNI11:23.51 
  I'm also working on a branch of mupdf-android-viewer-old which strips out all the editing functionality and rewrites the MuPDFCore to use the new JNI library11:24.34 
  but that is still quite complicated GUI code11:24.57 
  http://git.ghostscript.com/?p=mupdf-android-viewer-mini.git;a=blob;f=README11:26.26 
Diemex_ Is there support for greyscale rendering in the jni bindings? There are lots of pdfs that are just text. One could save a lot of memory if those aren't rendered in argb_888811:40.37 
tor8 Diemex_: yes. but if you're rendering to android.graphics.Bitmap that is only ARGB8888.11:41.46 
  should not be *too* difficult to change11:41.58 
  there's some fancy tricks going on to render directly into an android.graphics.Bitmap's backing store memory11:42.36 
Diemex_ Because android has an ALPHA_8 format that one could use for greyscale11:42.40 
tor8 Diemex_: the #ifdef HAVE_ANDROID section with newNativeAndroidDrawDevice in platform/java/mupdf_native.c and platform/java/src/com/artifex/mupdf/fitz/android/AndroidDrawDevice.java11:44.16 
Diemex_ So I would change from fz-device-rgb to fz-device-greyscale (or whatever its called) 11:49.04 
  Those are some memory optimisations that I will do down the road sometime. I was also thinking about not rendering the padding around pages. The white space is quite wasteful (No information)11:50.42 
  Will grezscale rendering be faster than rgb?11:51.27 
  The amount of memory needed is just crazy on a 1440p tablet. 2048px tiles encoded in argb8888 are 16mb each. My app uses around 150mb Ram, mostly just bitmaps11:55.46 
  If I reduce the tile size the rendering slows down too much11:56.10 
tor8 grayscale rendering will be faster, because it only hits 1/4 of the RAM12:11.52 
Diemex_ tor8: Your git submodule reference is broken: Fetched in submodule path 'libmupdf', but it did not contain 79c47af457f7b3ac8c67ffc17e7f824ad0266304. Direct fetching of that commit failed.12:23.22 
tor8 Diemex_: sorry, try again now.12:23.51 
  I'd forgotten to push yesterdays' batch of approved commits to our master repo12:24.11 
Diemex_ tor8: Works now12:39.06 
  tor8: I get this error when running make12:46.53 
  In file included from C:/CODE/NDK/mupdf_new/mupdf-android-viewer-mini/libmupdf/platform/java/mupdf_native.c:13: C:/CODE/NDK/mupdf_new/mupdf-android-viewer-mini/libmupdf/include\mupdf/pdf.h:10:10: fatal error: 'mupdf/pdf/name-table.h' file not found12:46.54 
tor8 Diemex_: oh, you're using windows?12:48.34 
Diemex_ Yeah ofc12:48.49 
tor8 you'll need to find some way to run the 'make generate' step in libmupdf.12:48.57 
  on linux that's done automatically if you use the makefile12:49.06 
  easiest would be to open up libmupdf/platform/win32/libmupdf.vcproj in visual studio12:49.30 
  or cd libmupdf/platform/win32 and run generate.bat12:49.51 
Diemex_ I dont have VS installed atm...12:50.52 
tor8 sorry, that should be "cd libmupdf" and run "platform\win32\generate.bat"12:51.16 
  have you got MSYS/MinGW installed?12:51.28 
  have you got access to a linux machine?12:51.35 
  are you using Windows 10 with the Linux for Windows Subsystem?12:51.53 
Diemex_ I have GnuWin3212:52.15 
tor8 if neither of those are true, you're out of luck.12:52.18 
  run "make generate" in libmupdf12:52.37 
  if you have a unix-ish enough environment to run make and gcc that should be enough12:52.52 
Diemex tor8: Running make generate in libmupdf didnt resolve the error13:19.34 
tor8 did the command succeed?13:20.04 
Diemex tor8: The last lines are 13:23.55 
  ' ' ' ' GEN generated/gen_adobe_ca.h ; build/release/bin2hex generated/gen_adobe_ca.h resources/certs/AdobeCA.p7c ' ' ' ' GEN include/mupdf/pdf/name-table.h ; build/release/namedump resources/pdf/names.txt include/mupdf/pdf/name-table.h source/pdf/pdf-name-table.h13:23.57 
  Is there supposed to be a success message?13:24.14 
  Here is the output from running make generate in /libmupdf13:30.57 
  https://justpaste.it/13sj613:30.57 
icyjug hi i have a simple problem i want to do but cant find any solution13:31.15 
  i usually use pdftk to merge all my pdfs in a directory like this: pdftk *.pdf cat output output.pdf13:32.02 
  it works very well but it wont preserve any bookmarks13:32.37 
kens That's because you cannot preserve the bookmarks when you do that. You woul dhave to regenerate them.13:33.03 
tor8 Diemex: that does not look like a successful build13:33.05 
icyjug i also want to add the filenames of the files as bookmarks in the output13:33.17 
kens Then you need to make all new bookmarks13:33.31 
icyjug is this possible with gs?13:33.33 
kens Possible, yes, certainly, you can weite extensive pdfmarks to do it. Easy? No not at all13:33.52 
tor8 Diemex: http://pastebin.com/raw/iVFFpsRL that's what it should look like13:33.57 
icyjug actually i dont even need to preserve the original bookmarks, i meant that pdftk offers no support for bookmarks in general13:35.37 
kens If you want to simply add bookmarks then I believe ther eis a pdfmark operator for that.13:36.01 
tor8 Diemex: that "File not found - *.[ch]" message looks like something's not right13:36.04 
icyjug i simply want to merge the pdfs and add their filenames as bookmarks in the output13:36.12 
tor8 which 'make' are you using? we need gnu make13:36.17 
kens icyjug : well Ghostscript doesn't merge PDF files, it makes a new one based on the input, which is not quite the same thing.13:36.37 
icyjug kens i guess thats what pdftk does too13:37.17 
kens The pdfmark reference on page 26 has an example of creating an Outline (bookmark to you)13:37.17 
  icyjug : I suspect pdftk does not fully interpret the content streams teh way Ghostscript does.13:37.40 
  Likely it treats the objects as black boxes and simply reassemebles them with different numbering13:38.02 
  Ghostscript tears them apart to the lowest possible point13:38.13 
icyjug kens pdfmark is the manual of gs?13:38.30 
kens No.13:38.39 
  pdfmark is the Adobe defined PostScript operator for creating content in the output of a PostScript-to-PDF 'Distiller'13:39.05 
  You can find the pdfmark refrence somewhere on the adobe website13:39.23 
icyjug ok ill check13:39.38 
kens http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdfmark_reference.pdf13:39.50 
  page 26, Bookmarks (OUT)13:40.18 
  To the best of my knowledge the pdfwrite device will honour that pdfmark. You will have to check for yourself what it does with multiple inputs already containing pdfmarks.13:41.34 
Diemex tor8: I was using make from here: http://gnuwin32.sourceforge.net/packages/make.htm13:42.16 
kens Oh, and if I recall correctly, you will have to send the pdfmark after you process all the input.13:42.28 
Diemex It says it is gnu. I'm busy installing the linux subsystem and will retry with that13:42.43 
icyjug kens how could i adjust this solution http://stackoverflow.com/questions/7102090/combining-pdf-files-with-ghostscript-how-to-include-original-file-names for my case?13:53.48 
  i understand that bookmarks are kept in this postscript file13:54.08 
kens There are 3 answers there, which 'solution' are you talking about ?13:54.44 
icyjug but the automatization of the process seems too alien13:54.44 
  the third one13:55.08 
  that automates the process13:55.16 
kens Then you need to modify the pdfmarks, clearly13:55.32 
  There is no automation there, you need to create 'control.ps' yourself. That's the PostScript which contains the pdfmarks which write the outlines (bookmarks)13:56.17 
  Hmm, actually Ray did add code to do that, so there you go, its all there13:56.51 
icyjug so the third solution is not automated?13:57.03 
kens In a sense, there's a PostScript program which you can run which will do what you (seem to) want.13:57.52 
icyjug kens i guess this script doesnt preserve the original filenames right?13:58.55 
  it is using some kind of counters for the pages as i understand13:59.17 
kens The PostScript program itereates through the files matching a filesepc and write a boomark containing each filename.13:59.42 
icyjug kens i also guess it writes the bookmark in every next page?14:02.14 
  so it works only if original pdfs are of 1 page14:02.39 
kens You can't write bookmarks for 'every page', there is only one set of bookmarks per file.14:02.41 
icyjug i mean, the PN (PageNumber ?) of the bookmark is determined by a counter14:03.33 
kens The code you are pointing at will only work if each PDF is a single page yes14:03.40 
  You can do more sophisticated coding, as exemplified by the pdf_info.ps program which can determine the number of pages in a PDF file.14:04.13 
  So if you borrowed from that, you could create a PostScript file which contained appropriate deestinations for each bookmark.14:04.46 
  You would want to run that PostScript program *before* starting to process the PDF files, and then execute the assembled pdfmarks *after* finishing processing the PDF files14:05.27 
icyjug kens hmm pdf_info.ps? i cant see where that is..14:05.43 
kens in ghostpdl/toolbin/pdf_info.ps14:05.55 
chrisl You can get it direct from git on the web: http://git.ghostscript.com/?p=ghostpdl.git;a=blob_plain;f=toolbin/pdf_info.ps;hb=HEAD14:07.36 
kens icyjug : The final part of that answer runs each file and then looks at the current page number. SO the page number is bumped up by the number of pages that were in the file. SO that seems like a pretty complete solution to me.14:12.18 
icyjug man borrowing from this is too much for my level, i have no idea what this language is..14:12.20 
kens Its PostScript14:12.28 
icyjug i guess this could come in handy? usage: gs -dNODISPLAY -q -sFile=____.pdf [-dDumpMediaSizes=false] [-dDumpFontsNeeded=false] [-dDumpXML]14:12.30 
  22 % [-dDumpFontsUsed [-dShowEmbeddedFonts] ] toolbin/pdf_info.ps14:12.30 
kens As I said above, the final solution in the SO answer you pointed at looks like it will do the entire job of generating the pdfmark, including getting the page count correct for each bookmark14:13.19 
icyjug kens yeah i read that i am trying to fully understand the situation :D14:14.33 
kens But anyway, you can probably see that, as I previously said, while you can do this, its not easy.14:14.41 
icyjug kens you also said i could borrow from the pdf_info.ps, do you really mean borrowing code or is there a simpler way?14:17.06 
kens I meant borrowing code.14:17.21 
icyjug there was also a "usage" part in the comment on the top of that file14:17.59 
kens You can use PostScript to control Ghostscript and its a powerful means of doing so, because its a complete programming language.14:18.11 
  Yes, and the usage tells you how to use the file....14:18.21 
  But determining the number of pages in a PDF file is only part of what ot does. You would want to borrow that part14:18.53 
icyjug but it doesnt show a command for printing *onyl* the number of pages of a file...14:19.12 
  at least from what i see14:19.18 
kens I don't think I said ti did :-)14:19.35 
icyjug ah ok :D14:19.53 
  kens i can understand a bit of bash14:20.11 
  but here i have no idea where that part is14:20.22 
kens PostScript is not bash, more like FOrth14:20.23 
  Its a stack-based reverse-Polish notation language14:20.38 
  () = ( ) print print ( has ) print14:21.45 
  PDFPageCount dup =print 10 mod 1 eq { ( page.\n) } { ( pages\n) } ifelse = flush14:21.45 
  That's where the page count is printed14:22.01 
  And tnhis is where its determined and stored:14:22.35 
  "/dump { % (title) -> -14:22.39 
  " /PDFPageCount pdfpagecount def14:22.39 
  So you would need some PostScirpt like:14:25.02 
  (filename.pdfg) (r) runpdfbegin pdfpagecount == flush runpdfend14:25.02 
icyjug kens printed as in "echo" or as in "saved in an array"?14:25.04 
  that seems like an array to me..14:25.10 
kens printed as in echo, ie sent to stdout14:25.17 
icyjug (filename.pdfg) (r) runpdfbegin pdfpagecount == flush runpdfend14:25.57 
kens That should (I htink) print the number of pages on stdout14:26.16 
icyjug i guess this one + the entire script?14:26.16 
kens THat line just prints the number of pages in a given PDF file to stdout.14:26.33 
icyjug wow..14:26.53 
kens So you would need to run that line for each input file, adding the number of pages together as you go, and emitting a pdfmark for each filename using the current page count.14:29.05 
  Doesn't look har dfor a PostScript programmer, but I'm too busy to tackle ti right now14:29.42 
Diemex tor8: I was able to get the .so files using the lxss for windows. 15:08.02 
  Took quite a while as I had to redownload everything for linux 15:08.45 
  tor8: I copied the .so files from the /libs folder into my jni folder and copied the Java classes from /libmupdf/platform/java/src into my src folder15:31.29 
  Now I'm getting an error that the jni functions cannot be resolved Cannot resolve corresponding JNI function Java_com_artifex_mupdf_fitz_Annotation_finalize15:32.00 
  Okay. There are still compilation errors. -.- Running nm -g libmupdf_java.so shows that it has no symbols. I think I'm going to do it in a Ubuntu VM later15:43.01 
ray_laptop mvrhel_laptop: Ted sent around the logo to use. for Artifex -- or did you mean for your viewer app20:23.48 
 Forward 1 day (to 2017/02/23)>>> 
ghostscript.com
Search: