/// <summary> /// Tests the code128 C. /// </summary> /// <externalUnit/> /// <revision revisor="dev13" date="11/19/2009" version="1.1.3.7"> /// Added documentation header /// </revision> private static void TestCode128C() { string text = "98723493871103000000"; Bitmap barcode = Code128.Encode(text, 1, 0.125F, 96, 12, 0); PixelChar.DrawChar(barcode, 'M', 0, 2); Bitmap pixelchar = new Bitmap(70, 40); Graphics g = Graphics.FromImage(pixelchar); g.Clear(Color.White); g.Dispose(); pixelchar.SetResolution(96, 96); for (int i = 0; i < 7; i++) { for (int j = 0; j < 4; j++) { if (j * 7 + i < 26) { char ch = (char)(j * 7 + i + 65); PixelChar.DrawChar(pixelchar, ch, 10 * i, 10 * j); } } } MemoryInputStream misStream = new MemoryInputStream(barcode, 100); barcode.Dispose(); barcode.Dispose(); DSxInput pdfInput = new DSxInput(misStream); DSxSystem.setLicenseKey( "[Insert your license key here]"); DSxTask task = new DSxTask(); PDFxDocument pdfDoc = PDF.createDocument(task); PDFxContext context = pdfDoc.getContext(); PDFxPage pdfPage = pdfDoc.createCustomPage(5, 2); PDFxImage bar = PDFxImage.createImageFromJPEG(pdfInput); double dpi = 96D, k = 72D / dpi; pdfPage.drawImage( 18, 18, k * bar.getWidth(), k * bar.getHeight(), bar); bar = PDFxImage.createImageFromJPEG( new DSxInput(new MemoryInputStream(pixelchar, 100))); pixelchar.Dispose(); pdfPage.drawImage( 18, 72, k * bar.getWidth(), k * bar.getHeight(), bar); DSxPDFDocument dsDocument = new DSxPDFDocument(pdfDoc); dsDocument.save(new DSxOutput(@"bin\Debug\DSxInput2.pdf")); }
/// <summary> /// Draws the oval mark. /// </summary> /// <param name="pdfPage">The PDF page.</param> /// <param name="pdfContext">The PDF context.</param> /// <param name="x">The x (left, in points).</param> /// <param name="y">The y (top, in points).</param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="markWidth">Width of the line to make the mark.</param> /// <externalUnit/> /// <revision revisor="dev11" date="4/20/2009" version="1.0.11.0801"> /// Member Created /// </revision> /// <revision revisor="dev11" date="04/21/2009" version="1.0.11.0801"> /// added mark density color /// </revision> public void DrawOvalMark( PDFxPage pdfPage, PDFxContext pdfContext, double x, double y, double width, double height, double markWidth) { double tempLineWidth = pdfContext.getLineWidth(); int lineCap = pdfContext.getLineCapStyle(), lineJoin = pdfContext.getLineJoinStyle(); JColor foreGroundcolor = pdfContext.getFgColor(), bgColor = pdfContext.getBgColor(); pdfContext.setFgColor(this.markDensityColor); pdfContext.setBgColor(this.markDensityColor); switch (this.mark) { case TargetMark.OvalHalfBottom: pdfPage.drawArc( x, y, width, height, 180, 180, true, false, false); break; case TargetMark.OvalHalfLeft: pdfPage.drawArc( x, y, width, height, 90, 180, true, false, false); break; case TargetMark.OvalHalfRight: pdfPage.drawArc( x, y, width, height, -90, 180, true, false, false); break; case TargetMark.OvalHalfTop: pdfPage.drawArc( x, y, width, height, 0, 180, true, false, false); break; case TargetMark.OvalCheckMark: pdfContext.setLineWidth(markWidth); pdfContext.setLineCapStyle( PDFxContext.__Fields.LINE_CAP_ROUND); pdfContext.setLineJoinStyle( PDFxContext.__Fields.LINE_JOIN_ROUND); pdfPage.drawPolyline( new[] { x + (width * CheckMarkX1), x + (width * CheckMarkX2), x + (width * CheckMarkX3) }, new[] { y + (height * CheckMarkY1), y + (height * CheckMarkY2), y + (height * CheckMarkY3) }); break; case TargetMark.OvalXMark: pdfContext.setLineWidth(markWidth); pdfContext.setLineCapStyle( PDFxContext.__Fields.LINE_CAP_ROUND); pdfContext.setLineJoinStyle( PDFxContext.__Fields.LINE_JOIN_ROUND); pdfPage.drawLine( x + (width * XMarkX1), y + (height * XMarkY1), x + (width * XMarkX2), y + (height * XMarkY2)); pdfPage.drawLine( x + (width * XMarkX1), y + (height * XMarkY2), x + (width * XMarkX2), y + (height * XMarkY1)); break; default: // TargetMark.OvalDefault pdfPage.drawOval( x, y, width, height, true, false); break; } pdfContext.setLineWidth(tempLineWidth); pdfContext.setLineCapStyle(lineCap); pdfContext.setLineJoinStyle(lineJoin); pdfContext.setFgColor(foreGroundcolor); pdfContext.setBgColor(bgColor); }