IRC Logs

Log of #ghostscript at irc.freenode.net.

Search:
 <<<Back 1 day (to 2016/08/28)20160829 
sebras is a little confused.07:01.45 
  it looks like the mupdf JNI code calls object methods, detect their exceptions, convert these to fz exceptions, which are later converted _back_ to Java exceptions.07:02.32 
  kens: morning!07:02.38 
kens morning sebras07:02.43 
kens can't help with MuPDF and especially Java though07:02.59 
sebras no, I know. I just need to vent a bit because this is so confusing. :)07:06.56 
  and it is quite difficult to know what is the "right" way of doing it, but converting exceptions back and forth just seems unnecessary.07:07.17 
kens sebras can you connect to the MuPDF repository anonymously ?07:07.25 
sebras kens: yes.07:07.39 
kens Someone claiming in a bug report that they suddenly can't use git: or http:07:07.46 
kens will try my checkout07:08.10 
sebras kens: do you have a bug number?07:08.37 
kens 69707207:08.59 
  http://bugs.ghostscript.com/show_bug.cgi?id=69707207:09.10 
sebras kens: thanks.07:09.23 
kens Well, its working for me07:10.22 
  I'll say so in the bug report07:10.31 
sebras kens: I can clone using git:// but not http://07:10.54 
kens Hmm, we do usually allow http: don't we ?07:11.12 
sebras kens: we do. could be due to my location.07:11.25 
kens How do you test http: ?07:11.41 
sebras git clone http://git.ghostscript.com/mupdf.git07:11.56 
kens OK one moment then07:12.01 
sebras that usually works well for me though, so I'm thinking it has something to do with my location.07:12.21 
kens Hmmmmm07:12.44 
  Not getting anything ehre07:12.54 
sebras kens: times out for you?07:12.55 
  kens: right.07:12.58 
kens Not timed out yet, but nothing happening either07:13.15 
  Looks like its knackered07:13.27 
sebras we usually don't support https though, but he doesn't seem to mention that.07:13.45 
kens No he just says git: and http:07:13.57 
sebras kens: so... restarting gitweb will be the last thing we ask marcosw to do? :)07:14.46 
kens has no idea07:14.59 
  Is that what drives it ?07:15.05 
  I'm assuming Robin could probably fix it, but of course he's still on vacation07:15.33 
sebras kens: to the best of my knowledge.07:15.38 
kens Ah actually07:15.46 
  It just said 'done' here07:15.56 
  And it did work, so http is OK too07:16.07 
  Though there's a remarkable lack of feedback while its working07:16.22 
sebras kens: oh.. let m try.07:16.25 
  kens: oh... watch -n1 'du -ks mupdf' actually shows that something is happening!07:19.27 
  kens: but I get about 8kbyte/s.07:19.37 
kens Hmm well that's nice to know. SO its working ofr you now ?07:19.46 
sebras kens: RESOLVED WORKSFORME?07:20.12 
kens I added to the bug thread that it seems to be working and suggested he try again07:20.16 
  I guess I'll clos eit yes07:20.28 
sebras kens: yeah, I was just not patient enough when there was no feedback.07:20.31 
kens I probably would have been the same, but chatting here (and looking at Stack Overflow) I had just left it07:21.04 
  OK he syas it works for him now, using his phone instead of the office network, so I guess its not our problem.07:47.06 
  Thanks for checking sebras07:47.19 
sebras kens: no problems.07:51.06 
  kens: hm.. if a constructor in java throws an exception and you do MyCoolObject o = new MyCoolObject(args); then it may fail with that exception, but _besides_ that particular exception that the constructor throws, can the instantiation fail with _another_ type of exception? Like ClassNotFoundException or similar.08:22.27 
  http://docs.oracle.com/javase/specs/jls/se8/html/jls-11.html#jls-11.2.1 is supposed to explain the answer, but that was _quite_ unreadable for a novice. :)08:23.44 
kens Beats me....08:24.20 
sebras kens: the JNI spec knew: InstantiationException and OutOfMemoryError08:28.21 
  kens: that means that even if you know that your constructor doesn't throw anything then a call new MyCoolObject(args) may fail with an exception _anyway_.08:28.58 
kens Hmm, curious....08:29.21 
fontdebug Hi, there, I've detected a little bug in mutool draw -F stext with bbox and spaces09:44.43 
  here my test pdf: http://digi.ub.uni-heidelberg.de/diglitData/v/mmm.pdf09:45.03 
kens If you think you;ve found a bug, best thing to do is open a bug report09:45.57 
fontdebug ok. Thanks.09:46.12 
HD|Laptop Hi all09:47.40 
  So, I have that Z2100 plotter (24 inch) connected to my mac, and now I want to print loooong pages on a paper roll09:48.04 
  Problem is, of course, that Photoshop and Adobe PDF don't really know the concept of a "paper roll" and need a fixed page size (whereas all I have fixed is the width, with 24 inches)09:48.38 
  Can I setup Ghostscript + CUPS in a way that I can plot loooong documents? No need for color accuracy09:49.17 
kens Can't speak for CUPS. You can print arbitrary media sizes with Ghostscript, but you *will* need to specify a media height09:49.53 
HD|Laptop That's really annoying to do on OS X, and I need to do it individually for each print09:52.31 
  Can't I have ghostscript take the input document, scale it up/down to width=60cm, and then rasterize the document and send it to the plotter?09:53.02 
kens I don't really understand your problem to be honest. You must be sending eithe rPDF or PostScript to Ghostscript, and to do that you will need to specify a media size09:53.10 
  How is Ghostscript supposed to know how much to scale the document, if you don't tell it the media size ?09:53.32 
HD|Laptop the input document height/width are known, as well as the target width, so it should be trivial to do the scaling09:54.00 
kens Certainly it is09:54.10 
  You can code this in PostScript, no problem09:54.17 
HD|Laptop I just don't want to mess around with a calculator and do math by hand ;)09:54.21 
kens You haven't stated the input format. In any event you will need to write some PostScript to do it.09:55.07 
HD|Laptop Ah, input format is PDFs generated by Photoshop, Indesign and friends09:55.44 
  Sorry.09:55.46 
kens OK so you need to look at the PDFFitPage code in pdf_main.ps (if i recall correctly)09:56.11 
  Ordinarily you would set up a media size using -dDEVICEWIDTHPOINTS and -dDEVICEHEGHTPOINTS, and set -dFIXEDMEDIA09:57.26 
  WHich would create a specific media size, and make it 'fixed' so that the PDF file can't change it.09:57.48 
  Probably the easiest w3ay to do this is to hook the 'setpagedevice' operator. Check the dictionary for a /PageSize entry. Figure out what scale facto you need to get the desired width. Work out the new PageSize using that scale factor. Replace the /PageSize entry with the new calculated size and set scale as required09:59.34 
HD|Laptop Hmm. The graphic design dudes have an expensive printer with a machine and some proprietary software, where you just drag your input files in, and you can scale etc. with a GUI10:01.24 
  I'd be fine with this too, can I use something of the gs toolkit to implement this?10:01.45 
kens And I imagine that costs money10:01.51 
  You can extract the media size from a PDF file using Ghostscript10:02.07 
  And then draw your graphic.10:02.19 
  When you figure ou the newly desired media size you can use the -dDEVICEWIDTHPOINTS, -dDEVICEHEGHTPOINTS -dFIXEDMEDIA and -dPDFFitPage switches to force gteh media size and have GS scale the requested media to the new size.10:03.24 
  THere are other ways to achieve this of course, PostScript is a programming language, so you can solve the same problem in multiple ways10:04.07 
HD|Laptop Sounds pretty complex10:05.11 
kens Its all easy enough for a PostScript programmer10:05.27 
  Google searches provide solutiosn:10:06.32 
  https://ma.juii.net/blog/scale-page-content-of-pdf-files10:06.32 
tor8 sebras: the java -> fitz -> java exception roundabouts are from robin's original JNI prototype. I've tried to remove the extra round trip in the code I've written and reworked.10:31.09 
  sebras: making IllegalArgumentException checked would be a nightmare to use, don't you think?11:36.24 
sebras tor8: yo!13:15.08 
  tor8: I need to talk with you about exceptions some more.13:15.29 
  are you up for it, or are you busy?13:15.43 
tor8 talk away13:15.58 
  did you see my comment above?13:16.02 
