- added ability to save the Source File as PDF - fixed page size and added line breaks

This commit is contained in:
Marius Stanciu 2019-12-17 14:47:44 +02:00
parent 82f0c40ff8
commit 4a8a980cde
2 changed files with 19 additions and 16 deletions

View File

@ -18,6 +18,7 @@ CAD program, and create G-Code for Isolation routing.
- made sure that if in Gerber UI the isolation is made with a V-Shape tool then the tool type is automatically updated on the generated Geometry Object - made sure that if in Gerber UI the isolation is made with a V-Shape tool then the tool type is automatically updated on the generated Geometry Object
- added ability to save the Source File as PDF (still have to adjust the page size) - added ability to save the Source File as PDF (still have to adjust the page size)
- fixed the generate_from_geometry_2() method to use the default values in case the parameters are None - fixed the generate_from_geometry_2() method to use the default values in case the parameters are None
- added ability to save the Source File as PDF - fixed page size and added line breaks
16.12.2019 16.12.2019

View File

@ -8,6 +8,12 @@
from flatcamGUI.GUIElements import * from flatcamGUI.GUIElements import *
from PyQt5 import QtPrintSupport from PyQt5 import QtPrintSupport
from reportlab.platypus import SimpleDocTemplate, Paragraph
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.lib.units import inch, mm
from io import StringIO
import gettext import gettext
import FlatCAMTranslation as fcTranslate import FlatCAMTranslation as fcTranslate
import builtins import builtins
@ -218,17 +224,13 @@ class TextEditor(QtWidgets.QWidget):
try: try:
my_gcode = self.code_editor.toPlainText() my_gcode = self.code_editor.toPlainText()
if filename.rpartition('.')[2].lower() == 'pdf': if filename.rpartition('.')[2].lower() == 'pdf':
from reportlab.platypus import SimpleDocTemplate, Paragraph page_size = (
from reportlab.lib.styles import getSampleStyleSheet self.app.plotcanvas.pagesize_dict[self.app.defaults['global_workspaceT']][0] * mm,
from reportlab.lib.units import inch self.app.plotcanvas.pagesize_dict[self.app.defaults['global_workspaceT']][1] * mm
)
if self.app.defaults['units'].upper() == 'MM': # add new line after each line
dims = self.app.plotcanvas.pagesize_dict[self.app.defaults['global_workspaceT']] lined_gcode = my_gcode.replace("\n", "<br />")
else:
dims = (
self.app.plotcanvas.pagesize_dict[self.app.defaults['global_workspaceT']][0] / 25.4,
self.app.plotcanvas.pagesize_dict[self.app.defaults['global_workspaceT']][1] / 25.4
)
styles = getSampleStyleSheet() styles = getSampleStyleSheet()
styleN = styles['Normal'] styleN = styles['Normal']
@ -237,13 +239,13 @@ class TextEditor(QtWidgets.QWidget):
doc = SimpleDocTemplate( doc = SimpleDocTemplate(
filename, filename,
pagesize=dims, pagesize=page_size,
bottomMargin=0.4 * 72, bottomMargin=0.4 * inch,
topMargin=0.6 * 72, topMargin=0.6 * inch,
rightMargin=0.8 * 72, rightMargin=0.8 * inch,
leftMargin=0.8 * 72) leftMargin=0.8 * inch)
P = Paragraph(my_gcode, styleN) P = Paragraph(lined_gcode, styleN)
story.append(P) story.append(P)
doc.build( doc.build(