Printing to Laser cutter rasterizes images

Bug #630639 reported by Casey Borders on 2010-09-05
36
This bug affects 7 people
Affects Status Importance Assigned to Milestone
Inkscape
Medium
Alvin Penner

Bug Description

I have an Epilog Zing Laser Cutter and when I try to print to it directly from Inkscape it rasterizes all of the lines instead of cutting thin lines. If I set the thickness of the line to 0.001" and save the file as a pdf and print from Adobe Reader it cuts as expected.

~suv (suv-lp) wrote :

Do you have reduced opacity or transparency set for the object/stroke style? Can you attach a sample SVG file that prints rasterized?

tags: added: printing
Casey Borders (thebeast-13) wrote :

I am attaching a svg that contains a 1" circle with no fill and a solid black stroke that is 0.001" thick. This should cut on the laser cutter, but instead it is rasterized and etches.

~suv (suv-lp) wrote :

When you print the SVG to file (in PostScript format, using Inkscape's print dialog), is the content of the PS file also rasterized? Maybe it's an issue with the driver not handling Inkscape's PostScript output correctly?

Printing the file to PostScript with Inkscape 0.48 on OS X 10.5.8 does not rasterize the content - the PostScript file contains only vector information.

Casey Borders (thebeast-13) wrote :

I don't have the option in the print dialog to print to file.

Alvin Penner (apenner) wrote :

- just writing to confirm that the print dialog no longer has an option to use postscript format. I believe this option was lost (on Windows) probably around the same time as the conversion to native Windows dialog boxes for import and export.

- you can however save as .ps using File->Save As... On Windows XP I get the attached (non-rasterized) file.

Alvin Penner (apenner) wrote :

sorry, pushed the wrong button...

- could you try printing this .ps file using some other utility like GSView, which comes free with Ghostscript. GSView has some interesting print options, like "Print to Postscript printer"

- also, as a loooong shot, on the Inkscape print dialog there is a tab called "Rendering". could you confirm that the "Vector" option is chosen on this tab?

Casey Borders (thebeast-13) wrote :

Sorry it took so long to get around to testing these, but they both etch as a raster instead of cutting like a vector. Here are two more files. In Inkscape I drew a 1" circle and did save as... and saved as an svg, then I did save as... and saved as a pdf. If I try to print the svg from Inkscape it etches the circle, if I print the pdf from Adobe Reader it cuts the circle.

Casey Borders (thebeast-13) wrote :
Jonathan Manton (jmanton) wrote :

We have had this problem for about 8 months as well (also with an Epilog laser cutter directly attached to a machine running Windows XP). We have to save Inkscape files as PDF, then open them in Acrobat Reader before they can be sent. Thin lines are rasterized when printing.

Casey Borders (thebeast-13) wrote :

Just wanted to write to confirm that saving as pdf and printing from Acrobat Reader is a valid workaround. It would still be really nice to be able to print directly from Inkscape.!

~suv (suv-lp) wrote :

Setting status to 'Confirmed' based on another user report / inquiry on the mailing list:
<http://thread.gmane.org/gmane.comp.graphics.inkscape.devel/38555>
(also described in <http://www.inkscapeforum.com/viewtopic.php?f=31&t=11779>: «(The company) ULS now says that Inkscape isn't sending vector data to the windows GDI printer interface. Even though the default setting under inkscape is to use vector (not raster) mode. »)

tags: added: win32
Changed in inkscape:
importance: Undecided → Medium
status: New → Confirmed
~suv (suv-lp) on 2012-05-07
summary: - printing rasterizes images
+ Printing to Laser cutter rasterizes images
Alvin Penner (apenner) wrote :

attached is a proposal to produce a vector graphics printout. This particular method will work only on Windows, but if I understand the various reports correctly, this rasterization problem occurs only on Windows.

To use this method, copy the two files print_win32_vector.py and print_win32_vector.inx into the directory \Inkscape\share\extensions\. Then use the Inkscape menu item Extensions->Export->Win32 Vector Print. This will print only to the default printer, so you may need to modify the default printer ahead of time. When you run the extension, the Printing Preferences dialog should appear, which will allow you to specify page size, etc. Then click OK to start the print job.

The printout will be vector graphics as long as the line width is 1 pixel or less in printer units, so in Inkscape you may need to use a line width of 0.05 pixels, roughly. For testing purposes I am using the printer driver for an 'HP Laser Jet 1200 Series PCL 5e' printer at 600 dpi. At small linewidths it produces pure HPGL as desired (which in this case is cubic Bezier splines). At larger linewidths it produces a 'rasterized' output. In the 'rasterized' output the original spline is replaced by a sequence of dozens of very short lines, similar to what one might send to a CNC machine. In addition, each curve is drawn twice, in the opposite direction, to produce an outline shape. This behavior does not occur at narrow linewidths.

Since I do not have access to a true laser cutter, any feedback would be more than welcome.

Alvin Penner (apenner) wrote :

second file:

I tested printing from Inkscape on windows by printing to a file (using a driver for a PS printer) and using the PDFCreator print driver. The output was all vector.

Last time I looked at Inkscape printing on windows it was using the gtk+ print API which in turn uses the cairo win32 printing surface. I suspect the problem with laser cutters is that the cairo win32 printing surface uses Geometric Pens for drawing lines (see http://msdn.microsoft.com/en-us/library/windows/desktop/dd183317%28v=vs.85%29.aspx). Geometric Pens are based on the PostScript drawing model where the pen width is fixed in logical units. This allows the line width to vary when the logical to device transform is not uniformly scaled on both X and Y axes.

According to this article http://libregraphicsworld.org/blog/entry/vinyl-cutting-on-linux-the-real-deal most cutters use HPGL. My limited understanding of HPGL is it does not support the PostScript drawing model. So for HPGL devices it would be better to use Cosmetic Pens where the pen width is fixed in device units.

The above article mentions some options for using cutters with Inkscape. Alternatively it may be possible to make the cairo win32 printing surface work with cutters by using Cosmetic Pens when the cairo user space to device space transform is a scale transform with the same scale in X and Y.

Alvin Penner (apenner) wrote :

yes, the geometric vs cosmetic pen explanation makes sense. When I first started looking at this problem, I assumed that the problem lay somewhere in the Inkscape code. So I did three different printouts and compared them: In each case, start with a very thin cubic Bezier curve. And in each case, print to a HP Laser Jet printer driver which uses HPGL.

case 1: save svg as pdf file and print using Adobe Reader. In this case the HPGL output is recognizable as being "vector". The HPGL output contains a command called 'BZ' which stands for Bezier, and the Bezier control points are readable in the HPGL file in exactly the same format as svg uses.

case 2: print svg directly from Inkscape. In this case, rather than calling it "rasterized", it might be better to call it "discretized". The Bezier curve has been converted to a multi-line with dozens of line segments. Further, each curve is stroked twice to form an outline, and further, there is a HPGL command present called FP which stands for 'Fill Polygon'.

case 3: save svg as pdf and print from Evince. This output was identical to Inkscape output, it was "discretized".

This is the point at which I gave up, since it does not appear to be specifically an Inkscape problem.

fwiw, in gdi32.dll the distinction between the above two types of output is made in a very simple way. If you define a pen width of either 0 or 1, then you will get "vector" output, as desired. If the pen width is larger than 1, then you will get "discretized" output. Unfortunately, the problem may be that this is done in printer units, which you may not know ahead of time. This is part of the reason why I abandoned the code search and tried a different tack.

In case 1 it looks like Adobe Reader detects that it is a very thin line and draws the line with a cosmetic pen. Cosmetic pens don't support caps and joins but if the line is 1 device unit wide this won't matter.

In case 2 and 3 it looks like when a geometric pen is used the stroke is converted to a path, flattened, then filled.

It should be possible to change the cairo win32 printing surface to perform a similar optimization as Adobe Reader. ie use a cosmetic pen if the line is 1 device unit wide and the user space transform is a uniform scale. Inkscape can use gtk_print_context_get_dpi_x/y to determine the printer device units.

Alvin Penner (apenner) wrote :

I guess my question is: at what point is gdi32.dll called, or where is it called from (from Inkscape or from cairo or from gtk)? I assume that it is inevitable that it must be called (on Windows).
     In order to use gdi32.dll the first call that is essential is a call to CreatePen and CreatePen by definition always creates a cosmetic pen.
http://msdn.microsoft.com/en-us/library/windows/desktop/dd183484(v=vs.85).aspx

Alvin Penner (apenner) wrote :

okay, I get it, or I think I do...
- in cairo-1.10.2
- in the file : cairo-win32-printing-surface.c
- in the routine : _cairo_win32_printing_surface_stroke
- in line 1289 it says : pen_style = PS_GEOMETRIC;
- somewhat later there is a call to ExtCreatePen(pen_style,...

from the context in which this is written, I am assuming that Inkscape cannot modify this behaviour.

Alvin Penner (apenner) wrote :

two quick comments:

1. I have confirmed that a geometric pen cannot be used to produce a vector output. As an experiment I modified the Python code above to use the call to ExtCreatePen to create a geometric pen. With a geometric pen it was not possible to produce a "Vector" output. Even at a linewidth of zero pixels, an ordinary (geometric) line was both outlined and also filled with an apparent linewidth of 1 pixel. Neither of these are acceptable, so I am going to abandon this line of enquiry which was to modify Inkscape code to do this, and concentrate instead on the Python approach.

2. A partially positive test of the Python code has been reported at Bug 966244. If I can respond to the remaining outstanding issue mentioned there, then I will post a new version there.

Alvin Penner (apenner) wrote :

- a new version of the Python proposal has been posted in Bug 966244

- could you try this and see if it helps?

Changed in inkscape:
status: Confirmed → Incomplete
Alvin Penner (apenner) wrote :

fix committed to bzr rev 11575,
could you test and see if it helps?

Casey Borders (thebeast-13) wrote :

How do I test this? What is bzr?

Alvin Penner (apenner) wrote :

you will need two files, print_win32_vector.py and print_win32_vector.inx, available from Bug 966244, comment 15, and comment 4. Alternatively you can get them from the Inkscape repository at:
http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/files/head:/share/extensions/

you will need to copy these two files into the directory \Inkscape\share\extensions\ and then in Inkscape you can use the (new) menu item Extensions->Export->Win32 Vector Print.
I am not entirely sure if this will run as-is on your machine because it depends on which version of Inkscape you are currently running, but give it a try, and if there are error messages then report them here, together with the version number of your Inkscape.

hth,
Alvin

Kris (kris-degussem) wrote :

Marking as fix committed by lack of user feedback.

Changed in inkscape:
status: Incomplete → Fix Committed
milestone: none → 0.49
~suv (suv-lp) on 2012-12-17
Changed in inkscape:
assignee: nobody → Alvin Penner (apenner)
Steve Morris (stevem57) wrote :

I have the same issue running Inkscape 0.48, windows 7 and print output to a Trotec Laser. All lines are being seen as raster data.
This does not happen using exactly the same settings, colours and line weights in Corel Draw so it looks to be the Inkscape output is all raster with no vector content.

Any updates would be greatly appreciated.

Alvin Penner (apenner) wrote :

have you tried the option Extensions->Export->Win32 Vector Print?

In order to run this you will need to get a development version, available at:
https://onedrive.live.com/?cid=09706d11303fa52a&id=9706D11303FA52A%21217

Steve Morris (stevem57) wrote :

Tried it using 0.48+devel r13487 and setting Extensions->Export->Win32 Vector Print

no change, still all raster even though the output only contains what should be cut vectors.

Alvin Penner (apenner) wrote :

did you specify a narrow linewidth? Just repeating some details from comment 12 above:

>> The printout will be vector graphics as long as the line width is 1 pixel or less in printer units, so in Inkscape you may need to use a line width of 0.05 pixels, depending on your printer resolution, remembering that Inkscape resolution is 90 dpi

Jörg Eichhorn (je-o) wrote :

hi alvin, thanks for your work.

same here. created black rectangle, with no filling and linewidth set to 0.5px
problem: the rectangle gets rasterized.

testsetup:
win7 64bit, Inkscape 0.91pre2 r13516

install epilog zing driver 9.0.1
https://www.epiloglaser.com/tech-support/zing-drivers.htm
setup as network driver.

when printing redirect to file.

when selecting option to print "only vectors" the print-file is almost empty
%1BIN;YP050;ZS050;XR2500;%0B
where a working print-file (generated using illustrator) contains coordinates
%1BIN;YP050;ZS050;XR2500;LTPU985,810;PD148,810,148,156,985,156,985,810,985,810;%0B

Can't use the "Export/Win32-Vector-Print" since the "Redirect to File"-option is part of the printer selection dialog, whcih does not appear.

Could you please check, if there is a regression? afair an older dev version worked for me, but can't reproduce.
The possibility to use inkscape for lasercutting would be a great opportunity for our fablab.

Thanks a lot.

Alvin Penner (apenner) wrote :

just two comments:

>>same here. created black rectangle, with no filling and linewidth set to 0.5px

It is highly unlikely that this stroke width will work. As stated above, the stroke width must be 1 pixel or less in printer units, not Inkscape units. Inkscape resolution is 90 dpi. This means that if your printer resolution is 1200 dpi, which is fairly typical, then you will need to specify a stroke width, in Inkscape, of about 90/1200 = 0.075 px.

second comment, the option for Win32 Vector Print is not part of the normal priunt operation which is File->Print. It is part of the Python extensions system, obtained on the menu at Extensions->Export->Win32 Vector Print. Can you confirm that this item exists? It was committed at rev 11575. Also, you will need to ensure that your default printer is the laser printer. Under normal circumstances you should not need to "print to file" since I am assuming that your printer is currently connected. However this is your choice to make, depending on whether or not you are connected.

Jörg Eichhorn (je-o) wrote :

sorry, i mussunderstood the px-setting.
now i've tried again with the minimum stroke width of 0,001mm - still no vector output, also tried the "usual" hairline value of 0,01mm - still the same

yes, the export->win32 vector print exists. but no, the printer is actually not connected.

Alvin Penner (apenner) wrote :

could you attach the svg file you are using. I will try it on my machine to see if it works.

Alvin Penner (apenner) wrote :

thanks for the file. I printed this to an output file using the printer driver for an HP Laserjet 1200 running at 300 dpi. The output is attached here. It is hpgl vector graphics as can be seen from the commands which it contains:

SC - scale
PU - pen up
BZ - Bezier Absolute

Alvin Penner (apenner) wrote :

Just for comparison purposes attached is the output I obtain when I change the stroke width to be 1 px in Inkscape. The file is larger and it does not contain vector commands in it. Instead it contains the command PE (polyline encoded) which indicates that the output will be rasterized.

Jörg Eichhorn (je-o) wrote :

attached the prn file using the zing driver, allowing raster+vector elements in the printer settings.
set resolution to 250dpi in printer settings - but thought the resolution in this driver is not be related to the vector part.

Alvin Penner (apenner) wrote :

yes, well, that definitely looks rasterized, I do not see any vector elements there. Unfortunately, I do not have access to the zing driver, do you know if it is available for free somewhere?

alternatively, do you have any sample output of the zing driver, where you know for sure that the output has some vector components?

Alvin Penner (apenner) wrote :

did one final test, with an Epilog driver. I downloaded an Epilog driver, Epilog Zing driver 9.01, for the device Epilog Engraver Zing. I ran it with the default settings, namely 500 dpi and Combined Job Type. The output I get is attached here. It appears to be pure vector hpgl as expected.

Alvin Penner (apenner) wrote :

forgot the attachment

Jörg Eichhorn (je-o) wrote :

your zing_combined.prn looks like gold - thanks for your effort.
could you please attach your svg?

this makes it hard.
which os are you using? are there external libraries used by inkscape? any settings in windows to check?
is there any debug output i could enable?

Alvin Penner (apenner) wrote :

I was using your file rect_elip.svg from comment 33.
OS is Windows XP, Inkscape rev 13549.
Have you been using the Python procedure Extensions->Export->Win32 Vector Print?
If so, that's all you need. I would double-check the printer driver settings, or try a different driver as a test.

Jörg Eichhorn (je-o) wrote :

Hi Alvin,

I confirm Export->"Win32 Vector Print" is working using Win7 64bit, inkscape r13516. setting linewidth to "0,001mm"
I've managed to capture a print file by changing the "Printer Port" to "File:".

Again, many thanks for your help

Bryce Harrington (bryce) on 2015-02-21
Changed in inkscape:
status: Fix Committed → Fix Released
Steve Morris (stevem57) wrote :

Is this fix included in release 0.91 for 32 bit windows?

Alvin Penner (apenner) wrote :

yes, it is on the menu item Extensions->Export->Win32 Vector Print

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers