private Page DrawInvoiceData(MergerInvoiceData.Order data, Document document, ref int start) { // Tracks if the invoice is finished bool invoiceFinished = true; // Tracks the y position on the page float yOffset = 288; // Create a page using "Invoice.pdf" as a template Page page = new ImportedPage(templatePath, 1); // Uncomment the line below to show a layout grid. //page.Elements.Add( new LayoutGrid() ); // Add Details to the Invoice DrawInvoiceDetails(data, page); // Add bill to address page.Elements.Add(new TextArea(data.BillTo, 28, 139, 194, 70, Font.Helvetica, 12)); // Add ship to address page.Elements.Add(new TextArea(data.ShipTo, 318, 139, 194, 70, Font.Helvetica, 12)); // Add line items to the Invoice for (int i = start; i < data.OrderDetails.Count; i++) { DrawLineItem(data.OrderDetails[i], page, ref yOffset); // Break if at the bottom of the page if (yOffset >= 666) { invoiceFinished = false; start = i + 1; break; } } // Add the page to the document document.Pages.Add(page); // If Invoice is finished return the page else return null so another page will be added if (invoiceFinished) { return(page); } else { page.Elements.Add(new Label("Continued...", 454, 704, 82, 12, Font.Helvetica, 12, TextAlign.Right)); return(null); } }
public ceTe.DynamicPDF.Document CreateSchoolCards() { // Create a document and set it's properties Document document = new Document(); document.Creator = "SchoolCard.aspx"; document.Author = "Career Cruising"; document.Title = "School Access Card"; ceTe.DynamicPDF.Page page = new ImportedPage("D:\\newmedia\\docs\\american\\AccessCardsNoEDP.pdf", 1); /* * * NOTE: ALL YOU HAVE TO DO (BELOW) IS REPLACE * "schoolUserName" AND "schoolPasswd" WITH THE * PROPER SCHOOL INFO FROM THE DATABASE * */ // label params are (text, x-pos, y-pos, width, height, font, size) page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(AdminInfo["SchoolUserName"].ToString(), 108, 108, 150, 1, Font.Helvetica, 12)); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(AdminInfo["SchoolPassword"].ToString(), 108, 135, 150, 1, Font.Helvetica, 12)); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(AdminInfo["SchoolUserName"].ToString(), 397, 108, 150, 1, Font.Helvetica, 12)); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(AdminInfo["SchoolPassword"].ToString(), 397, 135, 150, 1, Font.Helvetica, 12)); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(AdminInfo["SchoolUserName"].ToString(), 108, 299, 150, 1, Font.Helvetica, 12)); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(AdminInfo["SchoolPassword"].ToString(), 108, 326, 150, 1, Font.Helvetica, 12)); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(AdminInfo["SchoolUserName"].ToString(), 397, 299, 150, 1, Font.Helvetica, 12)); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(AdminInfo["SchoolPassword"].ToString(), 397, 326, 150, 1, Font.Helvetica, 12)); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(AdminInfo["SchoolUserName"].ToString(), 108, 490, 150, 1, Font.Helvetica, 12)); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(AdminInfo["SchoolPassword"].ToString(), 108, 517, 150, 1, Font.Helvetica, 12)); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(AdminInfo["SchoolUserName"].ToString(), 397, 490, 150, 1, Font.Helvetica, 12)); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(AdminInfo["SchoolPassword"].ToString(), 397, 517, 150, 1, Font.Helvetica, 12)); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(AdminInfo["SchoolUserName"].ToString(), 108, 681, 150, 1, Font.Helvetica, 12)); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(AdminInfo["SchoolPassword"].ToString(), 108, 708, 150, 1, Font.Helvetica, 12)); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(AdminInfo["SchoolUserName"].ToString(), 397, 681, 150, 1, Font.Helvetica, 12)); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(AdminInfo["SchoolPassword"].ToString(), 397, 708, 150, 1, Font.Helvetica, 12)); document.Pages.Add(page); // Outputs the Access Cards to the current web page document.DrawToWeb("schoolCard.pdf"); Response.End(); return document; }
public ceTe.DynamicPDF.Document CreatePDF() { // Create a document and set it's properties Document document = new Document(); document.Creator = "AccessCard.aspx"; document.Author = "Career Cruising"; document.Title = "Access Card"; string pagePath; int pdfType; Array[] pdfCoords = new Array[8]; if (PortTypeElements["Mnu_DocsLink_EDP"].ToString() == "1") { pdfType = 2; } else if (PortTypeElements["Mnu_DocsLink_KY"].ToString() == "1") { pdfType = 4; } else if (PortTypeElements["Mnu_DocLink_DE"].ToString() == "1") { pdfType = 6; } else if (PortTypeElements["Mnu_DocLink_SD"].ToString() == "1") { pdfType = 7; } else if (PortTypeElements["Mnu_DocsLink_Port"].ToString() == "1") { pdfType = 1; } else { pdfType = 1; } /* // get pdfType from querystring (if it exists) if (Request.QueryString["pdfType"] != null) { pdfType = int.Parse(Request.QueryString["pdfType"]); // catch any unexpected types //if (pdfType != 1 || pdfType != 2 || pdfType != 3 || pdfType != 4 || pdfType != 5 || pdfType != 6) //{ // pdfType = 1; // for testing // this needs to be an error trapping case (pdfType should always be between 1 and 7) //} } else { pdfType = 1; // for testing // this is the case where pdfType is null } */ // set pdf file source and associated username/passwd positions (coordinates) in the pdf (for one page) if (pdfType == 1) { // from /School/HelpfulDocumentsCA.aspx // or /School/HelpfulDocumentsCA_ON.aspx // or /School/HelpfulDocumentsUS.aspx // use AccessCardsPort_1007.pdf pagePath = "D:\\newmedia\\docs\\canadian\\AccessCardsPort_1007.pdf"; pdfCoords[0] = new int[,] { { 109, 79 }, { 128, 111 }, { 128, 126 }, { 165, 163 }, { 165, 178 } }; pdfCoords[1] = new int[,] { { 109, 259 }, { 128, 291 }, { 128, 306 }, { 165, 343 }, { 165, 358 } }; pdfCoords[2] = new int[,] { { 109, 439 }, { 128, 471 }, { 128, 486 }, { 165, 523 }, { 165, 538 } }; pdfCoords[3] = new int[,] { { 109, 619 }, { 128, 651 }, { 128, 666 }, { 165, 703 }, { 165, 718 } }; pdfCoords[4] = new int[,] { { 361, 79 }, { 381, 111 }, { 381, 126 }, { 417, 163 }, { 417, 178 } }; pdfCoords[5] = new int[,] { { 361, 259 }, { 381, 291 }, { 381, 306 }, { 417, 343 }, { 417, 358 } }; pdfCoords[6] = new int[,] { { 361, 439 }, { 381, 471 }, { 381, 486 }, { 417, 523 }, { 417, 538 } }; pdfCoords[7] = new int[,] { { 361, 619 }, { 381, 651 }, { 381, 666 }, { 417, 703 }, { 417, 718 } }; } else if (pdfType == 2) { // from /School/HelpfulDocumentsEDP.aspx // use AccessCardsEDP_1007.pdf pagePath = "D:\\newmedia\\docs\\american\\AccessCardsEDP_1007.pdf"; pdfCoords[0] = new int[,] { { 109, 79 }, { 128, 111 }, { 128, 126 }, { 145, 163 }, { 145, 178 } }; pdfCoords[1] = new int[,] { { 109, 259 }, { 128, 291 }, { 128, 306 }, { 145, 343 }, { 145, 358 } }; pdfCoords[2] = new int[,] { { 109, 439 }, { 128, 471 }, { 128, 486 }, { 145, 523 }, { 145, 538 } }; pdfCoords[3] = new int[,] { { 109, 619 }, { 128, 651 }, { 128, 666 }, { 145, 703 }, { 145, 718 } }; pdfCoords[4] = new int[,] { { 361, 79 }, { 381, 111 }, { 381, 126 }, { 397, 163 }, { 397, 178 } }; pdfCoords[5] = new int[,] { { 361, 259 }, { 381, 291 }, { 381, 306 }, { 397, 343 }, { 397, 358 } }; pdfCoords[6] = new int[,] { { 361, 439 }, { 381, 471 }, { 381, 486 }, { 397, 523 }, { 397, 538 } }; pdfCoords[7] = new int[,] { { 361, 619 }, { 381, 651 }, { 381, 666 }, { 397, 703 }, { 397, 718 } }; } else if (pdfType == 3) { // from /School/HelpfulDocumentsKY.aspx (student) // use AccessCardsStudentKYILP_1007.pdf pagePath = "D:\\newmedia\\docs\\american\\AccessCardsStudentKYILP_1007.pdf"; pdfCoords[0] = new int[,] { { 113, 86 }, { 148, 130 }, { 148, 152 } }; pdfCoords[1] = new int[,] { { 113, 266 }, { 148, 310 }, { 148, 332 } }; pdfCoords[2] = new int[,] { { 113, 446 }, { 148, 490 }, { 148, 512 } }; pdfCoords[3] = new int[,] { { 113, 626 }, { 148, 670 }, { 148, 692 } }; pdfCoords[4] = new int[,] { { 365, 86 }, { 400, 130 }, { 400, 152 } }; pdfCoords[5] = new int[,] { { 365, 266 }, { 400, 310 }, { 400, 332 } }; pdfCoords[6] = new int[,] { { 365, 446 }, { 400, 490 }, { 400, 512 } }; pdfCoords[7] = new int[,] { { 365, 626 }, { 400, 670 }, { 400, 692 } }; } else if (pdfType == 4) { // from /School/HelpfulDocumentsKY.aspx (parent) // use AccessCardsParentKYILP_1007.pdf pagePath = "D:\\newmedia\\docs\\american\\AccessCardsParentKYILP_1007.pdf"; pdfCoords[0] = new int[,] { { 113, 86 }, { 148, 130 }, { 148, 152 } }; pdfCoords[1] = new int[,] { { 113, 266 }, { 148, 310 }, { 148, 332 } }; pdfCoords[2] = new int[,] { { 113, 446 }, { 148, 490 }, { 148, 512 } }; pdfCoords[3] = new int[,] { { 113, 626 }, { 148, 670 }, { 148, 692 } }; pdfCoords[4] = new int[,] { { 365, 86 }, { 400, 130 }, { 400, 152 } }; pdfCoords[5] = new int[,] { { 365, 266 }, { 400, 310 }, { 400, 332 } }; pdfCoords[6] = new int[,] { { 365, 446 }, { 400, 490 }, { 400, 512 } }; pdfCoords[7] = new int[,] { { 365, 626 }, { 400, 670 }, { 400, 692 } }; } else if (pdfType == 5) { // from /School/HelpfulDocumentsDE.aspx (parent) // use AccessCardsStudentDESSP_1007.pdf pagePath = "D:\\newmedia\\docs\\american\\AccessCardsStudentDESSP_1007.pdf"; pdfCoords[0] = new int[,] { { 113, 86 }, { 148, 130 }, { 148, 152 } }; pdfCoords[1] = new int[,] { { 113, 266 }, { 148, 310 }, { 148, 332 } }; pdfCoords[2] = new int[,] { { 113, 446 }, { 148, 490 }, { 148, 512 } }; pdfCoords[3] = new int[,] { { 113, 626 }, { 148, 670 }, { 148, 692 } }; pdfCoords[4] = new int[,] { { 365, 86 }, { 400, 130 }, { 400, 152 } }; pdfCoords[5] = new int[,] { { 365, 266 }, { 400, 310 }, { 400, 332 } }; pdfCoords[6] = new int[,] { { 365, 446 }, { 400, 490 }, { 400, 512 } }; pdfCoords[7] = new int[,] { { 365, 626 }, { 400, 670 }, { 400, 692 } }; } else if (pdfType == 6) { // from /School/HelpfulDocumentsDE.aspx (parent) // use AccessCardsParentDESSP_1007.pdf pagePath = "D:\\newmedia\\docs\\american\\AccessCardsParentDESSP_1007.pdf"; pdfCoords[0] = new int[,] { { 113, 86 }, { 148, 130 }, { 148, 152 } }; pdfCoords[1] = new int[,] { { 113, 266 }, { 148, 310 }, { 148, 332 } }; pdfCoords[2] = new int[,] { { 113, 446 }, { 148, 490 }, { 148, 512 } }; pdfCoords[3] = new int[,] { { 113, 626 }, { 148, 670 }, { 148, 692 } }; pdfCoords[4] = new int[,] { { 365, 86 }, { 400, 130 }, { 400, 152 } }; pdfCoords[5] = new int[,] { { 365, 266 }, { 400, 310 }, { 400, 332 } }; pdfCoords[6] = new int[,] { { 365, 446 }, { 400, 490 }, { 400, 512 } }; pdfCoords[7] = new int[,] { { 365, 626 }, { 400, 670 }, { 400, 692 } }; } else if (pdfType == 7) { // from SD // use AccessCardsParentSD_0109.pdf pagePath = "D:\\newmedia\\docs\\american\\AccessCardsParentSD_0109.pdf"; pdfCoords[0] = new int[,] { { 148, 80 }, { 148, 98 }, { 132, 130 }, { 132, 154 } }; pdfCoords[1] = new int[,] { { 148, 260 }, { 148, 278 }, { 132, 310 }, { 132, 334 } }; pdfCoords[2] = new int[,] { { 148, 440 }, { 148, 458 }, { 132, 490 }, { 132, 514 } }; pdfCoords[3] = new int[,] { { 148, 620 }, { 148, 638 }, { 132, 670 }, { 132, 694 } }; pdfCoords[4] = new int[,] { { 400, 80 }, { 400, 98 }, { 384, 130 }, { 384, 154 } }; pdfCoords[5] = new int[,] { { 400, 260 }, { 400, 278 }, { 384, 310 }, { 384, 334 } }; pdfCoords[6] = new int[,] { { 400, 440 }, { 400, 458 }, { 384, 490 }, { 384, 514 } }; pdfCoords[7] = new int[,] { { 400, 620 }, { 400, 638 }, { 384, 670 }, { 384, 694 } }; } else { // not sure what this case should be yet - using this for testing // should be used for error trapping pagePath = "D:\\newmedia\\docs\\canadian\\AccessCardsPort_1007.pdf"; pdfCoords[0] = new int[,] { { 109, 79 }, { 128, 111 }, { 128, 126 }, { 165, 163 }, { 165, 178 } }; pdfCoords[1] = new int[,] { { 109, 259 }, { 128, 291 }, { 128, 306 }, { 165, 343 }, { 165, 358 } }; pdfCoords[2] = new int[,] { { 109, 439 }, { 128, 471 }, { 128, 486 }, { 165, 523 }, { 165, 538 } }; pdfCoords[3] = new int[,] { { 109, 619 }, { 128, 651 }, { 128, 666 }, { 165, 703 }, { 165, 718 } }; pdfCoords[4] = new int[,] { { 361, 79 }, { 381, 111 }, { 381, 126 }, { 417, 163 }, { 417, 178 } }; pdfCoords[5] = new int[,] { { 361, 259 }, { 381, 291 }, { 381, 306 }, { 417, 343 }, { 417, 358 } }; pdfCoords[6] = new int[,] { { 361, 439 }, { 381, 471 }, { 381, 486 }, { 417, 523 }, { 417, 538 } }; pdfCoords[7] = new int[,] { { 361, 619 }, { 381, 651 }, { 381, 666 }, { 417, 703 }, { 417, 718 } }; } // number of students/parents/etc that need access cards int numRecords = dtParentList.Rows.Count; // this value is set to 10 (two pages) for testing - get actual value from DB (or result of search on StudentList.aspx) // counters to keep track of position in document int curRecord = 0; // iterate through each students/parents/etc. int curCard = 0; // iterate through cards on page (0 - 7) // calculate number of pages needed for looping. there is room for 8 records per page. we want to round up the number of pages to be printed. double numPages = Math.Ceiling((double)numRecords / 8); // loop to create a pdf long enough (enough pages) to fit all students/parents/etc. for (int curPage = 1; curPage <= numPages; curPage++) { ceTe.DynamicPDF.Page page = new ImportedPage(pagePath, 1); // create a new page int lastRecordOnPage; // index of last student/parent/etc on this page if (curPage * 8 < numRecords) { lastRecordOnPage = curPage * 8; } else { lastRecordOnPage = numRecords; } curCard = 0; // reset card counter // loop through each page of students/parents/etc. for (int i = curRecord; i < lastRecordOnPage; i++) { // when filling in info from DB will use "i" as the index to associate with the student/parent/etc record // print out individual student/parent/etc details (one card - can fit 8 on one page) // depending on pdf format either 3 or 3 fields are needed per card if (pdfType == 1 || pdfType == 2) { page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(dtParentList.Rows[curRecord]["FullName"].ToString(), (int)pdfCoords[curCard].GetValue(0, 0), (int)pdfCoords[curCard].GetValue(0, 1), 165, 1, Font.Helvetica, 10)); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(AdminInfo["SchoolUserName"].ToString(), (int)pdfCoords[curCard].GetValue(1, 0), (int)pdfCoords[curCard].GetValue(1, 1), 145, 1, Font.Helvetica, 10)); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(AdminInfo["SchoolPassword"].ToString(), (int)pdfCoords[curCard].GetValue(2, 0), (int)pdfCoords[curCard].GetValue(2, 1), 145, 1, Font.Helvetica, 10)); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(dtParentList.Rows[curRecord]["UserName"].ToString(), (int)pdfCoords[curCard].GetValue(3, 0), (int)pdfCoords[curCard].GetValue(3, 1), 130, 1, Font.Helvetica, 10)); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(dtParentList.Rows[curRecord]["Password"].ToString(), (int)pdfCoords[curCard].GetValue(4, 0), (int)pdfCoords[curCard].GetValue(4, 1), 130, 1, Font.Helvetica, 10)); } else { if (pdfType == 7) { page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(dtParentList.Rows[curRecord]["FirstName"].ToString() + " " + dtParentList.Rows[curRecord]["LastName"].ToString(), (int)pdfCoords[curCard].GetValue(0, 0), (int)pdfCoords[curCard].GetValue(0, 1), 165, 1, Font.Helvetica, 10)); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(dtParentList.Rows[curRecord]["FullName"].ToString(), (int)pdfCoords[curCard].GetValue(1, 0), (int)pdfCoords[curCard].GetValue(1, 1), 165, 1, Font.Helvetica, 10)); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(dtParentList.Rows[curRecord]["UserName"].ToString(), (int)pdfCoords[curCard].GetValue(2, 0), (int)pdfCoords[curCard].GetValue(2, 1), 130, 1, Font.Helvetica, 10)); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(dtParentList.Rows[curRecord]["Password"].ToString(), (int)pdfCoords[curCard].GetValue(3, 0), (int)pdfCoords[curCard].GetValue(3, 1), 130, 1, Font.Helvetica, 10)); } else { page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(dtParentList.Rows[curRecord]["FullName"].ToString(), (int)pdfCoords[curCard].GetValue(0, 0), (int)pdfCoords[curCard].GetValue(0, 1), 165, 1, Font.Helvetica, 10)); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(dtParentList.Rows[curRecord]["UserName"].ToString(), (int)pdfCoords[curCard].GetValue(1, 0), (int)pdfCoords[curCard].GetValue(1, 1), 130, 1, Font.Helvetica, 10)); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(dtParentList.Rows[curRecord]["Password"].ToString(), (int)pdfCoords[curCard].GetValue(2, 0), (int)pdfCoords[curCard].GetValue(2, 1), 130, 1, Font.Helvetica, 10)); } } // increment counters curCard++; curRecord++; } document.Pages.Add(page); // add page to document } // Outputs the Access Cards to the current web page document.DrawToWeb("schoolCard.pdf"); Response.End(); return document; }
//0 - not clear, not update //-1 - clear, update //1 - not clear, update private int CheckStructureTreeRootKids(ImportedPage newPage) { //start of document; if (importedPages.Count == 0) return 1; bool readerExist = false; foreach (ImportedPage page in importedPages) if (page.reader.Equals(newPage.reader)) { readerExist = true; break; } //add new reader; if (!readerExist) return 1; ImportedPage lastPage = importedPages[importedPages.Count - 1]; bool equalReader = lastPage.reader.Equals(newPage.reader); //reader exist, correct order; if (equalReader && newPage.pageNumber > lastPage.pageNumber) return 0; //reader exist, incorrect order; return -1; }
public PdfImportedPage GetImportedPage(PdfReader reader, int pageNumber, bool keepTaggedPdfStructure) { if (mergeFields && !mergeFieldsInternalCall) { throw new ArgumentException(MessageLocalization.GetComposedMessage("1.method.cannot.be.used.in.mergeFields.mode.please.use.addDocument", "getImportedPage")); } ImportedPage newPage = null; updateRootKids = false; if (!keepTaggedPdfStructure) { if (mergeFields) { newPage = new ImportedPage(reader, pageNumber, mergeFields); importedPages.Add(newPage); } return GetImportedPage(reader, pageNumber); } if (structTreeController != null) { if (reader != structTreeController.reader) structTreeController.SetReader(reader); } else { structTreeController = new PdfStructTreeController(reader, this); } newPage = new ImportedPage(reader, pageNumber, mergeFields); switch (CheckStructureTreeRootKids(newPage)) { case -1: //-1 - clear , update ClearIndirects(reader); updateRootKids = true; break; case 0: //0 - not clear, not update updateRootKids = false; break; case 1: //1 - not clear, update updateRootKids = true; break; } importedPages.Add(newPage); disableIndirects.Clear(); parentObjects.Clear(); return GetImportedPageImpl(reader, pageNumber); }
/** * Grabs a page from the input document * @param reader the reader of the document * @param pageNumber which page to get * @return the page */ public override PdfImportedPage GetImportedPage(PdfReader reader, int pageNumber) { if (mergeFields && !mergeFieldsInternalCall) { throw new ArgumentException(MessageLocalization.GetComposedMessage("1.method.cannot.be.used.in.mergeFields.mode.please.use.addDocument", "getImportedPage")); } if (mergeFields) { ImportedPage newPage = new ImportedPage(reader, pageNumber, mergeFields); importedPages.Add(newPage); } if (structTreeController != null) structTreeController.reader = null; disableIndirects.Clear(); parentObjects.Clear(); return GetImportedPageImpl(reader, pageNumber); }
public PdfImportedPage GetImportedPage(PdfReader reader, int pageNumber, bool keepTaggedPdfStructure) { updateRootKids = false; if (!keepTaggedPdfStructure) return GetImportedPage(reader, pageNumber); else { if (structTreeController != null) { if (reader != structTreeController.reader) structTreeController.SetReader(reader); } else { structTreeController = new PdfStructTreeController(reader, this); } ImportedPage newPage = new ImportedPage(reader, pageNumber); switch (CheckStructureTreeRootKids(newPage)) { case -1: //-1 - clear , update ClearIndirects(reader); updateRootKids = true; break; case 0: //0 - not clear, not update updateRootKids = false; break; case 1: //1 - not clear, update updateRootKids = true; break; } importedPages.Add(newPage); disableIndirects.Clear(); parentObjects.Clear(); return GetImportedPageImpl(reader, pageNumber); } }
public ceTe.DynamicPDF.Document CreatePDF() { // Create a document and set it's properties Document document = new Document(); document.Creator = "AccessCard.aspx"; document.Author = "Career Cruising"; document.Title = "Access Card"; string pagePath; string strCPCustomMessage = ""; int pdfType; Array[] pdfCoords = new Array[8]; bool isCurrentAdvisor; bool isAssignmentAdvised; if (PortTypeElements["Mnu_DocsLink_EDP"].ToString() == "1") { pdfType = 2; } else if (PortTypeElements["Mnu_DocsLink_KY"].ToString() == "1") { pdfType = 3; } else if (PortTypeElements["Mnu_DocLink_DE"].ToString() == "1") { pdfType = 5; } else if (PortTypeElements["Mnu_DocLink_SD"].ToString() == "1") { pdfType = 7; } else if (PortTypeElements["Mnu_DocsLink_Port"].ToString() == "1") { pdfType = 1; } else { pdfType = 1; } Response.Write(CCLib.Common.Forms.JavaScriptNotify(pdfType.ToString())); //check if CP school, then look for custom text. if (Convert.ToInt32(CPCoursePlanner) > 6 | Convert.ToInt32(CPCoursePlanner) == 3) { System.Text.StringBuilder sbSQL = new System.Text.StringBuilder(""); sbSQL.AppendLine("SELECT CP_School.AccessCardMessage, CP_SystemName.AccessCardMessage AS DistrictAccessCardMessage, CP_School.AccessCardType, "); sbSQL.AppendLine("CP_School.SchoolID "); sbSQL.AppendLine("FROM Userinfo INNER JOIN "); sbSQL.AppendLine("CP_SystemName ON Userinfo.CPSystemNameID = CP_SystemName.SystemNameID INNER JOIN "); sbSQL.AppendLine("CP_School ON Userinfo.SchoolID = CP_School.SchoolID "); sbSQL.AppendLine("WHERE (CP_School.SchoolID = " + SchoolID + ") "); DataTable dtCP = CareerCruisingWeb.CCLib.Common.DataAccess.GetDataTable(sbSQL.ToString()); if (dtCP.Rows.Count > 0) { strCPCustomMessage = (dtCP.Rows[0]["AccessCardMessage"].ToString() == "") ? dtCP.Rows[0]["DistrictAccessCardMessage"].ToString() : dtCP.Rows[0]["AccessCardMessage"].ToString(); if (dtCP.Rows[0]["AccessCardType"].ToString() == "1") pdfType = 8; } } /* // get pdfType from querystring (if it exists) if (Request.QueryString["pdfType"] != null) { pdfType = int.Parse(Request.QueryString["pdfType"]); // catch any unexpected types //if (pdfType != 1 || pdfType != 2 || pdfType != 3 || pdfType != 4 || pdfType != 5 || pdfType != 6) //{ // pdfType = 1; // for testing // this needs to be an error trapping case (pdfType should always be between 1 and 7) //} } else { pdfType = 1; // for testing // this is the case where pdfType is null } */ // set pdf file source and associated username/passwd positions (coordinates) in the pdf (for one page) if (pdfType == 1) { // from /School/HelpfulDocumentsCA.aspx // or /School/HelpfulDocumentsCA_ON.aspx // or /School/HelpfulDocumentsUS.aspx // use AccessCardsPort_1007.pdf if (GetUserLanguage() == "French") { pagePath = "D:\\newmedia\\docs\\canadian\\AccessCardsPortFR_1007.pdf"; pdfCoords[0] = new int[,] { { 109, 80 }, { 128, 111 }, { 128, 126 }, { 145, 115 }, { 145, 142 } }; pdfCoords[1] = new int[,] { { 109, 260 }, { 128, 291 }, { 128, 306 }, { 145, 295 }, { 145, 322 } }; pdfCoords[2] = new int[,] { { 109, 440 }, { 128, 471 }, { 128, 486 }, { 145, 475 }, { 145, 502 } }; pdfCoords[3] = new int[,] { { 109, 620 }, { 128, 651 }, { 128, 666 }, { 145, 655 }, { 145, 682 } }; pdfCoords[4] = new int[,] { { 361, 80 }, { 381, 111 }, { 381, 126 }, { 397, 115 }, { 397, 142 } }; pdfCoords[5] = new int[,] { { 361, 260 }, { 381, 291 }, { 381, 306 }, { 397, 295 }, { 397, 322 } }; pdfCoords[6] = new int[,] { { 361, 440 }, { 381, 471 }, { 381, 486 }, { 397, 475 }, { 397, 502 } }; pdfCoords[7] = new int[,] { { 361, 620 }, { 381, 651 }, { 381, 666 }, { 397, 655 }, { 397, 682 } }; } else { pagePath = "D:\\newmedia\\docs\\canadian\\AccessCardsPort_1007.pdf"; pdfCoords[0] = new int[,] { { 109, 82 }, { 128, 111 }, { 128, 126 }, { 125, 123 }, { 125, 150 } }; pdfCoords[1] = new int[,] { { 109, 262 }, { 128, 291 }, { 128, 306 }, { 125, 303 }, { 125, 330 } }; pdfCoords[2] = new int[,] { { 109, 442 }, { 128, 471 }, { 128, 486 }, { 125, 483 }, { 125, 510 } }; pdfCoords[3] = new int[,] { { 109, 622 }, { 128, 651 }, { 128, 666 }, { 125, 663 }, { 125, 690 } }; pdfCoords[4] = new int[,] { { 361, 82 }, { 381, 111 }, { 381, 126 }, { 377, 123 }, { 377, 150 } }; pdfCoords[5] = new int[,] { { 361, 262 }, { 381, 291 }, { 381, 306 }, { 377, 303 }, { 377, 330 } }; pdfCoords[6] = new int[,] { { 361, 442 }, { 381, 471 }, { 381, 486 }, { 377, 483 }, { 377, 510 } }; pdfCoords[7] = new int[,] { { 361, 622 }, { 381, 651 }, { 381, 666 }, { 377, 663 }, { 377, 690 } }; } } else if (pdfType == 2) { // from /School/HelpfulDocumentsEDP.aspx // use AccessCardsEDP_1007.pdf pagePath = "D:\\newmedia\\docs\\american\\AccessCardsEDP_1007.pdf"; pdfCoords[0] = new int[,] { { 109, 82 }, { 128, 111 }, { 128, 126 }, { 125, 123 }, { 125, 150 } }; pdfCoords[1] = new int[,] { { 109, 262 }, { 128, 291 }, { 128, 306 }, { 125, 303 }, { 125, 330 } }; pdfCoords[2] = new int[,] { { 109, 442 }, { 128, 471 }, { 128, 486 }, { 125, 483 }, { 125, 510 } }; pdfCoords[3] = new int[,] { { 109, 622 }, { 128, 651 }, { 128, 666 }, { 125, 663 }, { 125, 690 } }; pdfCoords[4] = new int[,] { { 361, 82 }, { 381, 111 }, { 381, 126 }, { 377, 123 }, { 377, 150 } }; pdfCoords[5] = new int[,] { { 361, 262 }, { 381, 291 }, { 381, 306 }, { 377, 303 }, { 377, 330 } }; pdfCoords[6] = new int[,] { { 361, 442 }, { 381, 471 }, { 381, 486 }, { 377, 483 }, { 377, 510 } }; pdfCoords[7] = new int[,] { { 361, 622 }, { 381, 651 }, { 381, 666 }, { 377, 663 }, { 377, 690 } }; } else if (pdfType == 3) { // from /School/HelpfulDocumentsKY.aspx (student) // use AccessCardsStudentKYILP_1007.pdf pagePath = "D:\\newmedia\\docs\\american\\AccessCardsStudentKYILP_1007.pdf"; pdfCoords[0] = new int[,] { { 113, 86 }, { 148, 130 }, { 148, 152 } }; pdfCoords[1] = new int[,] { { 113, 266 }, { 148, 310 }, { 148, 332 } }; pdfCoords[2] = new int[,] { { 113, 446 }, { 148, 490 }, { 148, 512 } }; pdfCoords[3] = new int[,] { { 113, 626 }, { 148, 670 }, { 148, 692 } }; pdfCoords[4] = new int[,] { { 365, 86 }, { 400, 130 }, { 400, 152 } }; pdfCoords[5] = new int[,] { { 365, 266 }, { 400, 310 }, { 400, 332 } }; pdfCoords[6] = new int[,] { { 365, 446 }, { 400, 490 }, { 400, 512 } }; pdfCoords[7] = new int[,] { { 365, 626 }, { 400, 670 }, { 400, 692 } }; } else if (pdfType == 4) { // from /School/HelpfulDocumentsKY.aspx (parent) // use AccessCardsParentKYILP_1007.pdf pagePath = "D:\\newmedia\\docs\\american\\AccessCardsParentKYILP_1007.pdf"; pdfCoords[0] = new int[,] { { 113, 86 }, { 148, 130 }, { 148, 152 } }; pdfCoords[1] = new int[,] { { 113, 266 }, { 148, 310 }, { 148, 332 } }; pdfCoords[2] = new int[,] { { 113, 446 }, { 148, 490 }, { 148, 512 } }; pdfCoords[3] = new int[,] { { 113, 626 }, { 148, 670 }, { 148, 692 } }; pdfCoords[4] = new int[,] { { 365, 86 }, { 400, 130 }, { 400, 152 } }; pdfCoords[5] = new int[,] { { 365, 266 }, { 400, 310 }, { 400, 332 } }; pdfCoords[6] = new int[,] { { 365, 446 }, { 400, 490 }, { 400, 512 } }; pdfCoords[7] = new int[,] { { 365, 626 }, { 400, 670 }, { 400, 692 } }; } else if (pdfType == 5) { // from /School/HelpfulDocumentsDE.aspx (parent) // use AccessCardsStudentDESSP_1007.pdf pagePath = "D:\\newmedia\\docs\\american\\AccessCardsStudentDESSP_1007.pdf"; pdfCoords[0] = new int[,] { { 113, 86 }, { 148, 130 }, { 148, 152 } }; pdfCoords[1] = new int[,] { { 113, 266 }, { 148, 310 }, { 148, 332 } }; pdfCoords[2] = new int[,] { { 113, 446 }, { 148, 490 }, { 148, 512 } }; pdfCoords[3] = new int[,] { { 113, 626 }, { 148, 670 }, { 148, 692 } }; pdfCoords[4] = new int[,] { { 365, 86 }, { 400, 130 }, { 400, 152 } }; pdfCoords[5] = new int[,] { { 365, 266 }, { 400, 310 }, { 400, 332 } }; pdfCoords[6] = new int[,] { { 365, 446 }, { 400, 490 }, { 400, 512 } }; pdfCoords[7] = new int[,] { { 365, 626 }, { 400, 670 }, { 400, 692 } }; } else if (pdfType == 6) { // from /School/HelpfulDocumentsDE.aspx (parent) // use AccessCardsParentDESSP_1007.pdf pagePath = "D:\\newmedia\\docs\\american\\AccessCardsParentDESSP_1007.pdf"; pdfCoords[0] = new int[,] { { 113, 86 }, { 148, 130 }, { 148, 152 } }; pdfCoords[1] = new int[,] { { 113, 266 }, { 148, 310 }, { 148, 332 } }; pdfCoords[2] = new int[,] { { 113, 446 }, { 148, 490 }, { 148, 512 } }; pdfCoords[3] = new int[,] { { 113, 626 }, { 148, 670 }, { 148, 692 } }; pdfCoords[4] = new int[,] { { 365, 86 }, { 400, 130 }, { 400, 152 } }; pdfCoords[5] = new int[,] { { 365, 266 }, { 400, 310 }, { 400, 332 } }; pdfCoords[6] = new int[,] { { 365, 446 }, { 400, 490 }, { 400, 512 } }; pdfCoords[7] = new int[,] { { 365, 626 }, { 400, 670 }, { 400, 692 } }; } else if (pdfType == 7) { // from SD // use AccessCardsSD_1007.pdf pagePath = "D:\\newmedia\\docs\\american\\AccessCardsSD_1007.pdf"; pdfCoords[0] = new int[,] { { 113, 100 }, { 132, 128 }, { 132, 154 } }; pdfCoords[1] = new int[,] { { 113, 280 }, { 132, 308 }, { 132, 334 } }; pdfCoords[2] = new int[,] { { 113, 460 }, { 132, 488 }, { 132, 514 } }; pdfCoords[3] = new int[,] { { 113, 640 }, { 132, 668 }, { 132, 694 } }; pdfCoords[4] = new int[,] { { 365, 100 }, { 384, 128 }, { 384, 154 } }; pdfCoords[5] = new int[,] { { 365, 280 }, { 384, 308 }, { 384, 334 } }; pdfCoords[6] = new int[,] { { 365, 460 }, { 384, 488 }, { 384, 514 } }; pdfCoords[7] = new int[,] { { 365, 640 }, { 384, 668 }, { 384, 694 } }; } else if (pdfType == 8) { // CP access card pagePath = "D:\\newmedia\\docs\\canadian\\AccessCards_CP.pdf"; pdfCoords[0] = new int[,] { { 109, 79 }, { 70, 100 }, { 135, 163 }, { 135, 178 } }; pdfCoords[1] = new int[,] { { 109, 259 }, { 70, 280 }, { 135, 343 }, { 135, 358 } }; pdfCoords[2] = new int[,] { { 109, 439 }, { 70, 460 }, { 135, 523 }, { 135, 538 } }; pdfCoords[3] = new int[,] { { 109, 619 }, { 70, 640 }, { 135, 703 }, { 135, 718 } }; pdfCoords[4] = new int[,] { { 361, 79 }, { 325, 100 }, { 387, 163 }, { 387, 178 } }; pdfCoords[5] = new int[,] { { 361, 259 }, { 325, 280 }, { 387, 343 }, { 387, 358 } }; pdfCoords[6] = new int[,] { { 361, 439 }, { 325, 460 }, { 387, 523 }, { 387, 538 } }; pdfCoords[7] = new int[,] { { 361, 619 }, { 325, 640 }, { 387, 703 }, { 387, 718 } }; } else { // not sure what this case should be yet - using this for testing // should be used for error trapping pagePath = "D:\\newmedia\\docs\\canadian\\AccessCardsPort_1007.pdf"; pdfCoords[0] = new int[,] { { 109, 79 }, { 128, 111 }, { 128, 126 }, { 165, 163 }, { 165, 178 } }; pdfCoords[1] = new int[,] { { 109, 259 }, { 128, 291 }, { 128, 306 }, { 165, 343 }, { 165, 358 } }; pdfCoords[2] = new int[,] { { 109, 439 }, { 128, 471 }, { 128, 486 }, { 165, 523 }, { 165, 538 } }; pdfCoords[3] = new int[,] { { 109, 619 }, { 128, 651 }, { 128, 666 }, { 165, 703 }, { 165, 718 } }; pdfCoords[4] = new int[,] { { 361, 79 }, { 381, 111 }, { 381, 126 }, { 417, 163 }, { 417, 178 } }; pdfCoords[5] = new int[,] { { 361, 259 }, { 381, 291 }, { 381, 306 }, { 417, 343 }, { 417, 358 } }; pdfCoords[6] = new int[,] { { 361, 439 }, { 381, 471 }, { 381, 486 }, { 417, 523 }, { 417, 538 } }; pdfCoords[7] = new int[,] { { 361, 619 }, { 381, 651 }, { 381, 666 }, { 417, 703 }, { 417, 718 } }; } // number of students/parents/etc that need access cards int numRecords = dtStudentList.Rows.Count; // this value is set to 10 (two pages) for testing - get actual value from DB (or result of search on StudentList.aspx) // counters to keep track of position in document int curRecord = 0; // iterate through each students/parents/etc. int curCard = 0; // iterate through cards on page (0 - 7) // calculate number of pages needed for looping. there is room for 8 records per page. we want to round up the number of pages to be printed. double numPages = Math.Ceiling((double)numRecords / 8); // loop to create a pdf long enough (enough pages) to fit all students/parents/etc. for (int curPage = 1; curPage <= numPages; curPage++) { ceTe.DynamicPDF.Page page = new ImportedPage(pagePath, 1); // create a new page int lastRecordOnPage; // index of last student/parent/etc on this page if (curPage * 8 < numRecords) { lastRecordOnPage = curPage * 8; } else { lastRecordOnPage = numRecords; } curCard = 0; // reset card counter // loop through each page of students/parents/etc. for (int i = curRecord; i < lastRecordOnPage; i++) { // when filling in info from DB will use "i" as the index to associate with the student/parent/etc record // print out individual student/parent/etc details (one card - can fit 8 on one page) // depending on pdf format either 3 or 3 fields are needed per card if (dtStudentList.Rows[curRecord]["AssignmentApproved"].ToString() == "True") { isAssignmentAdvised = true; } else { isAssignmentAdvised = false; } if (dtStudentList.Rows[curRecord]["AdminID"].ToString() == AdminInfo["AdminID"].ToString()) { isCurrentAdvisor = true; } else { isCurrentAdvisor = false; } if (pdfType == 1 || pdfType == 2) { page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(dtStudentList.Rows[curRecord]["firstname"].ToString() + " " + dtStudentList.Rows[curRecord]["lastname"].ToString(), (int)pdfCoords[curCard].GetValue(0, 0), (int)pdfCoords[curCard].GetValue(0, 1), 165, 1, Font.Helvetica, 12)); //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(AdminInfo["SchoolUserName"].ToString(), (int)pdfCoords[curCard].GetValue(1, 0), (int)pdfCoords[curCard].GetValue(1, 1), 145, 1, Font.Helvetica, 12)); //page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(AdminInfo["SchoolPassword"].ToString(), (int)pdfCoords[curCard].GetValue(2, 0), (int)pdfCoords[curCard].GetValue(2, 1), 145, 1, Font.Helvetica, 12)); if (((!(Convert.ToBoolean(PortTypeElements["Stu_ExportAccessInfo"])) && isAssignmentAdvised && isCurrentAdvisor) || Convert.ToBoolean(PortTypeElements["Stu_ExportAccessInfo"]))) { page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(dtStudentList.Rows[curRecord]["username"].ToString(), (int)pdfCoords[curCard].GetValue(3, 0), (int)pdfCoords[curCard].GetValue(3, 1), 150, 1, Font.Helvetica, 10)); if (Convert.ToInt16(AdminInfo["HideAllPasswords"]) == 1) page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(dtStudentList.Rows[curRecord]["password"].ToString(), (int)pdfCoords[curCard].GetValue(4, 0), (int)pdfCoords[curCard].GetValue(4, 1), 150, 1, Font.Helvetica, 10)); } } else if (pdfType == 8) //cp access cards { page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(dtStudentList.Rows[curRecord]["firstname"].ToString() + " " + dtStudentList.Rows[curRecord]["lastname"].ToString(), (int)pdfCoords[curCard].GetValue(0, 0), (int)pdfCoords[curCard].GetValue(0, 1), 165, 1, Font.Helvetica, 12)); page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(strCPCustomMessage, (int)pdfCoords[curCard].GetValue(1, 0), (int)pdfCoords[curCard].GetValue(1, 1), 200, 50, Font.Helvetica, 10)); if (((!(Convert.ToBoolean(PortTypeElements["Stu_ExportAccessInfo"])) && isAssignmentAdvised && isCurrentAdvisor) || Convert.ToBoolean(PortTypeElements["Stu_ExportAccessInfo"]))) { page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(dtStudentList.Rows[curRecord]["username"].ToString(), (int)pdfCoords[curCard].GetValue(2, 0), (int)pdfCoords[curCard].GetValue(2, 1), 130, 1, Font.Helvetica, 12)); if (Convert.ToInt16(AdminInfo["HideAllPasswords"]) == 1) page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(dtStudentList.Rows[curRecord]["password"].ToString(), (int)pdfCoords[curCard].GetValue(3, 0), (int)pdfCoords[curCard].GetValue(3, 1), 130, 1, Font.Helvetica, 12)); } } else { page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(dtStudentList.Rows[curRecord]["firstname"].ToString() + " " + dtStudentList.Rows[curRecord]["lastname"].ToString(), (int)pdfCoords[curCard].GetValue(0, 0), (int)pdfCoords[curCard].GetValue(0, 1), 165, 1, Font.Helvetica, 12)); if (((!(Convert.ToBoolean(PortTypeElements["Stu_ExportAccessInfo"])) && isAssignmentAdvised && isCurrentAdvisor) || Convert.ToBoolean(PortTypeElements["Stu_ExportAccessInfo"]))) { page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(dtStudentList.Rows[curRecord]["username"].ToString(), (int)pdfCoords[curCard].GetValue(1, 0), (int)pdfCoords[curCard].GetValue(1, 1), 130, 1, Font.Helvetica, 12)); if (Convert.ToInt16(AdminInfo["HideAllPasswords"]) == 1) page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label(dtStudentList.Rows[curRecord]["password"].ToString(), (int)pdfCoords[curCard].GetValue(2, 0), (int)pdfCoords[curCard].GetValue(2, 1), 130, 1, Font.Helvetica, 12)); } } // increment counters curCard++; curRecord++; } document.Pages.Add(page); // add page to document } // Outputs the Access Cards to the current web page document.DrawToWeb("schoolCard.pdf"); Response.End(); return document; }