| <<<Back 1 day (to 2017/07/30) | 20170731 |
deekej | chrisl: hello Chris, I have a small question about mapping of 2 current URW fonts to initial Core Font Set Level 2... Is P052 font family supposed to "replace" the old Palation font? | 13:33.26 |
| And therefore, the C059 should be mapped to "New Century Schoolbook"? | 13:33.54 |
| I was able to map the rest of the fonts, but I'm not sure about these 2 | 13:34.06 |
| chrisl: ah, nevermind, I have found the Resource/Init/Fontmap.GS file :) | 13:36.57 |
ml_ | hi i am struggling to get my ghostscript to work on one of the computers on powerbuilder | 13:47.45 |
kens | And in what way doe sit not work ? | 13:48.22 |
ml_ | it create empty pdf | 13:48.38 |
kens | And what back channel messages do you receive ? | 13:48.51 |
| Note; we don't support PowerBuilder | 13:49.04 |
ml_ | not sure new o it | 13:49.15 |
| ok | 13:49.28 |
kens | Well then how are you using Ghostscript ? binding to the DLL ? FOrking a process ? running from the command line ? something else ? | 13:49.46 |
| Also what version of Ghostscript, what word size, what operating system ? | 13:50.15 |
| Well that scared him off :-) | 13:51.37 |
jtth | @kens & @chrisl: about a week or so ago the possibility of altering ghostscript to convert the pdfs and store them in memory instead of it writing to files on conversion | 13:54.41 |
| is this still something you'd be interesting on walking me through? I'd like to give it a go | 13:55.03 |
kens | Umm, well we can try and help | 13:55.15 |
| Your best bet is probably to start with a device that does what you want, but writes to disk | 13:55.30 |
| I can't recall what you were trying to produce, JPEG ? | 13:55.48 |
jtth | Pdf to jpg yes. | 13:56.00 |
| Does Unity suffice as a device that allows me to write to disk? | 13:56.15 |
kens | RGB, CMYK or Gray output ? | 13:56.22 |
| I have no clue about Unity, WinRT, UWP or anythign like that stuff | 13:56.42 |
jtth | My guess would be RGB | 13:56.53 |
kens | In this case we are talking about a Ghostscript device | 13:57.00 |
jtth | I feel the same way Kens. windows runtime/uwp stuff is beyond foreign to me | 13:57.12 |
kens | FOr example the jpeg device is a GS device that writes RGB JPEG to isk, hpegcmyk is a GS device that writes CMYK JPEG etc | 13:57.26 |
| SO assuming RGB JPEG then we need to start with the jpeg device in GS | 13:57.46 |
jtth | Ok well I have a jpeg device working in Unity. Converts the pdfs to jpegs and stores each individually converted page into its own jpeg file on disk | 13:57.56 |
kens | I assume you are using the jepg device by setting -sDEVICE=jpeg | 13:58.17 |
jtth | No quite. Using this script, PDFConvert.cs - https://pastebin.com/jskvkbyz | 13:59.21 |
| Which I found via this project, https://www.codeproject.com/Articles/32274/How-To-Convert-PDF-to-Image-Using-Ghostscript-API | 13:59.29 |
kens | Seems excessively complicated.... | 14:00.11 |
jtth | I honestly couldn't tell you. About a month ago I was looking for a way to render PDFs in Unity. | 14:00.54 |
| That script claimed it did that. And with some tinkering it did do just that | 14:01.19 |
kens | But anyway, it still looks to me like its using -sDEVICE=jpeg, its just obfuxcated in the const strings | 14:01.24 |
jtth | GS_DeviceFormat = "-sDEVICE={0}"; | 14:01.50 |
| that> | 14:01.51 |
kens | Well sort of | 14:01.57 |
| It 'looks like' it replaces that {0} with 'somethign else' at some point, probably with jpeg | 14:02.16 |
| But I don't grok this language so I'm guessing | 14:02.29 |
| C# ? | 14:02.34 |
jtth | C#, yes | 14:02.39 |
kens | Well I'm going to give up on uinderstanding it, it looks like its using the jpeg device anyway | 14:03.51 |
jtth | Yeah it is | 14:03.57 |
| the script is supposed to allow the user to specify what output they want | 14:04.09 |
| when they call the function | 14:04.15 |
| But yes I am exporting to jpg | 14:04.21 |
kens | So look slike the devioce code i sin ghostpdl/devices/gdevjpeg.c | 14:04.46 |
chrisl | This is just for vewiing, isn't it? | 14:05.40 |
jtth | the functionality is purely to view a pdf | 14:06.00 |
kens | Then why not a Windows DIB ? | 14:06.13 |
jtth | what is that | 14:06.23 |
kens | Device Indepenedent Bitmap | 14:06.30 |
| You can draw it natively on a GDI canvas | 14:06.44 |
chrisl | I'd be tempted to use the gs display device | 14:06.55 |
jtth | again, don't know the acronym haha | 14:06.55 |
kens | Its all WIndows'y | 14:07.06 |
jtth | gotcha. | 14:07.10 |
| How does one use that | 14:07.16 |
kens | GDI is the Graphic Device Interface | 14:07.19 |
| There are Win32 calls for writing to it | 14:07.30 |
| Whether you can use *any* of this on a HoloLens I have no clue | 14:07.50 |
jtth | hololens has the windows 10 api, but limited as they didnt implement everything | 14:08.07 |
kens | But in any event, as chrisl says, the WIndows display device mechanism is (it seems to me) better suited for your needs anyway | 14:08.11 |
jtth | as well as windowsrt stuff | 14:08.15 |
kens | THe display device registers a callback which receives the rendered bitmap | 14:08.31 |
| Then it chooses what to do with it. In the case of Windows, its draws it in the Window | 14:08.48 |
| Its hte easiest way to get a bitmap in memory | 14:09.07 |
jtth | sounds like it might be the way to go. how does gs call/use t | 14:10.04 |
chrisl | https://www.ghostscript.com/doc/9.18/API.htm#display | 14:10.10 |
kens | wow, actually useful documentation.... | 14:11.12 |
jtth | The docs lead me to this windows implementation, https://www.ghostscript.com/doc/psi/dwmain.c | 14:15.28 |
kens | That's part of it, the actual bit that does the display is in dwimg.c, but the itnerface is in dwmain.c | 14:15.59 |
| Starts around line 100 | 14:16.10 |
jtth | o.o ... this is dense | 14:18.07 |
kens | The first thing that gets called is display_open() | 14:18.39 |
| Then display_size() | 14:19.10 |
| Which gets the width height format etc | 14:19.23 |
jtth | ughhh... any chance this dwmain.c is good to go and just needs the user to send a call. or do i need to run through the laundry list | 14:19.25 |
kens | Well you can try using the code as it stands | 14:19.51 |
| I've o clue if the HoloLens supports these old Win32 API calls that we use | 14:20.08 |
chrisl | I think it highly unlikely | 14:20.21 |
kens | I would agree myself | 14:20.34 |
| In which case you are going to need to implement the whole lot, and figure out how to render the bitmap tothe gadget | 14:20.52 |
| Actually it looks like the dwimg.c code creates a genuine Windows BITMAP, so you 'might' be able to use quite a bit of it. | 14:21.58 |
jtth | alright well that is beyond my comprehension of this code... my other alternative if this didn't pan out was to use FileOpenPickers and somehow select the PDF that way and feed it to the code I have working currently | 14:21.58 |
| but i have no idea how to use file pickers and i tried for weeks with no success | 14:22.27 |
kens | Can't help you with that, sorry | 14:22.36 |
jtth | Didnt think so. Are you saying dwimg.c/dwmain.c could be good to go now | 14:22.54 |
kens | Not directly, you could probably reuse a lot if it, but it depends on the HoloLens device | 14:23.17 |
| I have no idea how you render *anything* to it | 14:23.26 |
jtth | This is how I'm using the aforementioned PDFConvert script | 14:25.17 |
| https://pastebin.com/PicPBWWx | 14:25.18 |
| The main call thats important is, pp.Convert(CurrentHeadPath, CurrentPDFPath); | 14:25.57 |
| it creates the converted jpg imgs at the head path, from the pdf at pdf path | 14:26.37 |
kens | Not really, I know about that, I don't know how you draw anything. That seems to be done by something called a Texture | 14:26.39 |
| Which you then load into a RawImage | 14:27.01 |
jtth | I'm feeding the byte data into a Texture. Its just a component in unity | 14:27.05 |
| right | 14:27.13 |
| thats the only way ive been able to dynamically load images | 14:27.24 |
kens | Well, you could 'possibly' load the bitmap data into a RawImage, I've no idea really. | 14:28.03 |
jtth | Oop I had that mixed up. It detects if the pdf exists at the current headpath and creates the images using the pdf path | 14:28.35 |
kens | I guess its possible that the 'Texture' could read a bitmap instead of a JPEG. | 14:29.32 |
| In which case you could just pass the data in the img variable in dwmain.c, display_page() to the Texture device in your C# code. | 14:31.00 |
| BUt it seems like this is going to need a lot of work since that would be mixing C and C#, I can't believe that's going to end well | 14:31.27 |
jtth | I'm game to give it a shot | 14:32.39 |
kens | Have you looked at Ghostscript.NET ? | 14:32.49 |
jtth | How do I go about loading my pdf into the img variable in dwmain.c | 14:32.51 |
| Not sure, I'm gonna guess no | 14:33.10 |
kens | It might be easier if you did. For a start Josip understands C# which I do not | 14:33.31 |
jtth | Josip? | 14:34.01 |
kens | I don't know if it can return a bitmap in memory, but he would probably be the person I would ask to tackle this | 14:34.05 |
| Josip Habjan | 14:34.09 |
| The autor of Ghostscript.NET | 14:34.18 |
jtth | ah | 14:34.41 |
kens | OK here's the site: | 14:34.45 |
| https://ghostscriptnet.codeplex.com/ | 14:34.46 |
| Note that there's a viewer, so I'm going to guess he's solved the major part of your problems right gthere | 14:35.04 |
| Under other featires 'allows you to rasterise files in memory' | 14:35.29 |
jtth | Yes that caught my eye as well | 14:36.39 |
kens | Note Josip isn't an Artifex eomployee or anything, | 14:36.51 |
| He's completely independent but it looks like he has already solved most of what you are tyring to do | 14:37.09 |
| As far as getting rendered files in memory on a c# platform at least | 14:37.26 |
jtth | Ehh, well his Viewer is an executable program, so I have to believe that won't work in Unity or hololens | 14:37.52 |
kens | No, but its open source | 14:38.00 |
| And presumably uses Ghostscript.NET so you can look at what he's done to get the image in memory | 14:38.26 |
| He's usually pretty approachable I've found, and I think his expertise is going to be more helpful to you than we are, because we work in C, cross-platofrm | 14:39.02 |
| I'd certainly suggest you look at what it can do and see if you can use that, I'm guessing but I imagine it'll be easier to work with for you than trying to get Ghostscript and its devices to do what you want | 14:39.51 |
jtth | I'm confused on where exactly his viewer is used and why for | 14:39.52 |
kens | The viewer isn't (as far as I understand it) part of Ghostscript.NET. Its the same kind of setup as we use. The library is the important thing, the viewer (in our case the executable) is just a demo to show you how you can use it | 14:40.42 |
jtth | Well the thing is I've struggled through the gs for a few weeks and have it working, for the most part, its just that the hololens doesnt have access to create files in memory outside of a few known folders | 14:40.48 |
chrisl | So, use those folders? | 14:41.32 |
kens | His documentation has a 30 or so line example tht seems to rasterise to memory | 14:41.34 |
jtth | Chris, I wish I knew how. Every bloody example is using async/await methods to access the folder and I don't know how to just get the folder path as a string | 14:42.26 |
| Looks like this | 14:43.09 |
| StorageFolder storageFolder = KnownFolders.PicturesLibrary; StorageFile file = await storageFolder.CreateFileAsync("sample.png", CreationCollisionOption.ReplaceExisting); // Do something with the new file. | 14:43.10 |
| thats unhelpful. I apologize | 14:43.23 |
kens | jtth, from the Ghostscript,NET docuemntation: | 14:43.32 |
| _rasterizer = new GhostscriptRasterizer(); | 14:43.32 |
| _rasterizer.Open(inputPdfPath, _lastInstalledVersion, false); | 14:43.32 |
| for (int pageNumber = 1; pageNumber <= _rasterizer.PageCount; pageNumber++) | 14:43.32 |
| { | 14:43.32 |
| string pageFilePath = Path.Combine(outputPath, "Page-" + pageNumber.ToString() + ".png"); | 14:43.32 |
| Image img = _rasterizer.GetPage(desired_x_dpi, desired_y_dpi, pageNumber); | 14:43.32 |
| img.Save(pageFilePath, ImageFormat.Png); | 14:43.33 |
| Console.WriteLine(pageFilePath); | 14:43.34 |
| } | 14:43.34 |
| which looks like exactly what you are trying to do, except that it calls img.Save instead of 'something else' | 14:43.35 |
kens | coffees | 14:47.50 |
jtth | kens, so then how is this displayed | 14:47.55 |
kens | How is what displayed ? The output from the Rasteriser class ? It isn't, it gets written to disk byt the Image.Save | 14:52.25 |
| But I assume you could do something else with teh Image class | 14:52.36 |
| Evenif nnot, you cold look at Josip's impleemntation of his Rasteriser class to see how he rasterises to memory | 14:53.02 |
jtth | i dont know even know where his documentation is, let alone how to tinker with ghostscript and have any success | 15:11.17 |
kens | https://ghostscriptnet.codeplex.com/documentation | 15:11.43 |
| He returns a variable of class Image from _rasterizer.GetPage() Looking at teh class in the MSDN documentation I think you should be able to use that directly as a drawing argument to the Grpahics class for the HoloLens device | 15:12.44 |
| Drawing Images are dcoumented here: | 15:13.48 |
| https://msdn.microsoft.com/en-us/library/system.drawing.image(v=vs.110).aspx | 15:13.49 |
| Notice at the bottom of tht page is an example which Paints an image in response ot the Paint event for a Graphics Object | 15:14.38 |
| The Graphics class is documented here: | 15:15.14 |
| https://msdn.microsoft.com/en-us/library/system.drawing.graphics(v=vs.110).aspx | 15:15.14 |
jtth | My goodness. So it returns a variable of class Image, which I can then Paint using the Graphics class? | 15:16.52 |
kens | It looks like it to me, yes | 15:17.01 |
| I think you would use the DrawImage Method of the Graphics class though | 15:17.19 |
| I don't know how you ouwld obtain a suitable Graphics object for the HoloLens, I assume you can already do that though | 15:17.43 |
| So once you've obtained a Graphics object, you would rasterise the page you want using Ghostscript.Net, which would return you can object of type Image, which you would then paint by calling Graphics.DrawImage(Image, ...) | 15:19.19 |
| Bear in mind this is speculation on my part, none of this is exactly my area of expertise | 15:20.01 |
jtth | yeah I don't know how that would work, or if it would work. This variable of class Image, is it a bitmap | 15:23.08 |
kens | Its an Image class, which is a C# class | 15:23.31 |
| I have to guess its storing a bitmap in there somehow | 15:24.02 |
jtth | Ha, yeah I dont think thats going to work. I was hoping to fix the folder situation or integrate some sort of new solution like you were talking about by feeding in the rasterized (not even sure what that means) data into my rawimage | 15:25.07 |
kens | rasterized means the same as rendered. You take a resolution-independent vector description and create a fixed resolution bitmap from it. Its a commen term. | 15:25.59 |
| As I said, even if you don't want to use Josip's code, you can look at his implementation to see how he goes about creating a stored bitmap in the Image class. | 15:26.54 |
| Starting with a working solution seems to me much simpler than trying to code this up from scratch | 15:27.12 |
| Especially since, to be frank, we can't really help you much. The fact that Ghostscript is written in C and you need to use C# simply complicates matters further | 15:27.47 |
jtth | Gotcha. I'd never heard of it. Yes, I do have a working solution of sorts in Unity, just fails to create files in Hololens. Is his source code on the webpage you provided earlier | 15:27.48 |
kens | Yes, its all open source | 15:28.11 |
| You can download it all from the front page there | 15:28.27 |
jtth | Alright well then I will give it a look and see if I can find it | 15:29.57 |
kens | Specifically the source code page is: | 15:30.01 |
| https://ghostscriptnet.codeplex.com/SourceControl/latest | 15:30.01 |
jtth | It, being the bitmap in the image class | 15:30.17 |
kens | Huh ? | 15:30.40 |
| The code is a C# wrapper round Ghostscript, if you don't want to use it 'as is' then you can, as I said, look at the bits that the rasterizer class uses. Since tht gets a bitmap from Ghostscript in some fashion, it must do pretty much all of what you want | 15:31.49 |
jtth | Kens, I have no idea what I'm doing, lets just be clear on that. You were saying something about bitmaps being read in, or at least thats how I interpreted what you were saying about me reading in the byte data into my texture | 15:32.09 |
| Im trying to figure out what exactly I need from this, and I dont even know what I need/what I'm looking for | 15:32.40 |
kens | That's what you seem to be doing. If you really feel you need to continue in that mode then I suggest you look at how Ghotscript.NET rasterizer class retrieves the rendered bitmap from Ghostscript. THen, instead of creating an object of class Image from it, you can simply feed it to your existing code. | 15:33.24 |
jtth | look at how Ghotscript.NET rasterizer class retrieves the rendered bitmap from Ghostscript | 15:33.54 |
| ok. I will try to do find this | 15:34.03 |
| ... I can't even type. My apologies | 15:34.10 |
kens | is not in a position to complain about other people's typos | 15:34.25 |
jtth | If I get lost here, which I'm guessing, how should I contact Josip | 15:35.34 |
kens | Well, he watches the Ghostscript.NET stack Overflow tag | 15:35.58 |
| So you could ask a question tehre. I think the codeplex site has a forum too | 15:36.18 |
| https://ghostscriptnet.codeplex.com/discussions | 15:36.48 |
jtth | https://ghostscriptnet.codeplex.com/SourceControl/latest#Ghostscript.NET/Ghostscript.NET/Rasterizer/GhostscriptRasterizer.cs | 15:38.56 |
| Yeah not making much sense of it | 15:39.02 |
| I'll try an SO post with the GS.NET tag | 15:39.11 |
kens | Well it usees hte Viewer class to do the work | 15:39.27 |
| SO you need to look into that | 15:39.32 |
| And that's *really* complex | 15:39.42 |
jtth | ...and there in the lies the rub. | 15:40.00 |
kens | If you look at this: | 15:40.23 |
| https://ghostscriptnet.codeplex.com/SourceControl/latest#Ghostscript.NET/Ghostscript.NET/Viewer/GhostscriptViewer.cs | 15:40.24 |
| You will see its using the display device to return the bitmap | 15:40.32 |
jtth | looking | 15:40.41 |
| Where do you see that | 15:40.55 |
kens | About 45% of the way down | 15:41.10 |
| args.Add("-sDEVICE=display"); | 15:41.23 |
jtth | Ha ok so we've established that it is using the display device, but we don't know where the bitmap is so that we can access / obtain it | 15:42.16 |
kens | If you read through that code, somewhere it is registering callbacks with the display device. That's precisely what you need to do | 15:42.44 |
| The DisplayHandler is the code that receives the callbacks from Ghostscript | 15:44.31 |
jtth | Kens why does it feel like you know exactly what you're looking at/for and are just prodding me along until I stumble upon it | 15:45.19 |
kens | THat must be some kind of illusion, all I'm doing is reading someone else's code in a language which is highly unfamiliar to me | 15:45.45 |
| My only advantage is that I know how Ghostscript works, so I know that somewhere in here must be seomthign useful | 15:46.13 |
jtth | Ah. Well, I don't understand it as well. I'm going to draft an SO post in the meantime | 15:48.08 |
| https://stackoverflow.com/questions/45420632/use-ghostscript-net-to-write-and-view-converted-jpgs-to-and-from-memory | 16:08.11 |
| Very raw. Kens would you mind giving it a view to see if I included the entirety of what you understand I am trying to do? | 16:08.45 |
| Ha well he's gone! Kens if you see this log, I'd appreciate you giving it a look. You're far more knowledgeable when it comes to ghostscript and if there's any helpful details missing I'd trust you would know them. And if that being that case, I'd like to add any and all beneficial information to my post. | 16:49.24 |
| @chrisl are you here? | 16:53.50 |
AppleTODay | hello, I am trying to use Ghostscript inside my iOS app | 20:44.23 |
| I found a decent library file for 32 bit version | 20:44.39 |
| However I need to be able to support 64 bit for iOS 11 | 20:44.53 |
| Forward 1 day (to 2017/08/01)>>> | |