Horizontal/Vertical print resolution @ 96 dpi

Xojo 2017R1 is now using Direct2D Printing API’s which now allows the margins to be respected. (broken in 2016R4 & R4.1, 2016R3 worked fine) Although, 2017R1 respects the margins now, it is not respecting the print resolution of the printer. Even though, in code, you tell the printer setup to use a maximum of 300dpi for horizontal & Vertical resolution, it will also be set to 96 dpi regardless, which looks absolutely horrible.

Feedback 47538 addresses this and has been verified by the Xojo programming staff. feedback://showreport?report_id=47538

My question is, do we know when a fix for this print resolution will be implemented? Will this be a point release like 2017R1.1 or 2017R2? Will it be sometime later than even that? In the meantime, I have to continue using 2016R3 in order for our main application to even be usable by our clients.

Thank you for any insight you can give, Xojo! :slight_smile: (really helps in planning our software development)

It’s not a bug; the Direct2D printing API always returns a virtual 96 DPI sized surface to its callers. I’ve marked the case as such.

This does not mean you can’t print nice looking, high resolution output though. We do this quite often. Please create a case with a private project attachment and we’ll see if we can help you update that project so the actual physical output is still at the printer-capable resolution.

Basically, I have a full 8.5x11 graphic created in code at 300 dpi that simply gets printed as a single graphics. It looks like crap when printed with 2017R1, but looks great when printed with 2016R3.

How is it possible to make this work in 2017R1? It’s just one single graphic that fills the page.

Try the included [Printing and Reporting/Printing/PrintingGraphics/PrintingPicture] example. You should notice a difference in output between low and high- high just takes a higher resolution image and scales it down, creating higher resolution output.

If you still want help with your particular project, attach it to a case and we’ll see what we can do. The basic idea is to get the resolution and width/height from the printer and layout/scale as appropriate. That concept should work across all platforms/printers.

Travis,

I do apologize, I must be an idiot. I’ve tried everything I can think of. But, I can’t seem to find anything like [Printing and Reporting/Printing/PrintingGraphics/PrintingPicture]

Any help in pointing me in the right direction would be extremely appreciated.

That’s the path under the “Example Projects” in your Xojo installation.

That makes a lot more sense. The documentation just was not coming up with anything, which was what my assumption was.

Travis,

Basically, my image is 8" x 10.5" @ 300 dpi and I was scaling the image using ScaleMBS to the parameters read from the print setup before it got drawn to the printer. Using 2016R3 worked great. However, since everything is perceived as 96 dpi, the pre-scaling was hacking the resolution down to that point, which looks like crap.

But, drawing the image to the printer, but scaling it within the DrawPicture parameters does allow it to print correctly with all of it’s glorious resolution, as intended.

Now, I’ve just got lots of code to got through to get all of my DrawPicture references to scale within the DrawPicture method instead of pre-scaling the image. (what a pain)

Thanks for pointing me in the right direction.

Printing has being allways an issue in XOJO, so, I decided to draw everithing to a picture and then just print one picture.

That worked even in the 2016.4, but now, even that is broken.

So, how can I print a picture at 600dpi in a special sice printer as did before?

Dim g As graphics
Dim ps As PrinterSetup

ps = New printerSetup

// set things to get printers maximum resolution
ps.MaxHorizontalResolution = -1
ps.MaxVerticalResolution = -1

If ps.pageSetupDialog Then
  g = OpenPrinterDialog(ps)
  If g <> Nil Then
    //g has the REAL Width and Height of the paper with the correct resolution
    g.DrawPicture(RenderPage(g.Width, g.Height), 0, 0)
    
  End If
  
End If

Thanks

I don’t print in Xojo any more. I use dynaPDFMBS to serve up a PDF to the user. He can print from his viewer if he wants to and he already has an archive.

Thats a good idea Dan, but, in my case, its a printing software, so…

Waste of money my upgrade las year if I had to use 2016.3 to compile.

See the examples next to your IDE
Example Projects > Printing and Reporting > Printing
There are several examples in there

[quote=335388:@Pedro Ivan Tellez Corella]That worked even in the 2016.4, but now, even that is broken.
So, how can I print a picture at 600dpi in a special sice printer as did before?[/quote]

Read what Xojo has to say:

So… the 96DPI you see is only a “virtual Paper/Layout” where you Layout what you’re going to print. The same applies to the other OS’es - you sometimes get a 300 DPI Graphics-layout, even if the printer can actually print 600 or 1200 DPI.

change your code to let’s say render at 4x the reported size (*) and draw this into the “virutal space”:

If g <> Nil Then //g has NOT the REAL Width and Height of the paper with the correct resolution //g has a virtual Width and Height of the paper, just to layout things Dim pictureToDraw As Picture = RenderPage(4 * g.Width, 4 * g.Height) g.DrawPicture(pictureToDraw, 0, 0, g.Width, g.Height, 0, 0, pictureToDraw.Width, pictureToDraw.Height)

