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(); }
//////////////////////////////////////////////////////////////////// // 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; }
//////////////////////////////////////////////////////////////////// // 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(null, null, Permission.All & ~Permission.Print, EncryptionType.Aes128); // 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; PdfInfo Info = PdfInfo.CreatePdfInfo(Document); Info.Title("Article Example"); Info.Author("Uzi Granot Granotech Limited"); Info.Keywords("PDF, .NET, C#, Library, Document Creator"); Info.Subject("PDF File Writer C# Class Library (Version 1.14.1)"); // 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 Document.CreateFile(); // start default PDF reader and display the file Process Proc = new Process(); Proc.StartInfo = new ProcessStartInfo(FileName); Proc.Start(); // exit return; }
public GenerujPolaWDokumencie(string FileName, SingleFakturaProperty singleFaktura) { IHelperData mHelperData = new HelperData(singleFaktura); IDaneNaglowek mDaneNaglowka = new DaneNaglowek(singleFaktura.Work.Naglowek); PdfDocument = new PdfDocument(PaperType.A4, false, UnitOfMeasure.cm, FileName) { Debug = false }; _arialBold = PdfFont.CreatePdfFont(PdfDocument, ArialFontName, FontStyle.Bold); _arialNormal = PdfFont.CreatePdfFont(PdfDocument, ArialFontName, FontStyle.Regular); var Info = PdfInfo.CreatePdfInfo(PdfDocument); Info.Title("Faktura"); Info.Author("TZ"); Info.Keywords("keyword"); Info.Subject("Temat"); _page = new PdfPage(PdfDocument); PdfContents = new PdfContents(_page); IdFaktury(singleFaktura.Work.Naglowek.NumerFaktury); double lastPosition = 26; CreateTable(mDaneNaglowka.GetNaglowekL(), 1.3, 10, 8, lastPosition, lastPosition - 3, false, ContentAlignment.MiddleLeft); lastPosition = CreateTable(mDaneNaglowka.GetNaglowekR(), 10.3, 16, 8, lastPosition, lastPosition - 1.5, false, ContentAlignment.MiddleLeft); lastPosition = CreateTable(mHelperData.GetSprzeNaby(), 1.3, 30, 8, lastPosition - 1.4, lastPosition - 6.2, true, ContentAlignment.MiddleLeft); var widthRow = _arialNormal.TextWidth(8, mHelperData.NrBankowy()[0].Lewa + mHelperData.NrBankowy()[0].Prawa) + 0.25; lastPosition = CreateTable(mHelperData.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, singleFaktura.GetListDt()); RazemWTym(12.03, lastPosition - 0.018, lastPosition - 11, 9); lastPosition = Summary(12.03, lastPosition - 0.018, lastPosition - 11, 19.7, 9, singleFaktura.GetSum()); widthRow = _arialNormal.TextWidth(8, mHelperData.GetZapDoZap()[1].Lewa + mHelperData.GetZapDoZap()[1].Prawa) + 0.25; CreateTable(mHelperData.GetZapDoZap(), 1.3, 1.3 + widthRow, 8, lastPosition - 1, lastPosition - 10, false, ContentAlignment.MiddleLeft); widthRow = _arialNormal.TextWidth(12, mHelperData.Razem()[0].Lewa + mHelperData.Razem()[0].Prawa); lastPosition = CreateTable(mHelperData.Razem(), 19.7 - widthRow, 19.7, 12, lastPosition - 1, lastPosition - 10, false, ContentAlignment.MiddleRight); widthRow = _arialNormal.TextWidth(8, mHelperData.RazemSlownie().Lewa + mHelperData.RazemSlownie().Prawa); lastPosition = CreateTable(new List <DaneTabela> { mHelperData.RazemSlownie() }, 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); PdfDocument.CreateFile(); }