//////////////////////////////////////////////////////////////////// // Draw frame around example area //////////////////////////////////////////////////////////////////// private void DrawFrameAndBackgroundWaterMark ( PdfContents Contents ) { // save graphics state Contents.SaveGraphicsState(); // Draw frame around the page // Set line width to 0.02" Contents.SetLineWidth(0.02); // set frame color dark blue Contents.SetColorStroking(Color.DarkBlue); // use water mark tiling pattern to fill the frame Contents.SetPatternNonStroking(WaterMark); // rectangle position: x=1.0", y=1.0", width=6.5", height=9.0" Contents.DrawRectangle(1.0, 1.0, 6.5, 9.0, PaintOp.CloseFillStroke); // restore graphics sate Contents.RestoreGraphicsState(); // draw article name under the frame // Note: the \u00a4 is character 164 that was substituted during Font resource definition // this character is a solid circle it is normally unicode 9679 or \u25cf in the Arial family Contents.DrawText(ArialNormal, 9.0, 1.1, 0.85, "PdfFileWriter \u00a4 PDF File Writer C# Class Library \u00a4 Author: Uzi Granot"); return; }
//////////////////////////////////////////////////////////////////// // Draw heading //////////////////////////////////////////////////////////////////// private void DrawTwoLinesOfHeading ( PdfContents Contents ) { // page heading // Arguments: Font: ArialBold, size: 36 points, Position: X = 4.25", Y = 9.5" // Text Justify: Center (text center will be at X position) // Stoking color: R=128, G=0, B=255 (text outline) // Nonstroking color: R=255, G=0, B=128 (text body) Contents.DrawText(Comic, 40.0, 4.25, 9.25, TextJustify.Center, 0.02, Color.FromArgb(128, 0, 255), Color.FromArgb(255, 0, 128), "PDF FILE WRITER"); // save graphics state Contents.SaveGraphicsState(); // change nonstroking (fill) color to purple Contents.SetColorNonStroking(Color.Purple); // Draw second line of heading text // arguments: Handwriting font, Font size 30 point, Position X=4.25", Y=9.0" // Text Justify: Center (text center will be at X position) Contents.DrawText(Comic, 30.0, 4.25, 8.75, TextJustify.Center, "Example"); // Contents.TranslateScaleRotate(4.25, 8.75, 1.5, Math.PI / 6); // Contents.DrawText(Comic, 30.0, 0, 0, TextJustify.Center, "Example"); // restore graphics sate (non stroking color will be restored to default) Contents.RestoreGraphicsState(); return; }
//////////////////////////////////////////////////////////////////// // Draw rectangle with rounded corners and filled with brick pattern //////////////////////////////////////////////////////////////////// private void DrawBrickPattern ( PdfDocument Document, PdfContents Contents ) { // Define brick tilling pattern resource // Arguments: PdfDocument class, Scale factor (0.25), Stroking color (lines between bricks), Nonstroking color (brick) // Return value: tilling pattern resource PdfTilingPattern BrickPattern = PdfTilingPattern.SetBrickPattern(Document, 0.25, Color.LightYellow, Color.SandyBrown); // save graphics state Contents.SaveGraphicsState(); // set outline width 0.04" Contents.SetLineWidth(0.04); // set outline color to purple Contents.SetColorStroking(Color.Purple); // set fill pattern to brick Contents.SetPatternNonStroking(BrickPattern); // draw rounded rectangle filled with brick pattern Contents.DrawRoundedRectangle(1.13, 5.0, 1.4, 1.4, 0.2, PaintOp.CloseFillStroke); // restore graphics sate Contents.RestoreGraphicsState(); return; }
//////////////////////////////////////////////////////////////////// // Draw image of a flower and clip it //////////////////////////////////////////////////////////////////// private void DrawFlower ( PdfDocument Document, PdfContents Contents ) { // define local image resources PdfImage Image1 = new PdfImage(Document, "flower.jpg"); // image size will be limited to 1.4" by 1.4" SizeD ImageSize = Image1.ImageSize(1.4, 1.4); // save graphics state Contents.SaveGraphicsState(); // translate coordinate origin to the center of the picture Contents.Translate(3.36, 5.7); // clipping path Contents.DrawOval(-ImageSize.Width / 2, -ImageSize.Height / 2, ImageSize.Width, ImageSize.Height, PaintOp.ClipPathEor); // draw image Contents.DrawImage(Image1, -ImageSize.Width / 2, -ImageSize.Height / 2, ImageSize.Width, ImageSize.Height); // restore graphics state Contents.RestoreGraphicsState(); return; }
void DrawFooter(PdfContents content, PdfFont font) { content.SaveGraphicsState(); // Persönlich haftende Gesellschafterin content.DrawText(this.myFontBold, 8, 5, 20.5, "Persönlich haftende Gesellschafterin"); content.DrawText(font, 8, 5, 17, "Cut & Print Media GmbH & Co. KG"); content.DrawText(font, 8, 5, 14, "Geschäftsführer: Felix Deutz"); content.DrawText(font, 8, 5, 11, "USt.-ID: DE 814 912 333"); content.DrawText(font, 8, 5, 8, "HRA 200901"); content.DrawText(font, 8, 5, 5, "http://www.cut-print.de"); // Handelsregister content.DrawText(this.myFontBold, 8, xFTab1, 20.5, "Handelsregister"); content.DrawText(font, 8, xFTab1, 17, "Amtsgericht Osnabrück"); content.DrawText(font, 8, xFTab1, 14, "HRB 201534"); content.DrawText(font, 8, xFTab1, 11, "St-Nr.: 65/207/16220"); // Bankverbindung content.DrawText(this.myFontBold, 8, xFTab2, 20.5, "Bankverbindung"); content.DrawText(font, 8, xFTab2, 17, "Volksbank Georgsmarienhütte"); content.DrawText(font, 8, xFTab2, 14, "BLZ: 265 659 28"); content.DrawText(font, 8, xFTab2, 11, "Konto: 500 5555 000"); content.DrawText(font, 8, xFTab2, 8, "IBAN: DE06 265 659 28 500 5555 000"); content.DrawText(font, 8, xFTab2, 5, "SWIFT Code: GENODEF1HGM"); // AGB content.DrawText(this.myFontBold, 8, xFTab3, 20.5, "AGB"); content.DrawText(font, 8, xFTab3, 17, "Für alle unsere Angebote, Kaufverträge"); content.DrawText(font, 8, xFTab3, 14, "und rechtsgeschäftlichen Erklärungen"); content.DrawText(font, 8, xFTab3, 11, "gelten unsere allgemeinen"); content.DrawText(font, 8, xFTab3, 8, "Geschäftsbedingungen"); }
public void writePDF() { PdfDocument document = new PdfDocument(PaperType.A4, false, UnitOfMeasure.cm); // Step 3: Add new empty page PdfPage Page = new PdfPage(document); // Step 4: Add contents object to the page object PdfContents Contents = new PdfContents(Page); // Step 5: add graphics and text contents to the contents object TextBox Box = new TextBox(10, 5); // add text to the text box PdfFont font = new PdfFont(document, "Arial", FontStyle.Bold, true); Box.AddText(font, 12.0, "This area is an example of displaying text that is too long to fit within a " + "fixed width area. The text is displayed justified to right edge. You define a " + "text box with the required width and first line indent. You add text to this " + "box. The box will divide the text into lines. Each line is made of segments " + "of text. For each segment, you define font, font size, drawing style and color. " + "After loading all the text, the program will draw the formatted text.\n"); Double PosY = 1.4; Contents.DrawText(0.0, ref PosY, 0.0, 0, 0.015, 0.05, true, Box); // Step 6: create pdf file // argument: PDF file name string FileName = @"D:\MyPDFFile.pdf"; document.CreateFile(FileName); }
// start a new page private void CreateNewPage() { // terminate activity on current page if (RowNumber > 0) { // draw border and grid on current page DrawBorders(); // call user event handler for end of table on each page if (TableEndEvent != null) { TableEndEvent(this, _RowTopPosition); } } // create a new page Page = new PdfPage(Document); Contents = new PdfContents(Page); // reset border lines BorderRowTopPos = _TableArea.Top; BorderYPos.Clear(); BorderYPos.Add(BorderRowTopPos); _RowTopPosition = BorderRowTopPos; _RowTopPosition -= Borders.TopBorder.HalfWidth; // calculate header height if (RowNumber > 0 && DisplayHeader && HeaderOnEachPage) { HeaderHeight = CalculateRowHeight(_Header); } return; }
public void appendPageBreak() { currentPage = new PdfPage(doc); cont = new PdfContents(currentPage); drawY = pageHeight; appendPageHeader(); appendPageFooter(); }
void DrawSubtotal(PdfContents content) { string betrag; content.DrawText(fontDefault, 10D, xSummary, lastPosition - 5, DrawStyle.Normal, "Zwischensumme:"); betrag = string.Format("{0:N2}", zwischenSumme); content.DrawText(fontDefault, 10D, xRightMargin - 1, lastPosition - 5, TextJustify.Right, DrawStyle.Underline, System.Drawing.Color.Black, betrag); }
//////////////////////////////////////////////////////////////////// // Create article's example test PDF document //////////////////////////////////////////////////////////////////// public void Test ( Boolean Debug, String FileName ) { // Step 1: Create empty document // Arguments: page width: 8.5”, page height: 11”, Unit of measure: inches // Return value: PdfDocument main class Document = new PdfDocument(PaperType.Letter, false, UnitOfMeasure.Inch, FileName); // for encryption test // Document.SetEncryption(Permission.All & ~Permission.Print); // Debug property // By default it is set to false. Use it for debugging only. // If this flag is set, PDF objects will not be compressed, font and images will be replaced // by text place holder. You can view the file with a text editor but you cannot open it with PDF reader. Document.Debug = Debug; // Step 2: create resources // define font resources DefineFontResources(); // define tiling pattern resources DefineTilingPatternResource(); // Step 3: Add new page Page = new PdfPage(Document); // Step 4:Add contents to page Contents = new PdfContents(Page); // Step 5: add graphices and text contents to the contents object DrawFrameAndBackgroundWaterMark(); DrawTwoLinesOfHeading(); DrawHappyFace(); DrawBarcode(); DrawBrickPattern(); DrawImage(); DrawHeart(); DrawChart(); DrawTextBox(); DrawBookOrderForm(); // Step 6: create pdf file // argument: PDF file name Document.CreateFile(); //FileName); // start default PDF reader and display the file Process Proc = new Process(); Proc.StartInfo = new ProcessStartInfo(FileName); Proc.Start(); // exit return; }
public PdfExport() { PdfStream = new MemoryStream(); PdfDocument = new PdfDocument(PaperType.A4, false, UnitOfMeasure.Inch, PdfStream); PdfPage = new PdfPage(PdfDocument); PdfContents = new PdfContents(PdfPage); }
//////////////////////////////////////////////////////////////////// /// <summary> /// Add pages to PDF document /// </summary> /// <remarks> /// The PrintDoc.Print method will call BeginPrint method, /// next it will call multiple times PrintPage method and finally /// it will call EndPrint method. /// </remarks> //////////////////////////////////////////////////////////////////// public void AddPagesToPdfDocument() { // print the document by calling BeginPrint, PrintPage multiple times and finally EndPrint Print(); // get printing results in the form of array of images one per page // image format is Metafile PreviewPageInfo[] PageInfo = ((PreviewPrintController)PrintController).GetPreviewPageInfo(); // page size in user units Double PageWidth = Document.PageSize.Width / Document.ScaleFactor; Double PageHeight = Document.PageSize.Height / Document.ScaleFactor; // define empty image source rectangle Rectangle SourceRect = new Rectangle(); // add pages to pdf document for (Int32 ImageIndex = 0; ImageIndex < PageInfo.Length; ImageIndex++) { // add page to document PdfPage Page = new PdfPage(Document); // add contents to the page PdfContents Contents = new PdfContents(Page); // page image Image PageImage = PageInfo[ImageIndex].Image; // no crop if (CropRect.IsEmpty) { // convert metafile image to PdfImage PdfImage Image = new PdfImage(Contents.Document, PageImage, Resolution); // draw the image Contents.DrawImage(Image, 0.0, 0.0, PageWidth, PageHeight); } // crop else { Int32 ImageWidth = PageImage.Width; Int32 ImageHeight = PageImage.Height; SourceRect.X = (Int32)(ImageWidth * CropRect.X / PageWidth + 0.5); SourceRect.Y = (Int32)(ImageHeight * CropRect.Y / PageHeight + 0.5); SourceRect.Width = (Int32)(ImageWidth * CropRect.Width / PageWidth + 0.5); SourceRect.Height = (Int32)(ImageHeight * CropRect.Height / PageHeight + 0.5); // convert metafile image to PdfImage PdfImage PdfPageImage = new PdfImage(Contents.Document, PageImage, SourceRect, Resolution); // draw the image Contents.DrawImage(PdfPageImage, CropRect.X, PageHeight - CropRect.Y - CropRect.Height, CropRect.Width, CropRect.Height); } } return; }
public void OnePage ( int Cols, int Rows ) { // Add new page PdfPage Page = new PdfPage(Document); // Add contents to page PdfContents Contents = new PdfContents(Page); double Left = CenterX - 0.5 * Cols; double Right = CenterX + 0.5 * Cols; double Top = CenterY + 0.5 * Rows; double Bottom = CenterY - 0.5 * Rows; Contents.DrawText(ArialFont, FontSize, CenterX, Top + Descent + 0.2, TextJustify.Center, Cols == Rows ? "Square" : "Rectangle"); // save state Contents.SaveGraphicsState(); Contents.SetLineWidth(0.1); Contents.SetColorStroking(Color.Black); Contents.SetColorNonStroking(Color.LightBlue); Contents.DrawRectangle(Left, Bottom, Cols, Rows, PaintOp.CloseFillStroke); Contents.RestoreGraphicsState(); Contents.SaveGraphicsState(); Contents.SetLineWidth(0.04); for (int Row = 0; Row <= Rows; Row++) { Contents.DrawLine(Left - 0.25, Bottom + Row, Right, Bottom + Row); Contents.DrawText(ArialFont, FontSize, Left - 0.35, Bottom + Row - Descent, TextJustify.Right, Row.ToString()); } for (int Col = 0; Col <= Cols; Col++) { Contents.DrawLine(Left + Col, Bottom - 0.25, Left + Col, Top); Contents.DrawText(ArialFont, FontSize, Left + Col, Bottom - 0.25 - FontHeight, TextJustify.Center, Col.ToString()); } for (int Index = 0; Index < Rows * Cols; Index++) { int Row = Index / Cols; int Col = Index % Cols; Contents.DrawText(ArialFont, FontSize, Left + 0.5 + Col, Top - 0.5 - Descent - Row, TextJustify.Center, (Index + 1).ToString()); } Contents.DrawText(ArialFont, FontSize, CenterX, Bottom - 1.0, TextJustify.Center, "Area"); Contents.DrawText(ArialFont, FontSize, CenterX, Bottom - 1.4, TextJustify.Center, string.Format("{0} X {1} = {2}", Rows, Cols, Rows * Cols)); // restore graphics state Contents.RestoreGraphicsState(); return; }
public void GetInvoice() { var info = PdfInfo.CreatePdfInfo(MPdfDocument); info.Title("Faktura"); info.Author("TZ"); info.Keywords("keyword"); info.Subject("Temat"); PdfContents = new PdfContents(_page); IdFaktury(_mInvoiceData.InvoiceNumber); double lastPosition = 26; CreateTable(_mInvoiceData.HeaderLeft, 1.3, 10, 8, lastPosition, lastPosition - 3, false, ContentAlignment.MiddleLeft); lastPosition = CreateTable(_mInvoiceData.HeaderRight, 10.3, 16, 8, lastPosition, lastPosition - 1.5, false, ContentAlignment.MiddleLeft); lastPosition = CreateTable(_mInvoiceData.GetSprzeNaby, 1.3, 30, 8, lastPosition - 1.4, lastPosition - 6.2, true, ContentAlignment.MiddleLeft); var widthRow = ArialNormal.TextWidth(8, _mInvoiceData.NrBankowyLeftRight) + 0.25; lastPosition = CreateTable(_mInvoiceData.NrBankowy, 1.3, 1.3 + widthRow, 8, lastPosition - 1, lastPosition - 6.2, false, ContentAlignment.MiddleLeft); lastPosition = TabelaDaneFaktura(1.3, lastPosition - 1, lastPosition - 11, 19.7, 9, _mInvoiceData.DataServices); RazemWTym(12.03, lastPosition - 0.018, lastPosition - 11, 9); lastPosition = Summary(12.03, lastPosition - 0.018, lastPosition - 11, 19.7, 9, _mInvoiceData.SummaryServiceValues); widthRow = ArialNormal.TextWidth(8, _mInvoiceData.ZapDoZapLeftRight) + 0.25; CreateTable(_mInvoiceData.ZapDoZap, 1.3, 1.3 + widthRow, 8, lastPosition - 1, lastPosition - 10, false, ContentAlignment.MiddleLeft); widthRow = ArialNormal.TextWidth(12, _mInvoiceData.SummaryLeftRight); lastPosition = CreateTable(_mInvoiceData.Summary, 19.7 - widthRow, 19.7, 12, lastPosition - 1, lastPosition - 10, false, ContentAlignment.MiddleRight); widthRow = ArialNormal.TextWidth(8, _mInvoiceData.SummaryTextLeftRight); lastPosition = CreateTable(_mInvoiceData.SummaryText, 19.7 - widthRow, 19.7, 8, lastPosition, lastPosition - 10, false, ContentAlignment.MiddleRight); RamkiEnd(1.3, lastPosition - 1.4, lastPosition - 5, 9, 7, DictionaryMain.LabelPodpisWystawiania); RamkiEnd(12, lastPosition - 1.4, lastPosition - 5, 19.7, 7, DictionaryMain.LabelPodpisOdbierania); MPdfDocument.CreateFile(); }
/// <summary> /// PdfTable constructor. /// </summary> /// <param name="Page">Current PdfPage.</param> /// <param name="Contents">Current PdfContents.</param> /// <param name="Font">Table's default font.</param> /// <param name="FontSize">Table's default font size.</param> public PdfTable ( PdfPage Page, PdfContents Contents, PdfFont Font = null, double FontSize = 9.0 ) { // save arguments Document = Page.Document; this.Page = Page; this.Contents = Contents; // See if at least one font is defined. Make it the default font for the table if (Font == null) { foreach (var Obj in Document.ObjectArray) { if (Obj.GetType() == typeof(PdfFont)) { Font = (PdfFont)Obj; break; } } } // initialize default cell style DefaultCellStyle = new PdfTableStyle { Font = Font, FontSize = FontSize }; DefaultCellStyle.Margin.Left = DefaultCellStyle.Margin.Right = 3.0 / Document.ScaleFactor; DefaultCellStyle.Margin.Bottom = DefaultCellStyle.Margin.Top = 1.0 / Document.ScaleFactor; // initialize default header style DefaultHeaderStyle = CellStyle; DefaultHeaderStyle.BackgroundColor = Color.LightGray; // default table area TableArea = new PdfRectangle(72.0 / Page.ScaleFactor, 72.0 / Page.ScaleFactor, (Page.Width - 72.0) / Page.ScaleFactor, (Page.Height - 72.0) / Page.ScaleFactor); // set header on each page as the default HeaderOnEachPage = true; // create table border control Borders = new PdfTableBorder(this); // very small amount 1/300 of an inch // used to guard against rounding errors Epsilon = Document.Epsilon; }
/// <inheritdoc/> protected override void ExportPageBegin(ReportPage page) { // begin and prepare base.ExportPageBegin(page); pdfPage = new PdfPage(); pdfPage.Parent = pdfPagesLink; pdfPage.MediaBox = new System.Drawing.RectangleF(0, 0, ExportUtils.GetPageWidth(page) * PdfWriter.PDF_PAGE_DIVIDER, ExportUtils.GetPageHeight(page) * PdfWriter.PDF_PAGE_DIVIDER); // export page as one image { ClearBitmaps(); scaleFactor = ImageDpi / 96f; int width = (int)(ExportUtils.GetPageWidth(page) * scaleFactor * Units.Millimeters); int height = (int)(ExportUtils.GetPageHeight(page) * scaleFactor * Units.Millimeters); // check for max bitmap object size // 2GB (max .net object size) / 4 (Format32bppArgb is 4 bytes) // see http://stackoverflow.com/a/29175905/4667434 const ulong maxPixels = 536870912; if ((ulong)width * (ulong)height < maxPixels) { pageBitmap = new Bitmap(width, height); pageGraphics = Graphics.FromImage(pageBitmap); pageGraphics.TranslateTransform(this.scaleFactor * page.LeftMargin * Units.Millimeters, this.scaleFactor * page.TopMargin * Units.Millimeters, System.Drawing.Drawing2D.MatrixOrder.Append); //pageGraphics.ScaleTransform(scale, scale, System.Drawing.Drawing2D.MatrixOrder.Append); } } pageContent = new PdfContents(); // export page background using (TextObject pageFill = new TextObject()) { pageFill.Fill = page.Fill; pageFill.Left = -page.LeftMargin * Units.Millimeters; pageFill.Top = -page.TopMargin * Units.Millimeters; pageFill.Width = ExportUtils.GetPageWidth(page) * Units.Millimeters; pageFill.Height = ExportUtils.GetPageHeight(page) * Units.Millimeters; ExportObj(pageFill); } // export bottom watermark if (page.Watermark.Enabled && !page.Watermark.ShowImageOnTop) { AddImageWatermark(page); } if (page.Watermark.Enabled && !page.Watermark.ShowTextOnTop) { AddTextWatermark(page); } }
public PdfOutput(bool grayscale, string outputPath) { this.grayscale = grayscale; this.outputPath = outputPath; sisred = grayscale ? Color.DarkGray : Color.FromArgb(0, 60, 123); doc = new PdfDocument(pageWidth, pageHeight, UnitOfMeasure.Inch, outputPath); currentPage = new PdfPage(doc); cont = new PdfContents(currentPage); logoFont = PdfFont.CreatePdfFont(doc, "Times", FontStyle.Regular, false); contentFont = PdfFont.CreatePdfFont(doc, "Arial", FontStyle.Regular, false); boldFont = PdfFont.CreatePdfFont(doc, "Arial", FontStyle.Bold, false); drawY = pageHeight; }
//////////////////////////////////////////////////////////////////// // Create chart example //////////////////////////////////////////////////////////////////// public void Test ( bool Debug, string FileName ) { // Step 1: Create empty document // Arguments: page width: 8.5”, page height: 11”, Unit of measure: inches // Return value: PdfDocument main class Document = new PdfDocument(PaperType.Letter, false, UnitOfMeasure.Inch, FileName); // Debug property // By default it is set to false. Use it for debugging only. // If this flag is set, PDF objects will not be compressed, font and images will be replaced // by text place holder. You can view the file with a text editor but you cannot open it with PDF reader. Document.Debug = Debug; // Step 3: Add new page Page = new PdfPage(Document); // Step 4: Add contents to page Contents = new PdfContents(Page); // Step 5: draw charts DrawPieChart(); DrawColumnChart(); // Step 3: Add new page Page = new PdfPage(Document); // Step 4: Add contents to page Contents = new PdfContents(Page); // Step 5: draw charts DrawStockChart(); DrawPyramidChart(); // Step 6: create pdf file // argument: PDF file name Document.CreateFile(); // start default PDF reader and display the file Process Proc = new Process(); Proc.StartInfo = new ProcessStartInfo(FileName); Proc.Start(); // exit return; }
/// <summary> /// Add a new page to the document and reset the PagePosition /// </summary> public void NewPage() { this.checkBuilderState(); this.page = new PdfPage(this.document); this.contents = new PdfContents(this.page); // set initial position to top left corner this.pagePosition = new PointD(this.documentOptions.MarginLeft, (this.pageDimensions.Height - this.documentOptions.MarginTop)); // invoke any page header and footer event handlers this.PageHeader?.Invoke(this, new PageHeaderEventArgs()); this.PageFooter?.Invoke(this, new PageFooterEventArgs()); }
// start a new page private void CreateNewPage() { // terminate activity on current page if (DrawingActive) { // draw border and grid on current page DrawBorders(); // call user event handler for end of table on each page if (TableEndEvent != null) { TableEndEvent(this, _RowTopPosition); } // update page number TablePageNumber++; } // commit to PDF file if (CommitToPdfFile) { Contents.CommitToPdfFile(CommitGCCollectFreq > 0 && (CommitGCCollectFreq == 1 || (TablePageNumber % CommitGCCollectFreq) == (CommitGCCollectFreq - 1))); } // create a new page as a clone of the previous page Page = new PdfPage(Page); Contents = new PdfContents(Page); // reset border lines BorderRowTopPos = _TableArea.Top; BorderYPos.Clear(); BorderYPos.Add(BorderRowTopPos); // initial row position on the page _RowTopPosition = TableTopLimit; // calculate header height if (DrawingActive && DisplayHeader && HeaderOnEachPage) { CalculateHeaderHeight(); } // call user event handler for start of table on each page if (TableStartEvent != null) { TableStartEvent(this, BorderRowTopPos); } return; }
//////////////////////////////////////////////////////////////////// // Add page to document and draw page number //////////////////////////////////////////////////////////////////// public PdfContents AddPageToDocument ( Int32 PageNo ) { // add new page with two contents objects Page = new PdfPage(Document); Page.AddContents(BaseContents); PdfContents Contents = new PdfContents(Page); // draw page number right justified Contents.SaveGraphicsState(); //Contents.DrawText(ArialNormal, 10, PageWidth - Margin, PageHeight - 0.75 - ArialNormal.CapHeight(10), TextJustify.Right, String.Format("Page {0}", PageNo)); Contents.RestoreGraphicsState(); return(Contents); }
//////////////////////////////////////////////////////////////////// // Create article's example test PDF document //////////////////////////////////////////////////////////////////// public static void GenerateWelcomeLetterSimple(String FileName, CustomerInformation customer, List <Account> accountList, BranchInfo branch, bool inclEmail, Boolean Debug = false) { // Create an empty pdf document in A4 and measured in cm bool landscape = false; document = new PdfDocument(PaperType.A4, landscape, UnitOfMeasure.cm, FileName); // Set debug tag document.Debug = Debug; // Write Pdf info PdfInfo Info = PdfInfo.CreatePdfInfo(document); Info.Title("Welcome Letter - Bank of China"); Info.Author("Bank of China " + branch.GetAddress()[0]); Info.Keywords("Account, Bank of China, Remittance"); Info.Subject("Remittance information for Bank of China accounts"); // define font resources DefineFontResources(); // Add first page, also the only page for simple welcome letter Page = new PdfPage(document); // Add contents to page Contents = new PdfContents(Page); // Add graphices and text contents to the contents object DrawTitle(); if (customer.HasAddress()) { DrawCustomerNameAddress(customer); } DrawBranchNameAddress(branch, inclEmail); DrawLetterGreeting(customer); DrawBankInformation(customer); DrawAccountInformationForm(accountList); DrawLetterBody(); DrawGroupContact(); // Create pdf file document.CreateFile(); // exit return; }
//////////////////////////////////////////////////////////////////// /// <summary> /// Add existing contents to page /// </summary> /// <param name="Contents">Contents object</param> //////////////////////////////////////////////////////////////////// public void AddContents ( PdfContents Contents ) { // set page contents flag Contents.PageContents = true; // add content to content array if (ContentsArray == null) { ContentsArray = new List <PdfContents>(); } ContentsArray.Add(Contents); // exit return; }
//////////////////////////////////////////////////////////////////// // Draw heart //////////////////////////////////////////////////////////////////// private void DrawHeart ( PdfContents Contents ) { // save graphics state Contents.SaveGraphicsState(); // draw heart // The first argument are the coordinates of the centerline of the heart shape. // The DrawHeart is a special case of DrawDoubleBezierPath method. Contents.SetColorNonStroking(Color.HotPink); Contents.DrawHeart(new LineD(new PointD(5.14, 5.1), new PointD(5.14, 6.0)), PaintOp.CloseFillStroke); // restore graphics state Contents.RestoreGraphicsState(); return; }
//////////////////////////////////////////////////////////////////// // Draw Happy Face //////////////////////////////////////////////////////////////////// private void DrawHappyFace ( PdfContents Contents ) { // save graphics state Contents.SaveGraphicsState(); // translate coordinate origin to the center of the happy face Contents.Translate(4.25, 7.5); // change nonstroking (fill) color to yellow Contents.SetColorNonStroking(Color.Yellow); // draw happy face yellow oval Contents.DrawOval(-1.5, -1.0, 3.0, 2.0, PaintOp.Fill); // set line width to 0.2" this is the black circle around the eye Contents.SetLineWidth(0.2); // eye color is white with black outline circle Contents.SetColorNonStroking(Color.White); Contents.SetColorStroking(Color.Black); // draw eyes Contents.DrawOval(-0.75, 0.0, 0.5, 0.5, PaintOp.CloseFillStroke); Contents.DrawOval(0.25, 0.0, 0.5, 0.5, PaintOp.CloseFillStroke); // mouth color is black Contents.SetColorNonStroking(Color.Black); // draw mouth by creating a path made of one line and one Bezier curve Contents.MoveTo(-0.6, -0.4); Contents.LineTo(0.6, -0.4); Contents.DrawBezier(0.0, -0.8, 0, -0.8, -0.6, -0.4); // fill the path with black color Contents.SetPaintOp(PaintOp.Fill); // restore graphics sate Contents.RestoreGraphicsState(); return; }
//////////////////////////////////////////////////////////////////// // Draw six sided regular polygon //////////////////////////////////////////////////////////////////// private void DrawStar ( PdfContents Contents ) { // save graphics state Contents.SaveGraphicsState(); // Regular polygon // Coordinate of center point is PosX=6.67" PosY=5.7" // Radius of end points is 0.7" // First drawing point is at 30 degrees (in radians PI / 6). // Number of sides is 6 Contents.SetColorNonStroking(Color.Turquoise); Contents.DrawStar(6.67, 5.7, 0.7, Math.PI / 6, 6, PaintOp.CloseFillStroke); // restore graphics state Contents.RestoreGraphicsState(); return; }
static private void ShowFirstPageContent(string filename) { PdfDocument document = new PdfDocument(); document.Load(filename, false); PdfContents contents = document.Catalog.Pages[0].Contents; // Get a parser for decoding the contents of the page PdfContentsParser parser = contents.CreateParser(); // Keep getting new content commands until no more left PdfObject obj = null; while ((obj = parser.GetObject()) != null) { Console.WriteLine(obj); } document.Close(); }
private void button2_Click(object sender, EventArgs e) { if (folderDiag.SelectedPath != null && folderDiag.SelectedPath != "") { textBox1.Text = "Adding pages"; Image[] pages = System.IO.Directory.GetFiles(folderDiag.SelectedPath) .Select(file => System.Drawing.Image.FromFile(file)) .ToArray(); string title = titleBox.Text == "Title" ? "untitled" : titleBox.Text; PdfDocument book = new PdfDocument(title + ".pdf"); PdfPage page; PdfContents contents; PdfImage pic; foreach (Image i in pages) { double height = i.Height; double width = i.Width; page = new PdfPage(book, width, height); contents = new PdfContents(page); contents.SaveGraphicsState(); pic = new PdfImage(book, i); contents.DrawImage(pic, 0, 0, width, height); contents.RestoreGraphicsState(); contents.CommitToPdfFile(true); } book.CreateFile(); textBox1.Text = "Book created"; pages = null; book = null; page = null; contents = null; pic = null; } else { textBox1.Text = "No directory selected"; } }
void DrawSummary(PdfContents content, Offer offer) { content.SaveGraphicsState(); // Textbox für Nettopreishinweis, Zahlungs- und Lieferbedingungen var livingInABox = new TextBox(125); var nl = Environment.NewLine; string nettopreise = "Alle angegebenen Preise in Euro, zuzüglich der gesetzlich gültigen Mehrwertsteuer."; livingInABox.AddText(fontDefault, 8.0, nettopreise + nl); livingInABox.AddText(fontDefault, 8.0, this.myOffer.Zahlungsbedingungen + nl); livingInABox.AddText(fontDefault, 8.0, this.myOffer.Customer.FocText); double yPosition = lastPosition - 4; content.DrawText(10.5, ref yPosition, 0.0, 0, 0.0, 1.2, TextBoxJustify.Left, livingInABox); string betrag; // Nettosumme content.DrawText(fontDefault, 10D, xSummary, lastPosition - 5, DrawStyle.Normal, "Summe (netto):"); betrag = string.Format("{0:N2}", offer.NetAmount); content.DrawText(fontDefault, 10D, xRightMargin - 1, lastPosition - 5, TextJustify.Right, DrawStyle.Normal, System.Drawing.Color.Black, betrag); // USt. content.DrawText(fontDefault, 10D, xSummary, lastPosition - 9.2, DrawStyle.Normal, "USt. Betrag: (19%):"); betrag = string.Format("{0:N2}", offer.TaxAmount); content.DrawText(fontDefault, 10D, xRightMargin - 1, lastPosition - 9.2, TextJustify.Right, DrawStyle.Normal, System.Drawing.Color.Black, betrag); // Angebotsbetrag content.DrawText(fontDefault, 10D, xSummary, lastPosition - 13.4, DrawStyle.Normal, "Angebotsbetrag:"); betrag = string.Format("{0:N2}", offer.OfferTotal); content.DrawText(fontDefault, 10D, xRightMargin - 1, lastPosition - 13.4, TextJustify.Right, DrawStyle.Underline, System.Drawing.Color.Black, betrag); content.DrawText(fontDefault, 8D, xSummary, lastPosition - 17.6, TextJustify.Left, DrawStyle.Normal, System.Drawing.Color.DarkGray, "(Alle ausgewiesenen Beträge in Euro)"); content.RestoreGraphicsState(); }
public void Test ( Boolean Debug, String InputFileName ) { // fish artwork from your favorite wpf or svg editing software (AI, Blend, Expression Design) // for hand writing minipath strings please see SVG or WPF reference on it (for example, https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths) string FishPathText = "M 73.302,96.9831C 88.1275,96.9831 100.146,109.002 100.146,123.827C 100.146,138.653 88.1275,150.671 73.302,150.671" + "C 58.4764,150.671 46.458,138.653 46.458,123.827C 46.458,109.002 58.4764,96.9831 73.302,96.9831 Z M 80.3771,118.625" + "C 87.8473,118.625 93.9031,124.681 93.9031,132.151C 93.9031,139.621 87.8473,145.677 80.3771,145.677C 72.9068,145.677 66.851,139.621 66.851,132.151" + "C 66.851,124.681 72.9069,118.625 80.3771,118.625 Z M 124.936,229.489L 124.936,230.05C 142.757,230.05 157.205,187.542 157.205,135.105" + "C 157.205,82.6682 142.757,40.1597 124.936,40.1597L 124.936,40.7208C 140.016,40.7208 152.241,82.9781 152.241,135.105" + "C 152.241,187.232 140.016,229.489 124.936,229.489 Z M 155.904,33.5723C 168.593,40.8964 181.282,48.2205 184.749,59.0803" + "C 188.216,69.9401 182.461,84.3356 176.705,98.7312C 187.217,82.7698 197.73,66.8085 194.263,55.9487C 190.796,45.0889 173.35,39.3306 155.904,33.5723 Z " + "M 221.06,47.217C 231.336,54.9565 241.612,62.6958 243.473,72.5309C 245.334,82.366 238.779,94.2968 232.224,106.228" + "C 243.092,93.4406 253.96,80.6536 252.099,70.8185C 250.238,60.9834 235.649,54.1002 221.06,47.217 Z M 190.088,103.489" + "C 200.631,113.663 211.175,123.836 211.914,135.212C 212.654,146.588 203.591,159.166 194.527,171.744C 208.585,158.796 222.643,145.848 221.903,134.472" + "C 221.163,123.096 205.625,113.293 190.088,103.489 Z M 227.222,175.988C 233.667,185.231 240.112,194.474 238.981,203.168" + "C 237.849,211.862 229.142,220.007 220.434,228.153C 232.965,220.47 245.497,212.787 246.628,204.093C 247.759,195.399 237.49,185.693 227.222,175.988 Z " + "M 176.183,170.829C 182.085,184.24 187.987,197.65 184.36,208.457C 180.734,219.265 167.58,227.47 154.426,235.675C 172.342,229.02 190.258,222.366 193.884,211.558" + "C 197.511,200.75 186.847,185.79 176.183,170.829 Z M 253.24,114.388C 261.541,123.744 269.842,133.1 269.72,142.831" + "C 269.598,152.561 261.052,162.667 252.506,172.773C 265.327,162.683 278.148,152.592 278.27,142.861C 278.392,133.13 265.816,123.759 253.24,114.388 Z " + "M 19.3722,114.348C 33.8527,95.7363 61.0659,59.7511 97.8151,40.6822C 117.532,30.4513 139.994,25.0899 164.816,24.6372" + "C 165.876,24.1644 167.083,23.6525 168.454,23.0983C 181.841,17.6879 210.836,8.25439 232.2,4.09256C 253.564,-0.0693054 267.298,1.04053 273.749,4.99429" + "C 280.2,8.94803 279.368,15.7458 278.743,24.4856C 278.119,33.2255 277.703,43.9076 276.94,49.1099C 276.927,49.2001 276.913,49.2887 276.9,49.3756" + "C 318.05,66.1908 360.168,89.8268 395.044,112.964C 408.876,122.14 421.569,131.238 433.26,140.058C 439.423,134.13 445.322,128.267 450.904,122.587" + "C 478.22,94.7909 497.963,71.3744 513.5,56.0696C 529.037,40.7648 540.368,33.5717 541.331,39.3597C 542.295,45.1478 532.891,63.9171 528.998,87.7075" + "C 525.105,111.498 526.722,140.309 533.661,167.068C 540.599,193.827 552.858,218.532 549.803,224.507C 546.748,230.482 528.378,217.727 502.239,196.166" + "C 483.768,180.932 461.418,161.301 433.26,140.058C 409.264,163.142 381.252,187.219 352.261,205.363C 315.824,228.167 277.841,241.6 230.108,245.486" + "C 182.376,249.372 124.895,243.713 84.9205,225.782C 44.946,207.851 22.4781,177.648 11.4752,160.545C 0.472214,143.443 0.934143,139.44 2.03903,136.819" + "C 3.14392,134.199 4.89172,132.96 19.3722,114.348 Z "; // water artwork string WavePathOriginal = "M 0.000854492,723.999L 1106,723.999L 1106,616.629C 1025.42,656.405 941.978,687.324 846.084,679.721C 721.562,669.847 576.045,595.015 425.822,588.779" + "C 286.673,583.003 143.486,636.082 0.000854492,693.5L 0.000854492,723.999 Z M 423.35,26.0787C 573.573,32.3146 719.09,107.146 843.612,117.02C 940.487,124.701 1024.65,93.0672 1106,52.7042" + "L 1106,-1.90735e-005L 0.000854492,-1.90735e-005L 0.000854492,129.811C 142.658,72.7739 285,20.3355 423.35,26.0787 Z M 6.10352e-005,545.976C 143.485,488.558 286.672,435.478 425.822,441.255" + "C 576.045,447.491 721.562,522.322 846.084,532.196C 941.978,539.8 1025.42,508.88 1106,469.104L 1106,200.228C 1024.65,240.592 940.486,272.226 843.611,264.544" + "C 719.089,254.671 573.572,179.839 423.349,173.603C 284.999,167.86 142.657,220.298 6.10352e-005,277.335L 6.10352e-005,545.976 Z"; /* * string ItalianFish = "M73,302;96,9831C88,1275;96,9831 100,146;109,002 100,146;123,827 100,146;138,653 88,1275;150,671 73,302;150,671 58,4764;150,671 46,458;138,653 46,458;123,827 46,458;109,002 58,4764;96,9831 73,302;96,9831z M80,3771;118,625C87,8473;118,625 93,9031;124,681 93,9031;132,151 93,9031;139,621 87,8473;145,677 80,3771;145,677 72,9068;145,677 66,851;139,621 66,851;132,151 66,851;124,681 72,9069;118,625 80,3771;118,625z M124,936;229,489L124,936;230,05C142,757;230,05 157,205;187,542 157,205;135,105 157,205;82,6682 142,757;40,1597 124,936;40,1597L124,936;40,7208C140,016;40,7208 152,241;82,9781 152,241;135,105 152,241;187,232 140,016;229,489 124,936;229,489z M155,904;33,5723C168,593;40,8964 181,282;48,2205 184,749;59,0803 188,216;69,9401 182,461;84,3356 176,705;98,7312 187,217;82,7698 197,73;66,8085 194,263;55,9487 190,796;45,0889 173,35;39,3306 155,904;33,5723z M221,06;47,217C231,336;54,9565 241,612;62,6958 243,473;72,5309 245,334;82,366 238,779;94,2968 232,224;106,228 243,092;93,4406 253,96;80,6536 252,099;70,8185 250,238;60,9834 235,649;54,1002 221,06;47,217z M190,088;103,489C200,631;113,663 211,175;123,836 211,914;135,212 212,654;146,588 203,591;159,166 194,527;171,744 208,585;158,796 222,643;145,848 221,903;134,472 221,163;123,096 205,625;113,293 190,088;103,489z M227,222;175,988C233,667;185,231 240,112;194,474 238,981;203,168 237,849;211,862 229,142;220,007 220,434;228,153 232,965;220,47 245,497;212,787 246,628;204,093 247,759;195,399 237,49;185,693 227,222;175,988z M176,183;170,829C182,085;184,24 187,987;197,65 184,36;208,457 180,734;219,265 167,58;227,47 154,426;235,675 172,342;229,02 190,258;222,366 193,884;211,558 197,511;200,75 186,847;185,79 176,183;170,829z M253,24;114,388C261,541;123,744 269,842;133,1 269,72;142,831 269,598;152,561 261,052;162,667 252,506;172,773 265,327;162,683 278,148;152,592 278,27;142,861 278,392;133,13 265,816;123,759 253,24;114,388z M19,3722;114,348C33,8527;95,7363 61,0659;59,7511 97,8151;40,6822 117,532;30,4513 139,994;25,0899 164,816;24,6372 165,876;24,1644 167,083;23,6525 168,454;23,0983 181,841;17,6879 210,836;8,25439 232,2;4,09256 253,564;-0,0693054 267,298;1,04053 273,749;4,99429 280,2;8,94803 279,368;15,7458 278,743;24,4856 278,119;33,2255 277,703;43,9076 276,94;49,1099 276,927;49,2001 276,913;49,2887 276,9;49,3756 318,05;66,1908 360,168;89,8268 395,044;112,964 408,876;122,14 421,569;131,238 433,26;140,058 439,423;134,13 445,322;128,267 450,904;122,587 478,22;94,7909 497,963;71,3744 513,5;56,0696 529,037;40,7648 540,368;33,5717 541,331;39,3597 542,295;45,1478 532,891;63,9171 528,998;87,7075 525,105;111,498 526,722;140,309 533,661;167,068 540,599;193,827 552,858;218,532 549,803;224,507 546,748;230,482 528,378;217,727 502,239;196,166 483,768;180,932 461,418;161,301 433,26;140,058 409,264;163,142 381,252;187,219 352,261;205,363 315,824;228,167 277,841;241,6 230,108;245,486 182,376;249,372 124,895;243,713 84,9205;225,782 44,946;207,851 22,4781;177,648 " + * "11,4752;160,545 0,472214;143,443 0,934143;139,44 2,03903;136,819 3,14392;134,199 4,89172;132,96 19,3722;114,348z"; * * string ItalianWave = "M0,000854492;723,999L1106;723,999 1106;616,629C1025,42;656,405 941,978;687,324 846,084;679,721 721,562;669,847 576,045;595,015 425,822;588,779 286,673;583,003 143,486;636,082 0,000854492;693,5L0,000854492;723,999z M423,35;26,0787C573,573;32,3146 719,09;107,146 843,612;117,02 940,487;124,701 1024,65;93,0672 1106;52,7042L1106;-1,90735E-05 0,000854492;-1,90735E-05 0,000854492;129,811C142,658;72,7739;285;20,3355;423,35;26,0787z M6,10352E-05;545,976C143,485;488,558 286,672;435,478 425,822;441,255 576,045;447,491 721,562;522,322 846,084;532,196 941,978;539,8 1025,42;508,88 1106;469,104L1106;200,228C1024,65;240,592 940,486;272,226 843,611;264,544 719,089;254,671 573,572;179,839 423,349;173,603 284,999;167,86 142,657;220,298 6,10352E-05;277,335L6,10352E-05;545,976z"; * // water artwork * string WavePathText = "M 0,724L 1106,724L 1106,617C 1025,656 942,687 846,680C 722,670 576,595 426,589C 287,583 143,636 0,694L 0,724 Z " + * "M 423,26C 574,32 719,107 844,117C 940,125 1025,93 1106,53L 1106,0L 0,0L 0,130C 143,73 285,20 423,26 Z " + * "M 0,546C 143,489 287,435 426,441C 576,447 722,522 846,532C 942,540 1025,509 1106,469L 1106,200C 1025,241 940,272 844,265" + * "C 719,255 574,180 423,174C 285,168 143,220 0,277L 0,546 Z"; * string MyWavePathText = "M 0 0 L 1000 0 L 1000 100 C 550 550 550 -300 0 250 Z" + * "M 0 550 C 550 0 550 850 1000 400 L 1000 850 C 550 1300 550 450 0 1000 Z" + * "M 0 1400 L 0 1300 C 550 750 550 1600 1000 1150 L 1000 1400 Z"; */ // create document using (PdfDocument Document = new PdfDocument(PaperType.Letter, false, UnitOfMeasure.Inch, InputFileName)) { // define font PdfFont ArialNormal = PdfFont.CreatePdfFont(Document, "Arial", FontStyle.Regular); // Add new page PdfPage Page = new PdfPage(Document); // Add contents to page PdfContents Contents = new PdfContents(Page); // translate origin Contents.SaveGraphicsState(); // test draw // string TestDraw1 = "M 0 0 L 1000 0"; string TestDraw1 = "M 0 0 L 100 200 L 200 0 Z M 0 200 L 100 0 L 200 200 Z"; // string TestDraw1 = "M 0 0 A 400 400 0 0 0 100 200 A 400 400 0 0 0 200 0 A 400 400 0 0 0 0 0 Z" + // "M 0 250 A 400 400 0 0 1 100 -50 A 400 400 0 0 1 250 250 A 400 400 0 0 1 0 250 Z"; //string TestDraw1 = "M 0 0 L 100 200 L 200 0"; DrawWPFPath TestPath1 = new DrawWPFPath(TestDraw1, YAxisDirection.Up); TestPath1.SetBrush(Color.DarkMagenta); SysMedia.Pen Pen = new SysMedia.Pen(new SysMedia.SolidColorBrush(SysMedia.Colors.DarkBlue), 2); Pen.StartLineCap = SysMedia.PenLineCap.Flat; Pen.LineJoin = SysMedia.PenLineJoin.Bevel; Pen.DashStyle = new SysMedia.DashStyle(new double[] { 1.0 }, 0.0); TestPath1.SetPen(Pen); Contents.DrawWPFPath(TestPath1, 1.0, 4.0, 5.0, 3.0); string TestDraw2 = "M 0 0 L 200 200 A 200 200 0 1 0 0 0 Z"; DrawWPFPath TestPath2 = new DrawWPFPath(TestDraw2, YAxisDirection.Up); // string TestDraw = "M 0 200 L 200 0 A 200 200 0 1 1 0 200"; // DrawWPFPath TestPath = new DrawWPFPath(TestDraw, YAxisDirection.Down); TestPath2.SetPenWidth(0.05); TestPath2.SetPen(Color.Chocolate); Contents.DrawWPFPath(TestPath2, 4.25, 4.0, 3.0, 3.0, ContentAlignment.BottomLeft); // load fish path DrawWPFPath FishPath = new DrawWPFPath(FishPathText, YAxisDirection.Down); // set pen for both fish FishPath.SetPen(Color.FromArgb(255, 255, 80, 0)); FishPath.SetPenWidth(0.02); // PdfTilingPattern BrickPattern = PdfTilingPattern.SetBrickPattern(Document, 0.25, Color.LightYellow, Color.SandyBrown); // FishPath.SetBrush(BrickPattern); // draw small fish FishPath.SetBrush(Color.FromArgb(255, 67, 211, 216)); Contents.DrawWPFPath(FishPath, 2.5, 5.75, 4.5, 3.0, ContentAlignment.TopRight); // big fish drawing area Color[] BigFishBrushColor = new Color[] { Color.FromArgb(0xff, 0xff, 0x50, 0), Color.FromArgb(0xff, 0x27, 0xda, 0xff) }; PdfRadialShading RadialShading = new PdfRadialShading(Document, new PdfShadingFunction(Document, BigFishBrushColor)); RadialShading.SetGradientDirection(0.15, 0.5, 0.0, 0.25, 0.5, 1.3, MappingMode.Relative); FishPath.SetBrush(RadialShading, 1.0); Contents.DrawWPFPath(FishPath, 1.5, 2.0, 5.5, 5.5, ContentAlignment.BottomLeft); // load wave DrawWPFPath WavePath = new DrawWPFPath(WavePathOriginal, YAxisDirection.Up); // draw wave Color[] WaveBrushColor = new Color[] { Color.Cyan, Color.DarkBlue }; PdfAxialShading AxialShading = new PdfAxialShading(Document, new PdfShadingFunction(Document, WaveBrushColor)); AxialShading.SetAxisDirection(0.0, 1.0, 1.0, 0.0, MappingMode.Relative); WavePath.SetBrush(AxialShading, 0.55); Contents.DrawWPFPath(WavePath, 1.0, 1.0, 6.5, 9.0); // restore graphics state Contents.RestoreGraphicsState(); // create pdf file Document.CreateFile(); // start default PDF reader and display the file Process Proc = new Process(); Proc.StartInfo = new ProcessStartInfo(InputFileName); Proc.Start(); } return; }
/** * Adds some <CODE>PdfContents</CODE> to this Writer. * <P> * The document has to be open before you can begin to add content * to the body of the document. * * @return a <CODE>PdfIndirectReference</CODE> * @param page the <CODE>PdfPage</CODE> to add * @param contents the <CODE>PdfContents</CODE> of the page * @throws PdfException on error */ internal virtual PdfIndirectReference Add(PdfPage page, PdfContents contents) { if (!open) { throw new PdfException("The document isn't open."); } PdfIndirectObject objecta; objecta = AddToBody(contents); page.Add(objecta.IndirectReference); if (group != null) { page.Put(PdfName.GROUP, group); group = null; } else if (rgbTransparencyBlending) { PdfDictionary pp = new PdfDictionary(); pp.Put(PdfName.TYPE, PdfName.GROUP); pp.Put(PdfName.S, PdfName.TRANSPARENCY); pp.Put(PdfName.CS, PdfName.DEVICERGB); page.Put(PdfName.GROUP, pp); } root.AddPage(page); currentPageNumber++; return null; }
internal override PdfIndirectReference Add(PdfPage page, PdfContents contents) { return null; }