Export / Print to pdf: Is there a way to get a vector print?
Forum rules
and Helpful information
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help
Also, be nice to others! Read the FreeCAD code of conduct!
Also, be nice to others! Read the FreeCAD code of conduct!
Export / Print to pdf: Is there a way to get a vector print?
Whether I export or print my Drawing to pdf ... I get a raster image.
Disadvantages:
Text no longer editable (since font vectors projected as rasters) (although I could do an OCR, but that's a detour)
Extremely large files (What a waste of memory)
Low printing quality, so long as files should remain sufficiently small for handling
Is it not a pity that conversion to pdf implies such a loss of quality?
Is there a way to get a vector print?
Thx
Roland
Disadvantages:
Text no longer editable (since font vectors projected as rasters) (although I could do an OCR, but that's a detour)
Extremely large files (What a waste of memory)
Low printing quality, so long as files should remain sufficiently small for handling
Is it not a pity that conversion to pdf implies such a loss of quality?
Is there a way to get a vector print?
Thx
Roland
Re: Export / Print to pdf: Is there a way to get a vector print?
Found my own solution.
For those who are interested:
Combo View: Select Page for exporting
File, Export, Type: Drawing (*.svg, etc)
Open exported file in Inkscape. From there do not print to pdfprinter, but rather Save as ... *.pdf.
Bingo.
Result:
10 times smaller files than with FreeCad File, Export PDF.
All the other advantages of a vector print
Is there a shortcut for this procedure inside FreeCAD ?
Greetz,
Roland
For those who are interested:
Combo View: Select Page for exporting
File, Export, Type: Drawing (*.svg, etc)
Open exported file in Inkscape. From there do not print to pdfprinter, but rather Save as ... *.pdf.
Bingo.
Result:
10 times smaller files than with FreeCad File, Export PDF.
All the other advantages of a vector print
Is there a shortcut for this procedure inside FreeCAD ?
Greetz,
Roland
Re: Export / Print to pdf: Is there a way to get a vector print?
Good question. I think it comes down to Qt support for printing out PDF files by using vector back-end. Quick Google search indicates this functionality isn't provided in Qt by default therefore probably custom solution would need to be coded (probably a lot of work would be needed). Anyway will leave that up to developers.
As for:
As for:
Probably custom macro could be the solution (to automate the printing to PDF by using Inkscape (command line) from FreeCAD).Is there a shortcut for this procedure inside FreeCAD ?
Re: Export / Print to pdf: Is there a way to get a vector print?
I created a drawing and exported it to SVG file and after on Ubuntu:
This procedure works quite good based on first observations. Probably there is a way to make this more automatic. By getting SVG image from drawing page /tmp location and making subprocess call to Inkscape.
Basically in the end it could be done as it is done for POV-Ray support offered in FreeCAD. If user would set Inkscape path in Preferences FreeCAD would use Inkscape to create PDF file instead of default option that puts rasterized image in PDF file.
Code: Select all
inkscape -f FILENAME.svg -A FILENAME.pdf
Basically in the end it could be done as it is done for POV-Ray support offered in FreeCAD. If user would set Inkscape path in Preferences FreeCAD would use Inkscape to create PDF file instead of default option that puts rasterized image in PDF file.
Re: Export / Print to pdf: Is there a way to get a vector print?
OK i created Export PDF macro. It uses Inkscape to do the SVG to PDF conversion. Customize ToolsBar instructions can be used to add tool button in Drawing WB and therefore to be able to use Export PDF macro with ease when needed.
What does it do:
It exports drawing page to PDF file using Inkscape. Instead of bitmap image inserted in PDF file elements like text are searchable and exported PDF file size can be smaller when the drawings do not have big number of elements in it.
How to use it:
First thing the users needs to check is if the path to Inkscape executable is set correctly. It should work out of the box on Ubuntu (i didn't test the Export PDF macro on Windows but the path to Inkscape executable needs to be changed).
Code: Select all
import os
import subprocess
from PySide import QtGui
obj = FreeCADGui.Selection.getSelection()[0]
# Path to Inkscape executable
inkscape_path = "/usr/bin/inkscape"
# Exported PDF file location
file_location = os.path.expanduser("~" + os.sep + obj.Label + ".pdf")
# ------------------------------------------------------------------------------------
try:
page = getattr(obj, 'PageResult')
except AttributeError:
QtGui.QMessageBox.warning(None,"Export PDF", "Page object has not been selected.")
else:
file_exists = os.path.isfile(file_location)
if file_exists == True:
QtGui.QMessageBox.warning(None,"Export PDF", "A file with the name " + obj.Label + ".pdf already exists:\n\n" + file_location)
else:
call_inkscape = [inkscape_path, "-f", obj.PageResult, "-A", file_location]
subprocess.call(call_inkscape)
QtGui.QMessageBox.information(None,"Export PDF", "Successfully exported:\n\n" + file_location)
What does it do:
It exports drawing page to PDF file using Inkscape. Instead of bitmap image inserted in PDF file elements like text are searchable and exported PDF file size can be smaller when the drawings do not have big number of elements in it.
How to use it:
- Select Page object in Tree View.
- Run Export PDF macro.
First thing the users needs to check is if the path to Inkscape executable is set correctly. It should work out of the box on Ubuntu (i didn't test the Export PDF macro on Windows but the path to Inkscape executable needs to be changed).
Re: Export / Print to pdf: Is there a way to get a vector print?
That is great, Triplus.
I work under win7. Tried yr code, but not functional. I suppose the commands are linux type. I shall look into it later, and report it here when succesful.
Best regards,
Roland
I work under win7. Tried yr code, but not functional. I suppose the commands are linux type. I shall look into it later, and report it here when succesful.
Best regards,
Roland
Re: Export / Print to pdf: Is there a way to get a vector print?
Hopefully you will just need to change this line:Roland wrote:That is great, Triplus.
I work under win7. Tried yr code, but not functional. I suppose the commands are linux type. I shall look into it later, and report it here when succesful.
Best regards,
Roland
Code: Select all
inkscape_path = "/usr/bin/inkscape"
Code: Select all
inkscape_path = "path\to\inkscape.exe"
Code: Select all
path\to\inkscape.exe
Re: Export / Print to pdf: Is there a way to get a vector print?
This works for me on Win7 x64
This is the default Inkscape install, and writes the file to the user/documents folder
Code: Select all
import os
import subprocess
from PySide import QtGui
obj = FreeCADGui.Selection.getSelection()[0]
# Path to Inkscape executable
inkscape_path = "C:\Program Files\Inkscape\Inkscape.exe"
# Exported PDF file location
file_location = os.path.expanduser("~" + os.sep + "Documents" + obj.Label + ".pdf")
# ------------------------------------------------------------------------------------
try:
page = getattr(obj, 'PageResult')
except AttributeError:
QtGui.QMessageBox.warning(None,"Export PDF", "Page object has not been selected.")
else:
file_exists = os.path.isfile(file_location)
if file_exists == True:
QtGui.QMessageBox.warning(None,"Export PDF", "A file with the name " + obj.Label + ".pdf already exists:\n\n" + file_location)
else:
call_inkscape = [inkscape_path, "-f", obj.PageResult, "-A", file_location]
subprocess.call(call_inkscape)
QtGui.QMessageBox.information(None,"Export PDF", "Successfully exported:\n\n" + file_location)
"fight the good fight"
Re: Export / Print to pdf: Is there a way to get a vector print?
This seems worth living in the Macro Recipes section of the homepage! Who can enter it there?
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Re: Export / Print to pdf: Is there a way to get a vector print?
Great, Srogan,
You cracked it for my win7 (64) too!
Thx
Roland
You cracked it for my win7 (64) too!
Thx
Roland