Printing to Laser cutter rasterizes images

Bug #630639 reported by Casey Borders
44
This bug affects 8 people
Affects Status Importance Assigned to Milestone
Inkscape
Fix Released
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.

Tags: printing win32
Revision history for this message
su_v (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
Revision history for this message
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.

Revision history for this message
su_v (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.

Revision history for this message
Casey Borders (thebeast-13) wrote :

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

Revision history for this message
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.

Revision history for this message
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?

Revision history for this message
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.

Revision history for this message
Casey Borders (thebeast-13) wrote :
Revision history for this message
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.

Revision history for this message
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.!

Revision history for this message
su_v (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
su_v (suv-lp)
summary: - printing rasterizes images
+ Printing to Laser cutter rasterizes images
Revision history for this message
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.

Revision history for this message
Alvin Penner (apenner) wrote :

second file:

Revision history for this message
Adrian Johnson (ajohnson-redneon) wrote :

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.

Revision history for this message
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.

Revision history for this message
Adrian Johnson (ajohnson-redneon) wrote :

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.

Revision history for this message
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

Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
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
Revision history for this message
Alvin Penner (apenner) wrote :

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

Revision history for this message
Casey Borders (thebeast-13) wrote :

How do I test this? What is bzr?

Revision history for this message
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

Revision history for this message
Kris (kris-degussem) wrote :

Marking as fix committed by lack of user feedback.

Changed in inkscape:
status: Incomplete → Fix Committed
milestone: none → 0.49
su_v (suv-lp)
Changed in inkscape:
assignee: nobody → Alvin Penner (apenner)
Revision history for this message
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.

Revision history for this message
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

Revision history for this message
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.

Revision history for this message
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

Revision history for this message
Jörg Eichhorn (jeichhor) 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.

Revision history for this message
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.

Revision history for this message
Jörg Eichhorn (jeichhor) 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.

Revision history for this message
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.

Revision history for this message
Jörg Eichhorn (jeichhor) wrote :
Revision history for this message
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

Revision history for this message
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.

Revision history for this message
Jörg Eichhorn (jeichhor) 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.

Revision history for this message
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?

Revision history for this message
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.

Revision history for this message
Alvin Penner (apenner) wrote :

forgot the attachment

Revision history for this message
Jörg Eichhorn (jeichhor) 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?

Revision history for this message
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.

Revision history for this message
Jörg Eichhorn (jeichhor) 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)
Changed in inkscape:
status: Fix Committed → Fix Released
Revision history for this message
Steve Morris (stevem57) wrote :

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

Revision history for this message
Alvin Penner (apenner) wrote :

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

Revision history for this message
J Matthew Gaskill (jmgaskill) wrote :

...working w/ Inkscape r13725 to drive Universal PLS6.60 Laser Cutter; as stated previously file->print does not create vectors which precludes "cutting" however file->print does generate the raster necessary to "engrave"

using Extensions->Export->Win32 Vector Print (with stroke sized accordingly small - 0.01mm) generates the vector output but mucks up the rastered portions

Ideally both vector and raster will coexist to drive both cutting and engraving from a single output. As a work around I can use file->print to create the raster image and perform the engraving operations on the laser then generate a separate vector only output to cut the parts.

can a solution be developed that combines the file->print raster with the Win32 Vector Print -- it would also be nice if this solution would also temporarily (or internally) resize the strokes to ensure vector output. Appropriately sized strokes (0.01mm) are difficult to see on screen while working in Inkscape so it is convenient to set these to 1px for editing.

...drivers for the laser cutter can be downloaded here and work well for testing even if you don't have a laser system connected: http://www.ulsinc.com/downloads/drivers/UcpInst-5.38.57.49.exe

Revision history for this message
Alvin Penner (apenner) wrote :

>>> can a solution be developed that combines the file->print raster with the Win32 Vector Print

just offhand, I can not see any easy way of doing this. The File->Print routine is written in C, while the Win32 Vector Print is written in Python, so they cannot easily be integrated. Also, the Win32 Vector Print is a Windows-specific solution that will not work on any other platform. (If I understand the situation correctly, it is not actually needed on other platforms.)

>>> it would also be nice if this solution would also temporarily (or internally) resize the strokes to ensure vector output

In this case the answer is a bit more optimistic. The Win32 routine was written in such a way that the Inkscape user could choose the stroke width appropriately for each individual object so as to get either raster or vector output (of the stroke only), depending on what you want for each object. If you had decided that you wanted everything to be written as vector, then you could modify the Python script to force everything to be done as vector output, regardless of the Inkscape stroke width. For example, go to line 67 of the file print_win32_vector.py in the directory \Inkscape\share\extensions\ and over-write the stroke value to be so small that you are guaranteed to get vector output. Then you could use any stroke width you like in Inkscape to make it easier to see, but still get the desired output.

Revision history for this message
J Matthew Gaskill (jmgaskill) wrote :

...thanks Alvin; great help -- while new to python I do have a bit of programming experience so I followed your suggestion and took a stab at it.

The crux of the problem with using Inkscape to generate files for ULS Laser Cutters is the lack of a "hairline" stroke designation (stroke-width=0 but still visible when rendered). Looking through the options natively available within Inkscape it seems that designating a stroke of "1 pt" more or less captures the intent (at least until "hairline" or " non-scaling-stroke" is implemented per SVG 1.2). We typically use units of "in" or "mm" to create geometry for the laser which leaves "pt" essentially untapped (as long as an equivalent dimension in a another unit not used).

Setting "vector" strokes to width=1 pt and adding the following lines to print_win32_vector.py after line 67 takes care of the rest:

if style['stroke-width'] == '1':
    stroke = 1

The next issue is the requirement to use the default printer; one would assume there must be a way to create a printer dialog of some sort then allow the user to select the printer she would like to use; perhaps along with the assistance of these resources:

https://mail.python.org/pipermail/tutor/2010-September/078869.html
https://msdn.microsoft.com/en-us/library/windows/desktop/dd144911(v=vs.85).aspx
http://www.pinvoke.net/default.aspx/winspool.GetPrinter

Revision history for this message
Henry (hkroker) wrote :

Thanks for a GREAT discussion regarding this topic and humble apologies for posting to an old thread.
Oddly I find myself travelling through the same valley of death years and versions after the end of this thread.
I have learned how to output vector to my VLS200 using the export method using the win 32 vector export.
I can also use the print function to output raster via the same VL200 Advanced driver. Both cases assuming that the VL200 Advanced printer driver is default.
I cannot seem to be able to output both with either method. Take the example of a box with a letter in it. Using the export technique I am able to print the vector box but not the letter. I use the print method and output the letter but not the box. My concern is alignment and scaling. On a simple object like this I can manage but on larger pages - say a label run I have problems.
I noticed that Mr Gaskill in post 45 asked the same question I need to ask. Am I doing something wrong when I try to output vector to the driver through the print mechanism? My stroke is set to 0.075px and the version I am using is Inkscape 0.92.2 (5c3e80d, 2017-08-06) Is there solution to do both?

Revision history for this message
Alvin Penner (apenner) wrote :

something you could try is to select all the text and perform Path->Object to Path, so everything is a path. Then use the vector print extension.

Revision history for this message
Rick-firefang (rick-firefang) wrote :

I've submitted a patch to win32 Cairo so that it properly sends anything smaller than the device's smallest unit size as a hairline (0.001" works) so you can print directly to laser printers now: https://lists.cairographics.org/archives/cairo/2018-October/028767.html

Of course, these lines are hard to see, so I've also created a patch in Inkscape for a new display mode that makes "hairlines" (anything smaller than half a pixel on screen) more visible: https://gitlab.com/inkscape/inkscape/merge_requests/365

Revision history for this message
Shane Madie (shanemadie) wrote :

Thank you so much, for such an amazing blog. I enjoyed every single part of it. I was looking for <a href="https://digit-it.com/services/">Raster to Vector</a> conversion services and then suddenly I saw Digit-it.com. Literally, I was amazed by their Raster to Vector conversion services and I also prefer everyone to at least give them a try once.

Revision history for this message
shahaib (shahzaibk) wrote :

Our embroidery designs are created using various computer programs. They are then transferred to the embroidery sewing machine. We have the capability of enlarging and shrinking the design - making it possible to use the same pattern on several items of different sizes, such as on towels and washcloth sets. For more information, please visit the URL at https://glitzdigitizing.com/embroidery-digitizing-services/

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

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.