public void PrintElement(BasicElement element, PdfDocument pdf, PdfStream pdfStream) { var type = element.GetType(); var adapter = new PdfStreamAdapter(pdfStream, defaultFont); if (type == typeof (Text)) { adapter.PrintText((Text) element); } else if (type == typeof (Expression)) { adapter.PrintExpression((Expression) element); } else if (type == typeof (Image)) { adapter.PrintImage((Image) element); } else if (type == typeof (Rectangle)) { adapter.PrintRectangle((Rectangle) element); } else if (type == typeof (Bookmark)) { PrintBookmark((Bookmark) element, pdf); } }
public override void Print(Document document, Stream printStream) { var pdf = new PdfDocument(); foreach (var font in document.Fonts) { var pdfFont = pdf.CreateFont(PdfFontTypes.TYPE1, font.FontName); if (font.IsDefault) { defaultFont = pdfFont.FontName; } } foreach (Image image in document.Images) { var wi = new WinImage(image.url); var pdfImage = pdf.CreateImage(wi); image.ImageName.Name = pdfImage.Name; } foreach (var page in document.Pages) { PrintPage(page, pdf); } pdf.Print(printStream); printStream.Flush(); }
public void PrintPage(Page page, PdfDocument pdf) { currentPage = pdf.CreatePage(page.Width, page.Height); foreach (var be in page.Elements) { PrintElement(be, pdf, currentPage.Content); } }
public void Works() { var pdf = new PdfDocument(); var font = pdf.CreateFont(PdfFontTypes.TYPE1, "Helvetica"); var image = pdf.CreateImage(@"C:\Temp\dotnet.gif"); var page = pdf.CreatePage( 612, 792); page.DrawText("a GIF image :",50,550,font,24, new RgbColor()); page.DrawImage(image, 20, 100); page.DrawImage(image, 250, 570, 61, 35); page.DrawRectangle(20, 40, 400, 50, new RgbColor("#330000"), new RgbColor(Color.Red)); pdf.MakeOutline(pdf.OutlineRoot, "root", page); pdf.Print(new FileStream(@"C:\Temp\test.pdf", FileMode.Create, FileAccess.Write)); }
public void PrintBookmark(Bookmark b, PdfDocument pdf) { pdf.MakeOutline(pdf.OutlineRoot, b.VarName, currentPage); }