if (viewport.length() == 0) { width = bounds.getWidth() + (2 * this.margin); height = bounds.getHeight() + (2 * this.margin);  viewport = "" + (bounds.getMinimumX() - this.margin) + " " + ((-1 * bounds.getMaximumY()) - this.margin) + "  "
double[] margin = this.getMargin(bounds); width = bounds.getWidth() + (margin[1] + margin[3]); height = bounds.getHeight() + (margin[0] + margin[2]);  viewport = "" + (bounds.getMinimumX() - margin[3]) + " " + ((-1 * bounds.getMaximumY()) - margin[0]) + "  "
	private void generateSAX() {		try {			this.handler.startDocument();			AttributesImpl attr = new AttributesImpl();			// add the viewport			// with margin			// this is important otherwise in most cases			// the SVG-Viewer will not show the content			String viewport = "";			Bounds bounds = this.doc.getBounds();			double width=0.0;			double height=0.0;			if (this.doc.getDXFHeader().hasVariable("$PEXTMAX")					&& this.doc.getDXFHeader().hasVariable("$PEXTMMIN")) {				DXFVariable min = this.doc.getDXFHeader().getVariable(						"$PEXTMIN");				DXFVariable max = this.doc.getDXFHeader().getVariable(						"$PEXTMAX");				double x = min.getDoubleValue("10");				double y = min.getDoubleValue("20");				double max_y = max.getDoubleValue("20");				width = max.getDoubleValue("10") - x;				height = max_y - y;				double boundsWidth = bounds.getWidth();				// we set a limit here and use the bounds instead				if ((width <= (boundsWidth * 2)) && (width > 0)) {					viewport = "" + x + " " + ((-1.0) * max_y) + " "							+ Math.abs(width) + " " + Math.abs(height);				}			}			if (viewport.length() == 0) {				width = bounds.getWidth() + (2 * this.margin);				height = bounds.getHeight() + (2 * this.margin);								viewport = "" + (bounds.getMinimumX() - this.margin) + " "						+ ((-1 * bounds.getMaximumY()) - this.margin) + "  "						+ SVGUtils.formatNumberAttribute(width) + " "						+ SVGUtils.formatNumberAttribute(width);			}			SVGUtils.addAttribute(attr, "viewBox", viewport);			if(this.properties.containsKey(PROPERTY_WIDTH)){				SVGUtils.addAttribute(attr, SVGConstants.SVG_ATTRIBUTE_WIDTH,(String) this.properties.get(PROPERTY_WIDTH));			}						if(this.properties.containsKey(PROPERTY_HEIGHT)){				SVGUtils.addAttribute(attr, SVGConstants.SVG_ATTRIBUTE_HEIGHT,(String) this.properties.get(PROPERTY_HEIGHT));			}						// set the default namespace			SVGUtils.addAttribute(attr, "xmlns", SVGConstants.SVG_NAMESPACE);						//			 the version of SVG we generate now			SVGUtils.addAttribute(attr,SVGConstants.SVG_ATTRIBUTE_VERSION, SUPPORTED_SVG_VERSION);						//the overflow 			if(this.overflow){				SVGUtils.addAttribute(attr,SVGConstants.SVG_ATTRIBUTE_OVERFLOW, SVGConstants.SVG_ATTRIBUTEVALUE_VISIBLE);			}									SVGUtils.startElement(this.handler, SVGConstants.SVG_ROOT, attr);			// the blocks as symbol in the defs-section of SVG			attr = new AttributesImpl();			SVGUtils.startElement(this.handler, SVGConstants.SVG_DEFS, attr);			// set the context			context.put(SVGContext.DRAFT_BOUNDS, bounds);			double dotLength = 0.0;			if (bounds.getWidth() > bounds.getHeight()) {				dotLength = bounds.getHeight()						* SVGConstants.DEFAULT_STROKE_WIDTH_PERCENT;			} else {				dotLength = bounds.getWidth()						* SVGConstants.DEFAULT_STROKE_WIDTH_PERCENT;			}			context.put(SVGContext.DOT_LENGTH, new Double(dotLength));			Iterator i = this.doc.getDXFBlockIterator();			while (i.hasNext()) {				DXFBlock block = (DXFBlock) i.next();				this.blockToSAX(block);			}			// maybe there is a fontdescription available from DXFStyle			i = this.doc.getDXFStyleIterator();			while (i.hasNext()) {				DXFStyle style = (DXFStyle) i.next();				style.toSAX(handler, context);			}//			i = this.doc.getDXFHatchPatternIterator();////			while (i.hasNext()) {//				DXFHatchPattern pattern = (DXFHatchPattern) i.next();//				pattern.toSAX(handler, context);//			}			SVGUtils.endElement(handler, SVGConstants.SVG_DEFS);			// the draft			attr = new AttributesImpl();			SVGUtils.addAttribute(attr, "id", "draft");			// the globale coordinate system transformation			// note: DXF has the y-axis positiv from bottom to top			// SVG has the y-axis positiv from top to bottom			SVGUtils.addAttribute(attr, "transform", "matrix(1 0 0 -1 0 0)");			// the stroke-width			if (this.context.containsKey(SVGContext.STROKE_WIDTH)) {				SVGUtils.addAttribute(attr, "stroke-width", ""						+ this.context.get(SVGContext.STROKE_WIDTH));			} else {				SVGUtils.addAttribute(attr, "stroke-width", ""						+ SVGConstants.DEFAULT_STROKE_WIDTH_PERCENT + '%');			}			SVGUtils.startElement(handler, SVGConstants.SVG_GROUP, attr);			// the layers as container g-elements			i = this.doc.getDXFLayerIterator();			while (i.hasNext()) {				DXFLayer layer = (DXFLayer) i.next();				this.layerToSAX(layer);			}			SVGUtils.endElement(handler, SVGConstants.SVG_GROUP);			SVGUtils.endElement(handler, SVGConstants.SVG_ROOT);			handler.endDocument();		} catch (SAXException e) {			e.printStackTrace();		}	}