1 / 6

Daten Anzeigen und Ausdrucken

Daten Anzeigen und Ausdrucken. Zu Zeigende Daten (z.B. Studentenplan) Daten in XML müssen geparst und in PDF- Format umgewandelt werden. Dazu iTEXT Bibliothek. http://itextsharp.sourceforge.net. 1-Die Erstellung eines PDF Dokuments mit der iText Bibliothek. gliedert sich in fünf Schritte:

Download Presentation

Daten Anzeigen und Ausdrucken

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Daten Anzeigen und Ausdrucken • Zu Zeigende Daten (z.B. Studentenplan) • Daten in XML müssen geparst und in PDF- Format umgewandelt werden. • Dazu iTEXT Bibliothek. • http://itextsharp.sourceforge.net

  2. 1-Die Erstellung eines PDF Dokuments mit der iText Bibliothek gliedert sich in fünf Schritte: • 1. Erzeugung einer Dokument Instanz. • 2. Erzeugung eines Writers, welcher als Obeserver des Dokument Objekts agiert und zugefügtenInhalt in die PDF Datei schreibent.

  3. 2-Die Erstellung eines PDF Dokuments mit der iText Bibliothek • 3. Das Dokument muss, um Inhalt hinzufügen zu können explizit geöffnet werden. • 4. Hinzufügen des Inhaltes. • 5. Schließen des Dokumentes (damit die OutputStreams geleert werden).

  4. 1-Schritt eindeuten public class HelloWorld { public static void main ( String [ ]args) { //--1. Schritt : Dokument Instanz Document doc = new Document(); try { //--2. Schritt: Writer erzeugen PdfWriter.getInstance ( doc, new FileOutputStream("HelloWorld.pdf") ) ; //--3. Schritt: Dokument Öffnen doc.open();

  5. 2-Schritt eindeuten //--4. Schritt: Inhalt hinzufügen Font font = FontFactory . getFont ( FontFactory.HELVETICA_BOLD, 34 ) ; Chunk c = new Chunk("HelloWorld",font) ; doc.add(c) ; //--5. Schritt : Dokument schlissen doc.close(); System.out.println("HelloWorld pdf created!"); } catch (DocumentException e ) { e.printStackTrace() ; } catch(IOException e) { e.printStackTrace(); } }

  6. XML-Doc <?xml version="1.0" ?>   <!DOCTYPE name (View Source for full doctype...)> <root> <Semester> <Vorlesung>   <Name>Rechner Systeme</Name>   <ProfName>Prandis</ProfName>   <ECTS>6</ECTS>   <SWS>4</SWS>   </Vorlesung> <Vorlesung>   <Name>Information Managment</Name>   <ProfName>Keim</ProfName>   <ECTS>9</ECTS>   <SWS>6</SWS>   </Vorlesung>   </Semester>   </root>

More Related