sebras reads the logs13:16.40 
  tor8: ok, then i'll try to remove more roundtrips if i can.13:17.12 
  they seem so unnecessary.13:17.17 
  tor8: well, IllegalArgumentExceptions are unchecked by default regardless of whether you declare them using "throws" or not.13:17.49 
tor8 yes, I was just reading your discussion with fred13:18.01 
  having to do a try/catch for exceptions that you know are impossible (because you're not passing illegal arguments) would be a major PITA13:18.29 
sebras tor8: right, so there is no drawback in declaring them, but also unchecked exceptions are supposed to be programming errors rather than something that the application can magically fix. consider e.g. off by one re: indicies in an array.13:19.02 
  yes, I agree.13:19.11 
  but it is not whether you declare exceptions with "throws" that makes client code _have_ to handle it, it is whether the Exception derives from RuntimeException (unchecked) or not (checked).13:19.52 
  tor8: this ties into why we made the choice to always throw Exception directly and TryLaterException, both of which do _not_ derive from RuntimeException which makes them checked.13:21.01 
  tor8: I'm not convinced that was a conscious decision.13:21.52 
riki hi13:22.45 
ghostbot Welcome to #ghostscript, the channel for Ghostscript and MuPDF. If you have a question, please ask it, don't ask to ask it. Do be prepared to wait for a reply as devs will check the logs and reply when they come on line.13:22.45 
tor8 sebras: correct.13:22.49 
riki is here somebody to help me with page orientation for ghostscript printing from C#13:23.31 
  ?13:23.38 
kens We can't tell you anything about C#, we can possibly help with Ghostscript. If your question involves a C# wrapper of some kind you'll probably have to directi it to the authour of the wrapper in the first instance13:24.24 
sebras tor8: that choice means that almost all calls should be declared "throws Exception, TryLaterException".13:24.49 
  tor8: and I'm not sure we want to do it that way.\13:25.01 
riki Ok, other qustion.. 13:25.30 
sebras can we use the code from fz_throw() to distinguish what exceptions we want to throw as checked and which ones we want to throw as unchecked perhaps?13:26.03 
  tor8: doesn't really resolve the issue with the declarations though as they are done at compile-time.13:26.20 
riki I have tried oll switches, and I need to page to be prindnted horizonataly, but it is still vertical..13:26.46 
  List<string> switches = new List<string>(); switches.Add("-empty"); switches.Add("-dPrinted"); switches.Add("-dBATCH"); switches.Add("-dNOPAUSE"); switches.Add("-dNOSAFER"); switches.Add("-dNumCopies=1"); switches.Add("-sDEVICE=mswinpr2"); //switches.Add("-sOutputFile=%printer%" + printerName); switches.Add("-sPAPERSIZE = a4"); //switches.Add("-dAutoR13:26.50 
tor8 sebras: right.13:27.01 
kens riki: Like I said, can't help you with C#13:27.13 
  You have not said what the input is, PDF or PostScript.13:27.37 
sebras tor8: so for now I'll do the naive thing and do throws on everything unless we can come up with a better approach.13:27.38 
kens I also very much doubt if you have tried *all* switches, Ghostscript has rather a lot.13:27.59 
tor8 this all depends on what we want to force the user of mupdf to do13:28.03 
riki Ok, so generaly, what is the setting to print page landsacape?13:28.17 
sebras tor8: oh, and do you mind if I use java.io.IOEXception for the buffer classes when unable to allocate bytearrays/whatever..?13:28.23 
kens You can set a fixed media size, by using -dDEVICEWIDTHPOINTS and -dDEVICEHEIGHTPOINTS and -dFIXEDMEDIA13:28.30 
sebras tor8: yeah, I realize, and I'm not sure myself. :)13:28.41 
kens Then use -dPDFFitPage or -dPSFitPage or -dEPSFitPage depending on the type of input13:28.55 
tor8 for now I'd make TryLaterException a subclass of RuntimeError and throw RuntimeErrors (which are unchecked) so we don't have the conflict of throwing undeclared checked exceptions from JNI13:28.56 
riki Ok, thanks.. 13:29.11 
tor8 sebras: I don't think much would be gained by having all java calls to mupdf have to catch exceptions explicitly13:29.55 
  most of the mupdf errors are unexpected runtime errors13:30.06 
  if we want to change that, we should go through and start classifying FZ_ERROR_GENERIC codes into something more useful13:30.30 
riki Do you think, if the PDF, does not have a a landsacpe orientation, it could be a porblem, even if the ghostscript seetings are fine?13:30.31 
sebras tor8: agreed.13:30.38 
tor8 FZ_ERROR_SYNTAX for invalid files, for one13:30.49 
kens riki your main problem is that you are using the mswinpr2 device I suspect.13:30.53 
  Are you trying to use media from a different tray or something ?13:31.19 
sebras tor8: though due to the... interesting nesting of fz_*() and pdf_*() then I guess all call will return the most devious exception anyway. despite having done a better classification. ;)13:31.24 
  tor8: FZ_ERROR_SYNTAX is definitely a good idea.13:31.35 
