|
Tutorial 1:Hello World!
Tutorial 2:Change Page Size
Tutorial 3:Change Object's Color
Tutorial 4:Draw Elements On Different Pages
Tutorial 5:Basic Bookmarks
Tutorial 6:Advanced Bookmarks
Tutorial 7:Basic Tables
Tutorial 1:Hello World!
This is a basic sample that shows how to create a simple
"Hello World" PDF.
pdfDocument myDoc = new pdfDocument("TUTORIAL","ME");
pdfPage myPage = myDoc.addPage();
myPage.addText("Hello World!",200,450,predefinedFont.csHelvetica,20);
myDoc.createPDF(@"c:\test.pdf");
myPage = null;
myDoc = null;
|
Tutorial 2:Change Page Size
This is a basic sample that shows how to create a page
with non-standard size.
pdfDocument myDoc = new pdfDocument("TUTORIAL","ME");
pdfPage myPage = myDoc.addPage(100,100);
myPage.addText("Hello World!",200,450,predefinedFont.csHelvetica,10);
myDoc.createPDF(@"c:\test.pdf");
myPage = null;
myDoc = null;
|
Tutorial 3:Change Object's Color
This is a basic sample that shows how to change the color
of a PDF objects.
pdfDocument myDoc = new pdfDocument("TUTORIAL","ME");
pdfPage myPage = myDoc.addPage(100,100);
myPage.addText("Hello World!",70,140,predefinedFont.csHelvetica,10,new
pdfColor(predefinedColor.csCyan));
myPage.addText("Hello World!",70,100,predefinedFont.csHelvetica,10,new
pdfColor(112,27,184));
myPage.addText("Hello World!",70,60,predefinedFont.csHelvetica,10,new
pdfColor("B81C74"));
myDoc.createPDF(@"c:\test.pdf");
myPage = null;
myDoc = null;
OR
pdfDocument myDoc = new pdfDocument("TUTORIAL","ME");
pdfPage myPage = myDoc.addPage(100,100);
myPage.addText("Hello
World!",70,140,predefinedFont.csHelvetica,10,predefinedColor.csCyan);
myDoc.createPDF(@"c:\test.pdf");
myPage = null;
myDoc = null;
|
Tutorial 4:Draw Elements On Different Pages
This is a basic sample that shows how to draw different
objects on different pages.
pdfDocument myDoc = new pdfDocument("TUTORIAL","ME");
pdfPage myFirstPage = myDoc.addPage();
myFirstPage.drawLine(100,100,200,200,predefinedLineStyle.csNormal,new
pdfColor(predefinedColor.csBlue),10);
pdfPage mySecondPage = myDoc.addPage();
mySecondPage.drawRectangle(100,100,300,200,new
pdfColor(predefinedColor.csBlue),new
pdfColor(predefinedColor.csYellow),1,predefinedLineStyle.csNormal);
pdfPage myThirdPage = myDoc.addPage();
myThirdPage.drawCircle(200,200,50,new pdfColor(predefinedColor.csBlue), new
pdfColor(predefinedColor.csYellow),predefinedLineStyle.csNormal,1);
myDoc.createPDF(@"c:\test.pdf");
myFirstPage = null;
mySecondPage = null;
myThirdPage = null;
myDoc = null;
|
Tutorial 5:Basic Bookmarks
This is a basic sample that shows how to use sample
bookmarks. Bookmarks are links on the left side of the page that have a
destination. When you create the bookmark you choose the page (pdfPage object)
and a destination type. You can obtain destination type with a
pdfDetinationFactory that returns different pdfDesyination objects that
implement a generic IPdfDestination Interface.
pdfDocument myDoc = new pdfDocument("Sample Application","Me", true);
pdfPage myPage = myDoc.addPage();
myPage.addText("sharpPDF
1.2.2",100,660,predefinedFont.csHelveticaOblique,30,new
pdfColor(predefinedColor.csCyan));
myDoc.addBookmark(new pdfBookmarkNode("FIRST PAGE", myPage, false,
pdfDestinationFactory.createPdfDestinationFit()));
myDoc.createPDF(txtOutput.Text + @"\" + txtDoc.Text + ".pdf");
|
Tutorial 6:Advanced Bookmarks
This is an advanced sample that shows how to use related
bookmarks. You can create a structure like a tree and you can link all pages in
your document.
pdfDocument myDoc = new pdfDocument("Sample
Application","Me", true);
pdfPage myFirstPage = myDoc.addPage();
myFirstPage.addText("sharpPDF
1.2.2",100,660,predefinedFont.csHelveticaOblique,30,new
pdfColor(predefinedColor.csCyan));
pdfBookmarkNode firstBook = new pdfBookmarkNode("FIRST PAGE", myFirstPage,
false, pdfDestinationFactory.createPdfDestinationFit());
pdfPage mySecondPage = myDoc.addPage();
pdfBookmarkNode secondBook = new pdfBookmarkNode("SECOND PAGE", mySecondPage,
false, pdfDestinationFactory.createPdfDestinationFit());
firstBook.addChildNode(secondBook);
myDoc.addBookmark(firstBook);
myDoc.createPDF(txtOutput.Text + @"\" + txtDoc.Text + ".pdf");
|
Tutorial 7:Basic Tables
This is a basic sample that shows how to create tables and to congifure them.
pdfDocument myDoc = new pdfDocument("Sample Application","Me", false);
pdfPage myFirstPage = myDoc.addPage();
myFirstPage.addText("sharpPDF 1.3 - Table Sample",100,660,predefinedFont.csHelveticaOblique,30,new pdfColor(predefinedColor.csCyan));
pdfTable myTable = new pdfTable();
//Set table's border
myTable.borderSize = 1;
myTable.borderColor = new pdfColor(predefinedColor.csDarkBlue);
myTable.tableHeader.addColumn(new pdfTableColumn("id",predefinedAlignment.csRight,50));
myTable.tableHeader.addColumn(new pdfTableColumn("user",predefinedAlignment.csCenter,150));
myTable.tableHeader.addColumn(new pdfTableColumn("tel",predefinedAlignment.csLeft,80));
myTable.tableHeader.addColumn(new pdfTableColumn("email",predefinedAlignment.csLeft,150));
pdfTableRow myRow = myTable.createRow();
myRow[0].columnValue = "1";
myRow[1].columnValue = "Andrew Red";
myRow[2].columnValue = "898-0210989";
myRow[3].columnValue = "Andrew.red@sharppdf.net";
myTable.addRow(myRow);
myRow = myTable.createRow();
myRow[0].columnValue = "2";
myRow[1].columnValue = "Andrew Green";
myRow[2].columnValue = "298-55109";
myRow[3].columnValue = "Andrew.green@sharppdf.net";
myTable.addRow(myRow);
myRow = myTable.createRow();
myRow[0].columnValue = "3";
myRow[1].columnValue = "Andrew White";
myRow[2].columnValue = "24-5510943";
myRow[3].columnValue = "Andrew.white@sharppdf.net";
myTable.tableHeaderStyle = new pdfTableRowStyle(predefinedFont.csCourierBoldOblique,12,new pdfColor(predefinedColor.csBlack),new pdfColor(predefinedColor.csLightCyan));
myTable.rowStyle = new pdfTableRowStyle(predefinedFont.csCourier,8,new pdfColor(predefinedColor.csBlack),new pdfColor(predefinedColor.csWhite));
myTable.alternateRowStyle = new pdfTableRowStyle(predefinedFont.csCourier,8,new pdfColor(predefinedColor.csBlack),new pdfColor(predefinedColor.csLightYellow));
myTable.cellpadding = 20;
myFirstPage.addTable(myTable, 100, 600);
myTable = null;
myDoc.createPDF(txtOutput.Text + @"\" + txtDoc.Text + ".pdf");
|
|