Reputation: 2092
i succesfully managed to add ability of displaying and printing svg to my app, to achieve that i've used https://github.com/vvvv/SVG. Library renders bitmap from provided SVG file, and thats ok as far as it comes to editing. Problem starts when it comes to printing. Files are printed with PrintDocument component to virtual PDF printer and when text sent to print is smooth, svg elements are bitmaps, and what i had in mind to benefit form that "high quality" look that svg provides. Is there any way to send SVG straight to printed page without transforming it to bitmap?
Upvotes: 0
Views: 1845
Reputation: 70681
One possibility: when you start printing, re-render the SVG into a new bitmap used just for the print job, where the bitmap size takes into account the actual print resolution for the job. That is, if you are printing at 300 dpi and want the SVG to print in an area 2x2 inches square (for example), the bitmap would be a 600x600 bitmap instead of whatever you used for screen display.
Note that this means your PDF will contain the high-resolution bitmap, making it much larger. This addresses the quality issue, but at the expense of file size.
Without a platform API that will actually draw an SVG to the Graphics instance for the print job (which I'm not aware of), it would be harder to keep the SVG data in a vector format.
That said, I didn't look at the library you're using closely, but if it's using a Windows API to render into a bitmap, that means there's probably an HDC (native Win32) or Graphics (.NET) instance being drawn to. You can use a metafile for the HDC or Graphics object instead of a bitmap, and that will preserve the vector nature of the rendering, which in turn might be preserved when you render it to the PDF printer driver (at that point it will be all up to the PDF printer driver, which is out of your control).
Upvotes: 1