Esempio n. 1
0
        public static void AddImageInLine()
        {
            PdfDocument document = new PdfDocument();

            //Create document level builder
            using (PdfDocumentBuilder builder = new PdfDocumentBuilder(document))
            {
                builder.InsertParagraph();
                //You can insert same image to different position in page, or insert different images to respective position
                using (Stream sampleImage = File.OpenRead("sample.jpg"))
                {
                    builder.InsertImageInline(sampleImage, new Size(40, 40));
                    builder.InsertText(", second one:");
                    builder.InsertImageInline(sampleImage, new Size(100, 100));
                    builder.InsertText(" and third one:");
                    builder.InsertImageInline(sampleImage, new Size(100, 60));
                    builder.InsertText(" the end.");
                }
            }

            using (FileStream fs = File.OpenWrite("InsertImageInLine.pdf"))
            {
                PdfFile pdfFile = new PdfFile();
                pdfFile.Export(document, fs);
            }
        }