riki yes, switches.Add("-sDEVICE=mswinpr2");13:31.36 
  do you know how to fix it?13:32.06 
kens Yes I see that, but my question was whether you are trying to use media from a tray other than the printer default ?13:32.10 
tor8 sebras: agh. something in the past month or two has broken 'mutool create'13:32.20 
sebras tor8: oh? how so?13:32.34 
tor8 pdf_add_image, line 313 uses doc->resources->image ... but for some reason doc->resources is NULL nowadays13:33.07 
sebras tor8: I never notice that because I rarely use mutool create. so i probably messed up.13:33.12 
riki It is set as defualut printer for windows..13:33.17 
sebras tor8: oh, that one!13:33.20 
  tor8: I have been debugging that one.13:33.24 
  tor8: wait...13:33.29 
riki It prints horizontali without problems..13:33.39 
kens riki I'm not asking about the *printer* I'm asking about the media. Are you trying to use something other than the default tray ? Landscape suggests you are, most printers default to portrait13:34.01 
  riki I don't think I understand your problem. Why do you want to print landscape ?13:34.33 
sebras tor8: bug 69689213:34.43 
tor8 right. when did we use to init the resource tables before that, and why was it removed?13:36.00 
riki hmm, good point, do you think, if the printer has a default setting for horizontal printing, it woould not print it verticaly, even if it set in ghostscript..13:36.08 
sebras tor8: has it been?13:36.17 
kens riki I have no idea what you are talking about13:36.19 
  What is hte format of the input file ? (PDF or PostScript ?) WHat is the media of the input file (size and orientation) ? What is the media of the printer ?13:37.21 
sebras tor8: that bug tripped font handling in annotations which needed doc->resources to be != NULL before the call in pdf_create_document() to init doc->resources happened.13:37.39 
  tor8: but I note that you mention pdf_add_image now..13:37.49 
tor8 sebras: yeah. in a completely different use case.13:38.48 
sebras tor8: sorry for the noise.13:38.57 
tor8 the one you ran into was a pdf being *edited*13:38.58 
  this is for a pdf being created from scratch13:39.07 
  when creating a pdf from scratch, we may never create a pdf device13:39.25 
riki OK, I just need to print PDF landscape, PDF.. So do not think about C#, just what is the setting for that, I already tried all from http://stackoverflow.com/questions/3089773/how-to-change-page-orientation-of-pdf-ghostscript-or-postscript-solution-neede13:39.40 
sebras tor8: not really edited, the annotation changed state itself, but yea.13:39.42 
tor8 I think the right solution is to init the tables when both opening a PDF, and creating one from scratch13:39.48 
kens riki there is no 'setting for that'13:39.57 
riki Ok, so it takes a PDF and print it as it comes?13:40.37 
kens And you are complicating the issue by using the mswinpr2 device and talking about a physical printer13:40.41 
  OK so you are talking about PDF input, at last an answer.13:41.03 
  The PDF requests a specific media size. Ghostscript will (normally) select from its available media and render teh content of the PDF to that media.13:41.32 
sebras tor8: right, because mutool create doesn't prepare a display list and feed it through a pdf device to create the pdf13:41.34 
  tor8: I didn't think about that case.13:41.40 
  tor8: and obivously neither did rjw13:41.56 
