public void EqualityTest() { var oneInch1 = PdfMeasurement.Inches(1.0); var oneInch2 = PdfMeasurement.Mm(25.4); Assert.Equal(oneInch1, oneInch2); }
public void BinaryOperatorTest() { var oneInch1 = PdfMeasurement.Inches(1.0); var oneInch2 = PdfMeasurement.Mm(25.4); Assert.Equal(2.0, (oneInch1 + oneInch2).RawValue); Assert.Equal(50.8, (oneInch2 + oneInch1).RawValue); }
public void SourceDestinationTransformTest() { var dxf = new DxfFile(); // line from (2,2) to (3,3) dxf.Entities.Add(new DxfLine(new DxfPoint(2, 2, 0), new DxfPoint(3, 3, 0))); var options = new DxfToPdfConverterOptions(PdfMeasurement.Mm(210), PdfMeasurement.Mm(297), new ConverterDxfRect(2, 3, 2, 3), new ConverterPdfRect(PdfMeasurement.Points(100), PdfMeasurement.Points(200), PdfMeasurement.Points(300), PdfMeasurement.Points(400))); var pdf = ConvertToString(dxf, options); // expected line from (100,300)pt to (200,400)pt var expected = NormalizeCrLf(@" stream 0 w 0 0 0 RG 0 0 0 rg 100.00 300.00 m 200.00 400.00 l S endstream".Trim()); Assert.Contains(expected, pdf); }
private static PdfMeasurement GetStrokeWidth(DxfEntity entity, DxfLayer layer) { // TODO many entities have a Thickness property (which is often zero). DxfLineWeight lw = new DxfLineWeight { Value = entity.LineweightEnumValue }; DxfLineWeightType type = lw.LineWeightType; if (type == DxfLineWeightType.ByLayer) { lw = layer.LineWeight; } if (lw.Value == 0) { return(default(PdfMeasurement)); } if (lw.Value < 0) { return(PdfMeasurement.Points(1)); // smallest valid stroke width } // TODO What is the meaning of this short? Some default app-dependent table? DXF spec doesn't tell. // QCad 1mm => lw.Value==100 return(PdfMeasurement.Mm(lw.Value / 100.0)); }