public void EqualityTest() { var oneInch1 = PdfMeasurement.Inches(1.0); var oneInch2 = PdfMeasurement.Mm(25.4); Assert.Equal(oneInch1, oneInch2); }
public void ConvertTest() { var oneInch = PdfMeasurement.Inches(1.0); Assert.Equal(72.0, oneInch.AsPoints()); Assert.Equal(25.4, oneInch.ConvertTo(PdfMeasurementType.Mm).RawValue); }
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); }
private static string ConvertToString(DxfFile dxf, PdfMeasurement?pageWidth = null, PdfMeasurement?pageHeight = null, double scale = 1.0) { var options = new DxfToPdfConverterOptions( pageWidth ?? PdfMeasurement.Inches(8.5), pageHeight ?? PdfMeasurement.Inches(11.0), scale); return(ConvertToString(dxf, options)); }
public void VerifyGraphicsStreamTest() { var page = new PdfPage(PdfMeasurement.Inches(8.5), PdfMeasurement.Inches(11.0)); var width = 100; var height = 100; var bpp = 3; var imageBytes = new byte[width * height * bpp]; // 0 is fine for this var imageObject = new PdfImageObject(width, height, PdfColorSpace.DeviceRGB, 8, imageBytes, new ASCIIHexEncoder()); var xScale = 400; var yScale = 400; var xOffset = 100; var yOffset = 100; var transform = PdfMatrix.ScaleThenTranslate(xScale, yScale, xOffset, yOffset); var imageItem = new PdfImageItem(imageObject, transform); page.Items.Add(imageItem); // placement of image var expectedStream = @" q 400.00 0.00 0.00 400.00 100.00 100.00 cm /Im5 Do Q "; AssertPageContains(page, expectedStream); // raw image data var expectedImageData = @" <</Type /XObject /Subtype /Image /Width 100 /Height 100 /ColorSpace /DeviceRGB /BitsPerComponent 8 /Length 60939 /Filter [/ASCIIHexDecode]>> stream "; AssertPageContains(page, expectedImageData); }
public void VerifyStreamFilterTest() { var page = new PdfPage(PdfMeasurement.Inches(8.5), PdfMeasurement.Inches(11.0), new ASCIIHexEncoder()); var text = new PdfText("foo", new PdfFontType1(PdfFontType1Type.Helvetica), PdfMeasurement.Points(12.0), new PdfPoint(PdfMeasurement.Inches(1.0), PdfMeasurement.Inches(1.0))); page.Items.Add(text); var expected = @" <</Length 185 /Filter [/ASCIIHexDecode] >> stream 3020770D0A30203020302052470D0A30203020302072670D0A42540D0A202020202F46312031322E30302054660D0A2020202037322E30302037322E30302054 640D0A202020205B28666F6F295D20544A0D0A45540D0A530D0A> endstream endobj "; AssertPageContains(page, expected); }
public void VerifyPageTextAndFontTest() { var file = new PdfFile(); var page = PdfPage.NewLetter(); var text = new PdfText("foo", new PdfFontType1(PdfFontType1Type.Helvetica), PdfMeasurement.Points(12.0), new PdfPoint(PdfMeasurement.Inches(1.0), PdfMeasurement.Inches(2.0))); page.Items.Add(text); file.Pages.Add(page); AssertFileContains(file, @" BT /F1 12.00 Tf 72.00 144.00 Td [(foo)] TJ ET "); AssertFileContains(file, @" /Resources <</Font <</F1 5 0 R>>>> "); AssertFileContains(file, "<</Type /Font /Subtype /Type1 /BaseFont /Helvetica>>"); text.CharacterWidth = PdfMeasurement.Points(0.25); AssertFileContains(file, @" BT /F1 12.00 Tf 72.00 144.00 Td 0.25 Tc [(foo)] TJ ET "); }