1
2
3
4 package de.tivsource.page.helper.pdf;
5
6 import java.io.File;
7 import java.io.IOException;
8 import java.util.Date;
9 import java.util.HashMap;
10 import java.util.Map;
11
12 import org.apache.pdfbox.exceptions.COSVisitorException;
13
14 import de.tivsource.page.entity.embeddable.Address;
15 import de.tivsource.page.entity.embeddable.ContactDetails;
16 import de.tivsource.page.entity.enumeration.Language;
17 import de.tivsource.page.entity.event.Event;
18 import de.tivsource.page.entity.location.Location;
19 import de.tivsource.page.entity.namingitem.Description;
20 import de.tivsource.page.entity.namingitem.NamingItem;
21 import de.tivsource.page.entity.picture.Picture;
22 import de.tivsource.page.entity.picture.PictureUrl;
23 import de.tivsource.page.entity.reservation.Reservation;
24 import de.tivsource.page.enumeration.UrlType;
25
26
27
28
29
30 public class TestPDF {
31
32
33
34
35
36
37 public static void main(String[] args) throws COSVisitorException, IOException {
38 Location location = new Location();
39
40 Address address = new Address();
41 address.setCity("Castrop-Rauxel");
42 address.setCountry("Deutschland");
43 address.setStreet("Dorfstrasse 3");
44 address.setZip("47530");
45
46 ContactDetails contactDetails = new ContactDetails();
47 contactDetails.setEmail("info@tiv-source.de");
48 contactDetails.setFax("02305-0555555405");
49 contactDetails.setHomepage("http://www.tiv-source.de/");
50 contactDetails.setTelephone("02305-0555555407");
51
52 Map<Language, Description> descriptionMapLocation = new HashMap<Language, Description>();
53 descriptionMapLocation.put(Language.DE, createDescription(
54 "", "Filiale Dorfstrasse", "",
55 "", Language.DE, location));
56
57
58 Picture pictureLocation = new Picture();
59 Map<UrlType, PictureUrl> locationPictureUrls = new HashMap<UrlType, PictureUrl>();
60 PictureUrl locationPictureUrl = new PictureUrl();
61 locationPictureUrl.setPicture(pictureLocation);
62 locationPictureUrl.setUrl("4f97081d064a29f96db0f1c9c9013f19fdf2503a.png");
63 locationPictureUrl.setUrlType(UrlType.NORMAL);
64 locationPictureUrls.put(locationPictureUrl.getUrlType(), locationPictureUrl);
65 pictureLocation.setPictureUrls(locationPictureUrls);
66
67 location.setAddress(address);
68 location.setContactDetails(contactDetails);
69 location.setDescriptionMap(descriptionMapLocation);
70 location.setPicture(pictureLocation);
71
72
73 Event event = new Event();
74
75 Picture pictureEvent = new Picture();
76 Map<UrlType, PictureUrl> eventPictureUrls = new HashMap<UrlType, PictureUrl>();
77 PictureUrl eventPictureUrl = new PictureUrl();
78 eventPictureUrl.setPicture(pictureEvent);
79 eventPictureUrl.setUrl("03d2153912f5d6a7733d32aba97268e63b751ef9.png");
80 eventPictureUrl.setUrlType(UrlType.NORMAL);
81 eventPictureUrls.put(eventPictureUrl.getUrlType(), eventPictureUrl);
82 pictureEvent.setPictureUrls(eventPictureUrls);
83
84 Map<Language, Description> descriptionMapEvent = new HashMap<Language, Description>();
85 descriptionMapEvent.put(Language.DE, createDescription(
86 "", "Eventname hier", "",
87 "", Language.DE, location));
88
89 event.setBeginning(new Date());
90 event.setDescriptionMap(descriptionMapEvent);
91 event.setLocation(location);
92 event.setPicture(pictureEvent);
93
94 Reservation reservation = new Reservation();
95
96
97
98
99
100 reservation.setEmail("test.die.email@test.die.domaine.test.die.top.level.domain");
101 reservation.setEvent(event);
102 reservation.setFirstname("Hans Peter");
103 reservation.setGender(true);
104 reservation.setLastname("Wurst-Marmelade");
105 reservation.setQuantity(15);
106 reservation.setTelephone("+49-2302-1211122121");
107 reservation.setTime(new Date());
108 reservation.setUuid("53a78421-e1e5-49e3-a577-81151912433f");
109
110 File file = new File("BlankPage.pdf");
111 new CreateReservationPDF(
112 file,
113 reservation,
114 new File("logo1.png"),
115 new File("testdass.png"),
116 new File("bankgothicltbt.ttf")
117 );
118
119 }
120
121 private static Description createDescription(
122 String uuid, String name, String description,
123 String keywords, Language language, NamingItem namingItem) {
124 Description returnDescription = new Description();
125 returnDescription.setUuid(uuid);
126 returnDescription.setName(name);
127 returnDescription.setDescription(description);
128 returnDescription.setKeywords(keywords);
129 returnDescription.setLanguage(language);
130 returnDescription.setNamingItem(namingItem);
131 return returnDescription;
132 }
133
134 }