public Example_21() { PDF pdf = new PDF(new FileStream("Example_21.pdf", FileMode.Create)); Font f1 = new Font(pdf, CoreFont.HELVETICA); Page page = new Page(pdf, Letter.PORTRAIT); TextLine text = new TextLine(f1, "QR codes encoded with Low, Medium, High and Very High error correction level - C#"); text.SetLocation(100.0f, 30.0f); text.DrawOn(page); // Please note: // The higher the error correction level - the shorter the string that you can encode. QRCode qr = new QRCode( "https://kazuhikoarase.github.io/qrcode-generator/js/demo", ErrorCorrectLevel.L); // Low qr.SetModuleLength(3f); qr.SetLocation(100f, 100f); // qr.SetColor(Color.blue); qr.DrawOn(page); qr = new QRCode( "https://github.com/kazuhikoarase/qrcode-generator", ErrorCorrectLevel.M); // Medium qr.SetLocation(400f, 100f); qr.SetModuleLength(3f); qr.DrawOn(page); qr = new QRCode( "https://github.com/kazuhikoarase/jaconv", ErrorCorrectLevel.Q); // High qr.SetLocation(100f, 400f); qr.SetModuleLength(3f); qr.DrawOn(page); qr = new QRCode( "https://github.com/kazuhikoarase", ErrorCorrectLevel.H); // Very High qr.SetLocation(400f, 400f); qr.SetModuleLength(3f); float[] xy = qr.DrawOn(page); /* * Box box = new Box(); * box.SetLocation(xy[0], xy[1]); * box.SetSize(20f, 20f); * box.DrawOn(page); */ pdf.Complete(); }
public Example_21() { PDF pdf = new PDF(new FileStream("Example_21.pdf", FileMode.Create)); Font f1 = new Font(pdf, CoreFont.HELVETICA); Page page = new Page(pdf, Letter.PORTRAIT); TextLine text = new TextLine(f1, "QR codes"); text.SetLocation(100f, 30f); text.DrawOn(page); // Please note: The higher the error correction level - the shorter the string that you can encode. QRCode qr = new QRCode( "http://d-project.googlecode.com/svn/trunk/misc/qrcode/as3/src/sample", ErrorCorrectLevel.L); // Low qr.SetModuleLength(3f); qr.SetLocation(100f, 100f); qr.SetLocation(0.0001f, 100f); qr.DrawOn(page); qr = new QRCode( "http://d-project.googlecode.com/svn/trunk/misc/qrcode", ErrorCorrectLevel.M); // High qr.SetLocation(300f, 100f); qr.DrawOn(page); qr = new QRCode( "http://www.d-project.com/qrcode/index.html", ErrorCorrectLevel.Q); // Medium qr.SetLocation(100f, 300f); qr.DrawOn(page); qr = new QRCode( "http://www.d-project.com", ErrorCorrectLevel.H); // Very High qr.SetLocation(300f, 300f); float[] xy = qr.DrawOn(page); /* * Box box = new Box(); * box.SetLocation(xy[0], xy[1]); * box.SetSize(20f, 20f); * box.DrawOn(page); */ pdf.Close(); }
public Example_78() { PDF pdf = new PDF(new BufferedStream( new FileStream("Example_78.pdf", FileMode.Create))); Font f1 = new Font(pdf, CoreFont.HELVETICA_BOLD); Font f2 = new Font(pdf, new FileStream( "fonts/OpenSans/OpenSans-Regular.ttf.stream", FileMode.Open, FileAccess.Read), Font.STREAM); String fileName = "linux-logo.png"; EmbeddedFile file1 = new EmbeddedFile( pdf, fileName, new FileStream("images/" + fileName, FileMode.Open, FileAccess.Read), false); // Don't compress images. fileName = "Example_02.cs"; EmbeddedFile file2 = new EmbeddedFile( pdf, fileName, new FileStream(fileName, FileMode.Open, FileAccess.Read), true); // Compress text files. Page page = new Page(pdf, Letter.PORTRAIT); f1.SetSize(10f); FileAttachment attachment = new FileAttachment(pdf, file1); attachment.SetLocation(0f, 0f); attachment.SetIconPushPin(); attachment.SetTitle("Attached File: " + file1.GetFileName()); attachment.SetDescription( "Right mouse click or double click on the icon to save the attached file."); float[] point = attachment.DrawOn(page); attachment = new FileAttachment(pdf, file2); attachment.SetLocation(0f, point[1]); attachment.SetIconPaperclip(); attachment.SetTitle("Attached File: " + file2.GetFileName()); attachment.SetDescription( "Right mouse click or double click on the icon to save the attached file."); point = attachment.DrawOn(page); CheckBox checkbox = new CheckBox(f1, "Hello"); checkbox.SetLocation(0f, point[1]); checkbox.SetCheckmark(Color.blue); checkbox.Check(Mark.CHECK); point = checkbox.DrawOn(page); checkbox = new CheckBox(f1, "Hello"); checkbox.SetLocation(0.0, point[1]); checkbox.SetCheckmark(Color.blue); checkbox.Check(Mark.X); point = checkbox.DrawOn(page); Box box = new Box(); box.SetLocation(0f, point[1]); box.SetSize(20f, 20f); point = box.DrawOn(page); RadioButton radiobutton = new RadioButton(f1, "Yes"); radiobutton.SetLocation(0f, point[1]); radiobutton.SetURIAction("http://pdfjet.com"); radiobutton.Select(true); point = radiobutton.DrawOn(page); QRCode qr = new QRCode( "https://kazuhikoarase.github.io", ErrorCorrectLevel.L); // Low qr.SetModuleLength(3f); qr.SetLocation(0f, point[1]); point = qr.DrawOn(page); Dictionary <String, Int32> colors = new Dictionary <String, Int32>(); colors["brown"] = Color.brown; colors["fox"] = Color.maroon; colors["lazy"] = Color.darkolivegreen; colors["jumps"] = Color.darkviolet; colors["dog"] = Color.chocolate; colors["sight"] = Color.blue; StringBuilder buf = new StringBuilder(); buf.Append("The quick brown fox jumps over the lazy dog. What a sight!\n\n"); TextBox textbox = new TextBox(f1, buf.ToString()); textbox.SetLocation(0f, point[1]); // textbox.SetWidth(f1.StringWidth(buf.ToString())); textbox.SetBgColor(Color.whitesmoke); textbox.SetTextColors(colors); point = textbox.DrawOn(page); buf = new StringBuilder(); buf.Append("Calculus, originally called infinitesimal calculus or \"the calculus of infinitesimals\", "); buf.Append("is the mathematical study of continuous change, in the same way that geometry is the "); buf.Append("study of shape and algebra is the study of generalizations of arithmetic operations. "); buf.Append("It has two major branches, differential calculus and integral calculus; "); buf.Append("the former concerns instantaneous rates of change, and the slopes of curves, "); buf.Append("while integral calculus concerns accumulation of quantities, and areas under or between "); buf.Append("curves. These two branches are related to each other by the fundamental theorem of calculus, "); buf.Append("and they make use of the fundamental notions of convergence of infinite sequences and "); buf.Append("infinite series to a well-defined limit."); TextBlock textBlock = new TextBlock(f1); textBlock.SetText(buf.ToString()); textBlock.SetLocation(0f, point[1]); // textBlock.SetWidth(50f); point = textBlock.DrawOn(page); BarCode code = new BarCode(BarCode.CODE128, "Hello, World!"); code.SetLocation(0f, point[1]); code.SetModuleLength(0.75f); code.SetFont(f1); point = code.DrawOn(page); buf = new StringBuilder(); buf.Append("Using another font ...\n\nThis is a test."); textbox = new TextBox(f2, buf.ToString()); textbox.SetLocation(0f, point[1]); point = textbox.DrawOn(page); code = new BarCode(BarCode.CODE128, "G86513JVW0C"); code.SetLocation(0f, point[1]); code.SetModuleLength(0.75f); code.SetDirection(BarCode.TOP_TO_BOTTOM); code.SetFont(f1); point = code.DrawOn(page); buf = new StringBuilder(); StreamReader reader = new StreamReader( new FileStream("Example_12.cs", FileMode.Open)); String line = null; while ((line = reader.ReadLine()) != null) { buf.Append(line); // Both CR and LF are required by the scanner! buf.Append((char)13); buf.Append((char)10); } BarCode2D code2D = new BarCode2D(buf.ToString()); code2D.SetModuleWidth(0.5f); code2D.SetLocation(0f, point[1]); point = code2D.DrawOn(page); pdf.Complete(); }
public Example_20() { PDF pdf = new PDF(new BufferedStream( new FileStream("Example_20.pdf", FileMode.Create))); BufferedStream bis = new BufferedStream( new FileStream("data/testPDFs/PDFjetLogo.pdf", FileMode.Open)); SortedDictionary <Int32, PDFobj> objects = pdf.Read(bis); bis.Close(); pdf.AddResourceObjects(objects); Font f1 = new Font(pdf, new FileStream( "fonts/OpenSans/OpenSans-Regular.ttf.stream", FileMode.Open, FileAccess.Read), Font.STREAM); f1.SetSize(18f); List <PDFobj> pages = pdf.GetPageObjects(objects); PDFobj contents = pages[0].GetContentsObject(objects); Page page = new Page(pdf, Letter.PORTRAIT); float height = 105f; // The logo height in points. float x = 50f; float y = 50f; float xScale = 0.5f; float yScale = 0.5f; page.DrawContents( contents.GetData(), height, x, y, xScale, yScale); page.SetPenColor(Color.darkblue); page.SetPenWidth(0f); page.DrawRect(0f, 0f, 50f, 50f); PDFjet.NET.Path path = new PDFjet.NET.Path(); path.Add(new Point(13.0f, 0.0f)); path.Add(new Point(15.5f, 4.5f)); path.Add(new Point(18.0f, 3.5f)); path.Add(new Point(15.5f, 13.5f, Point.CONTROL_POINT)); path.Add(new Point(15.5f, 13.5f, Point.CONTROL_POINT)); path.Add(new Point(20.5f, 7.5f)); path.Add(new Point(21.0f, 9.5f)); path.Add(new Point(25.0f, 9.0f)); path.Add(new Point(24.0f, 13.0f)); path.Add(new Point(25.5f, 14.0f)); path.Add(new Point(19.0f, 19.0f)); path.Add(new Point(20.0f, 21.5f)); path.Add(new Point(13.5f, 20.5f)); path.Add(new Point(13.5f, 27.0f)); path.Add(new Point(12.5f, 27.0f)); path.Add(new Point(12.5f, 20.5f)); path.Add(new Point(6.0f, 21.5f)); path.Add(new Point(7.0f, 19.0f)); path.Add(new Point(0.5f, 14.0f)); path.Add(new Point(2.0f, 13.0f)); path.Add(new Point(1.0f, 9.0f)); path.Add(new Point(5.0f, 9.5f)); path.Add(new Point(5.5f, 7.5f)); path.Add(new Point(10.5f, 13.5f, Point.CONTROL_POINT)); path.Add(new Point(10.5f, 13.5f, Point.CONTROL_POINT)); path.Add(new Point(8.0f, 3.5f)); path.Add(new Point(10.5f, 4.5f)); path.SetClosePath(true); path.SetColor(Color.red); // path.SetFillShape(true); path.SetLocation(100f, 100f); path.ScaleBy(10f); path.DrawOn(page); page = new Page(pdf, Letter.PORTRAIT); TextLine line = new TextLine(f1, "Hello, World!"); line.SetLocation(50f, 50f); line.DrawOn(page); QRCode qr = new QRCode( "http://d-project.googlecode.com/svn/trunk/misc/qrcode/as3/src/sample", ErrorCorrectLevel.L); // Low qr.SetModuleLength(3f); qr.SetLocation(50f, 200f); qr.DrawOn(page); pdf.Close(); }