(*) please note: the 4x bigger is just an example.
you might want to always render at 600 DPI (calculate the needed scale-factor using ps.MaxHorizontal/VerticalResolution).
and “squash” this 600 DPI Picture into the Graphics provided by the Printer. even if this “virtual paper” is 96 DPI and the code seems to “scale down” your 600 DPI Picture, the output will be whatever resolution the printer supports (certainly more than 96 DPI).

Unfortunantely we have a lot of printing using the DBReport in our xojo-apps, and since Version 2016r4.1 we had severe problems with the DBReport because of the changes in the Xojo-Update. We decided to switch back to the Xojo-Report, but the result is extremely unsatisfying for us developers and of course for our costumers. We always get low-resolution-prints, and we don’t know what else we can do…

We are programming for Windows 64Bit-Systems
We heard that the XojoScript still isn’t available for 64 Bit. Maybe this causes our problems?

What we tried was writing an Xojo-Skript that creates a printerSetup, setting the max resolution to 200 in the program code, doing a testprint and readout the setupString again. We then loaded this setupString when we do prints, it always worked well, but now it doesn’t. We always geht back an max resolution of 200, but an actual resolution of 96 or even just 72, depending on the printer we test. Just on a few printers, we get correct results. Of course this is anything but not a reliable solution we can offer our costumers.

So our code looks like this:

Dim ps As New PrinterSetup
'...
'readout the setupString from a textfile
'...     
ps.SetupString=setupString

// set the resolution to 200 DPI for printing again 
ps.MaxHorizontalResolution = 200
ps.MaxVerticalResolution = 200
 ...
 g=OpenPrinter(ps)
 ...
 rpt.Run(rs, ps) Then
 rpt.Document.Print(g)
 ...

We even tried this like in the mentioned example PrintingGraphics/PrintingPicture, but still get bad resolution prints.

 Dim pictureToDraw As Picture = New Picture(4 * g.Height, 4 * g.Width)
 g.DrawPicture(pictureToDraw, 0, 0, g.Width, g.Height, 0, 0, pictureToDraw.Width, pictureToDraw.Height)

From what plugin do you get the RenderPage-Function mentioned in the example above?

As an interesting fact, printing pdfs still works well. We think about being a little bit creative, to print the report to an pdf, then print this pdf again by an tool you can control by shell (like SumatraPDF). So is there a tool available where you can can print Xojo-Reports directly to a pdf-File? The RenderToPDF-Function of the DBReport doesn’t work because we use 64-Bit Systems (the perfomance is very bad even when printing very simple reports).

We need support very urgent. What else could we do?
Thank you very much!

The way our projects work is like this:

Code in Button1 gets the SetupString

                Dim ps1 As New PrinterSetup
		Dim tos as TextOutputStream
		Dim g1 As Graphics
		
		dim file1 as FolderItem=new FolderItem("setup.txt")
		tos = TextOutputStream.Create(file1)
		
		ps1.MaxHorizontalResolution = 200
		ps1.MaxVerticalResolution = 200
		
		if ps1.PageSetupDialog then
		else
				MsgBox("Setup Dialog canceled!")
		end if
		
		g1=OpenPrinterDialog(ps1)
		
		tos.Write(ps1.SetupString)
		
		tos.Flush
		tos.Close

Code in Button 2 sets the Setupstring and makes a testprint (the setupString from the file itself)

		Dim setup as String
		Dim ps2 As New PrinterSetup
		Dim g2 As Graphics
		dim file2 as FolderItem=new FolderItem("setup.txt")
		
		Dim tis as TextInputStream
		tis=tis.Open(file2)
		setup = tis.ReadAll
		tis.close
		ps2.SetupString=setup
		
		ps2.MaxHorizontalResolution=200
		ps2.MaxVerticalResolution=200

		g2=OpenPrinter(ps2)
		If g2 <> Nil Then
				g2.drawString(setup, 40,40)
		End If

DPI is always 72

You could try BKS Shorts. http://www.bkeeney.com/allproducts/bkeeney-shorts/ A number of Xojo developers are using it with great success. It comes with report designer and viewer components, allows you to export to graphics, PDF (requires MBS DynaPDF), and CSV and is resolution independent.

feedback://showreport?report_id=45971

Take a look at feedback://showreport?report_id=45971 and then since you have access to the beta, please test it out with your reports.

Since the question comes up repeatedly maybe a blog post is in order rather than just pointing to some examples? Or a webinar (are they dead?)?

Just an idea …

I noticed that you set the printer to 200dpi… I have found that if you set the printer to a resolution that it does not natiively support then it either defaults to 72/96 dpi or to the next lower native resolution