kens So normally, because the media is effectively infinte (file format output), the resulting image file will be the orientqation of the input, and sized according to the size of the media and the resolution requested.13:42.25 
  That can be altered in a variety of ways13:42.36 
  However, you are also talking about the mswinpr2 device, which is dependent on the characterisitics of a physical printer, as described by a device driver in Windows.13:43.07 
  And that varies depending on the printer and the device driver.13:43.18 
riki Ok, guys, yes, this is a first time I am using this library and so I'm not such a expert as you are about this..13:43.29 
kens So I cannopt sensibly answer your question unless you give me more information13:43.32 
  So here are the questions in little pieces:13:43.50 
  1) What is the input format ?13:43.55 
riki wait a second i will be right back..13:44.46 
sebras tor8: re: exceptions: I have tested throwing 2+ exceptions from a JNI-method and only the last one is reported (no surprises)13:45.11 
  tor8: re: exceptions: I have tested throwing exceptions from an object constructor and the finalizer is called (also not very surprising)13:45.49 
  tor8: re: exceptions: I have tested causing the new operator to end up with OutOfMemoryError and also in this case the finalizer is called (-"-)13:46.25 
tor8 serbas: yes, the constructor operates to initialize an already created object and any exceptions halfway through initialization would want the finalizer to run13:47.15 
sebras tor8: besides OutOfMemoryError the new operator may throw InstantiationException when the class you try to do new on is abstract or an interface.13:47.15 
  tor8: right, but that means that we have problems if we do obj = NewObject(..., cs) if (!obj) fz_throw_java(); else fz_keep_colorspace(cs); because the keep is too late and so the finalizer which _will_ run will actually drop things that were never kept in the first place.13:48.39 
  tor8: in the case of OutOfMemoryError or an exception thrown by the constructor.13:48.58 
  tor8: if the JVM throws InstantiationException due to the code doing new on an abstract class or an interface then I can't imagine the finalizer being run (would there even be one?) though. since we have no abstract classes or interfaces I ignore this type of error right now.13:50.18 
  tor8: my immediate fix is to move the keep to _before_ the call to NewObject() then the finalizer will do all the cleanup.13:51.00 
tor8 right. so then we should call obj = NewObject(..., fz_keep_colorspace(cs))13:51.56 
  so, to_Annotation() etc should be fixed to keep before calling the constructor?13:52.45 
sebras tor8: we could, but those lines are awfully long already so I prefer to have a local variable but the order would be the same.13:52.45 
  tor8: indeed.13:52.52 
  tor8: I have the patches locally and I have tested them and it seems to work fine.13:53.07 
tor8 so the if (jobj == NULL) lines, what do they accomplish then?13:53.15 
sebras tor8: which one?13:53.30 
tor8 fz_keep_annot(); return NewObject();13:53.33 
  the ones after the NewObject call that just cals fz_throw_java13:53.48 
sebras right.13:53.54 
tor8 oh wait, no, those are throwing *fitz* exceptions13:54.01 
sebras tor8: they detect if the NewObject() call threw OutOfMemoryError basically.13:54.08 
tor8 that should be if (ExceptionCheck) ?13:54.13 
sebras tor8: they are... these are the ones that become roundtrip Java->fz->Java exceptions.13:54.31 
  tor8: well... it depends.13:54.39 
tor8 sebras: right. because they are calling java stuff inside a fz_try context that does more complicated stuff13:55.06 
sebras tor8: we want to detect in the caller to to_Annotation() that it failed some how. previously we'd done that through fz_throw() but I'm thinking that it may work to check for NULL on the return value.13:55.28 
  tor8: indeed.13:55.36 
  tor8: so actually since we do fz_throw_java() we _hide_ the original error by overwriting it.13:56.24 
  exception.13:56.27 
tor8 Page_getAnnotations, I'd probably toy with splitting that big fz_try and make individual calls to fitz be wrapped in fz_try, and not mix fitz and java calls13:56.27 
sebras tor8: yeah, now that I have a better grasp of these exception thingies I concur.13:57.07 
tor8 most of the other to_Xxx functions are called in the device functions (that are called from fz_run_page to call into a java device)13:57.35 
sebras tor8: I assume that if e.g. NewObject() throws OutOfMemoryError we don't want to overwrite that exception with an exception of our own, right?13:57.52 
tor8 nope, we just want to bail13:58.11 
sebras tor8: yeah, so quite possibly you could copy the code from to_ColorSpace() in to that non-device callback code. I think that makes more sense.13:58.55 
tor8 the to_Xxx_safe calls are ones that are designed to not round-trip exceptions because they're not being called from the fz_java_device13:59.27 
sebras tor8: still hadn't reallized that, but that makes sense.14:00.08 
riki hi, I set a default paper orientation, for my HP printer to landscape, and it works..14:00.18 
tor8 sebras: it all depends on who is calling who14:00.28 
sebras basically fz_throw_java() should only be called inside device-callbacks.14:00.30 
riki it prints correctly..14:00.35 
sebras tor8: yes, I know.14:00.37 
tor8 fz_java_device methods are called from fitz, so want to get fitz exceptions14:00.43 
  same with the callbacks in Text_walk, and Path_walk, and other iterators14:00.55 
kens riki well that was the point I was trying to get to14:00.57 
riki but, mi boss said, it is not a soulution, it is a hack..14:01.19 
sebras tor8: right.14:01.19 
tor8 getAnnots and getLinks are the new unexplored territory14:01.21 
sebras tor8: I'll get back to those two.14:01.34 
tor8 where we are doing mixed fitz/java calls14:01.35 
  to flatten a linked list into a java array14:01.52 
sebras tor8: I also found some android page that mentions that you cannot trust the return value from CallObjectMethod() unless you _first_ check if there's been an exception. which we need to do inside fz_throw_java() since it calls some method.14:02.24 
kens riki it is not a hack. THe mswinpr2 device does not alter the settings of the printer, *unless* you opt to open the pritner dialog and reconfigure the printer. It uses the default settings of the printer. THis is by design. Note that the mswinpr2 device is absolutely *not* intended as an unattended print server.14:02.34 
riki it means, this software wil be installed on thousends of computer, an we can hardly fore eac user to set the printer manualy for landscape..14:02.43 
kens If you want that you can of course create it using Ghostscript, but you will have to do some work.14:02.50 
  riki Are you aware that Ghostscript is AGPL sopftware ? Are you planning to release your software under the AGPL ?14:03.15 
riki This solution is commercial, does it mean, we cant use ghostscript?14:05.07 
kens You owuld need a commercial Ghostscript licence from Artifex14:05.19 
riki Ok, I have to ask my boss..14:05.43 
  Ok, boss said, we will probably byy it, but has question, what are this settings for:14:14.00 
  dAutoRotatePages=/None -- retains orientation of each page; * -dAutoRotatePages=/All -- rotates all pages (or none) depending on a kind of "majority decision"; * -dAutoRotatePages=/PageByPage -- auto-rotates pages individually. 14:14.33 
kens -dAutoRotatePages only affects the pdfwrite device14:14.56 
riki it has nothing to do with printing to physical priner?14:15.02 
kens No, nothing, it is specific to production of PDF files14:15.15 
  THat's why its covered in the pdfwrite-specific section of the documentation14:15.54 
riki ok guys, thank you a lot, I really appreciate you help... 14:16.26 
kens By the way, if you are using Ghostscript.NET I believe you will need a licence for that too14:16.43 
riki https://github.com/mephraim/ghostscriptsharp/blob/master/MIT-LICENSE.txt14:18.34 
kens OK that's Ghostscriptsharp, not Ghostscript.NET14:18.46 
  Ghostscript itself is AGPL, so you would need a commercial licence if you intend to seel it.14:19.46 
riki Ok, I will let my boss known about it14:20.32 
sebras http://xkcd.com/1726/ indeed.14:37.11 
  tor8: ok, thanks for the discussion. I'll sleep a bit now and continue on github/wip tomorrow.14:38.50 
ray_laptop riki: still here?17:01.24 
  riki: if you set -dFIXEDMEDIA and -dFitPage then gs should rotate pages for the best fit to your paper size (-sPAPERSIZE=a4) -- the printer should remain set for 'portrait'. GS will take care of rotating input pages and scaling as needed to fit the output (portrait a4)17:03.03 
  riki: if one of the pages in the input to GS happens to be landscape i.e., 842 x 595, then GS will rotate it for you.17:05.40 
 Forward 1 day (to 2016/08/30)>>> 
ghostscript.com
Search: