Log of #ghostscript at irc.freenode.net.

 <<<Back 1 day (to 2021/03/21)Fwd 1 day (to 2021/03/23) >>>20210322 
vamsi Hey! -- I am new to ghostscript. My usecase is to leverage ghostscript for merging pdf files in a browser. So, I want to compile ghostscript targeting it to WASM and reuse the compiled target in browser for merging pdf files. Can you guys please help me with pointers to the specific project i need to look into. I googled around to see if anyone05:43.28 
  tried the same so that i can take it forward. But i did not find many pointers. Could you please point me to any blog/repo which tried doing similar/related thing ?05:43.29 
artifexirc-bot <KenSharp> vamsi firstly Ghostscript (and the pdfwrite device) don't merge PDF files. If given a bunch of PDF files as input it will produce a new file as output where the vusual appearance should be the same as the input. The content of the files will be different, potentially very different. This is documented https://www.ghostscript.com/doc/current/VectorDevices.htm#Overview08:06.59 
  <KenSharp> I am unaware of anyone attempting to create a WASM version of Ghostscript, I doubt you will find much to help you.08:07.44 
  <KenSharp> Ghostscript isn't built using a project, it uses makefiles, both on Linux and Windows. The Windows project calls out to nmake to build the binary.08:08.19 
  <KenSharp> I've absolutely no clue how you would go about targeting a WASM virtual machine with that. I understand theoretically you can target WASM from C source, and Ghostscript is written in C. You should probably also be aware that Ghostscript uses a number of 3rd party open source libraries, such as zlib and OpenJPEG, which would obviously also need to be ported to a WASM target08:10.54 
  <KenSharp> Thirdly, you should check the AGPL license to satisfy yourself that your usage is compatible with the terms of the license.08:11.26 
  <Robin_Watts> I think it should be possible to build gs using wasm - I mean, we get away with it for MuPDF.10:37.55 
  <Robin_Watts> We share (broadly) the same set of dependencies in both projects.10:38.25 
  <KenSharp> I'm not saying its not possible, just that I have no idea how to go about it 🙂11:16.48 
  <chrisl> It *is* possible to build gs with the WASM cross-compiler, but I never got it to run successfully11:17.44 
  <KenSharp> Not encouraging....11:18.28 
  <chrisl> I only looked at it during a quarterly meeting....11:18.55 
  <Robin_Watts> @chrisl i/o would be the tricky thing, yes.11:27.56 
  <chrisl> @Robin_Watts I think I used the "GS_NO_FILESYSTEM". I assumed that stdio would still work.11:29.12 
  <Robin_Watts> I think that might be hopeful 😦11:29.53 
  <chrisl> So, no way to communicate with the outside world? Seems like a rather pointless blob, then11:30.29 
  <Robin_Watts> You have to communicate with the calling environment in some special manner.11:33.50 
  <Robin_Watts> MuPDF ends up feeding blobs of data as 'images' out to into the DOM.11:34.27 
chrisl If the wasm implementation of libc isn't doing that for stdio in some fashion, then I would says it's broken11:34.57 
artifexirc-bot <KenSharp> I can't szee anhy way that is going to work with pdfwrite, which needs to write temporary files.11:35.14 
  <Robin_Watts> @KenSharp Indeed.11:35.21 
  <KenSharp> Actually... It would be possible to set the temp dir to the %ramfs% file system, and then the temporary files would be written to memory. That would 'work' at the expense of using large amounts of memory. Still need to get the output file out somehow though.11:39.01 
  <chrisl> @KenSharp Given that it would be running in a browser "large amounts of memory" has a totally different meaning to what it means for us!11:40.40 
  <KenSharp> LOL11:41.06 
  <chrisl> With brave currently reserving 36.4Gb of address space on my system, right now11:41.40 
  <KenSharp> Remember that we write the image output 3 ways, uncompressed, and compressed with two different image schemes.... So potentially we really do mean a lot of memory11:41.46 
  <KenSharp> Depending on how many images of what area and resolution are embedded in the input11:42.11 
  <RayJohnston> does this work with the functions GS uses to create unique temp files?15:07.42 
  <KenSharp> I believe so, if you set TEMPDIR (or whatever its called). I have not tested it. There seems little point because the intention was to use pdfwrite, and there would need to be some way to get the final PDF file out.15:08.39 
  <RayJohnston> is that for pdfwrite?15:08.49 
  <KenSharp> Yes15:08.55 
  <KenSharp> When using the 'compression chooser'15:09.02 
  <KenSharp> I forget the name of the parameter15:09.08 
  <KenSharp> AutoFilterImages, that's it15:09.18 
  <RayJohnston> OK. I was going to say that the clist logic has different schemes for images, but only writes the image once.15:09.51 
 <<<Back 1 day (to 2021/03/21)Forward 1 day (to 2021/03/23)>>> 
ghostscript.com #mupdf