-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCrPdf.java
More file actions
executable file
·54 lines (42 loc) · 1.8 KB
/
Copy pathCrPdf.java
File metadata and controls
executable file
·54 lines (42 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import java.io.IOException;
import org.apache.pdfbox.examples.pdmodel.ImageToPDF;
import org.apache.pdfbox.exceptions.COSVisitorException;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.edit.PDPageContentStream;
import org.apache.pdfbox.pdmodel.font.PDFont;
import org.apache.pdfbox.pdmodel.font.PDTrueTypeFont;
import org.apache.pdfbox.pdmodel.font.PDType1Font;
public class CrPdf {
/**
* @param args
* @throws COSVisitorException
* @throws IOException
*/
public static void main(String[] args) throws COSVisitorException, IOException {
try {
PDDocument document = new PDDocument();
PDPage blankPage = new PDPage();
document.addPage( blankPage );
PDFont font = PDType1Font.HELVETICA_BOLD;
PDPageContentStream contentStream = new PDPageContentStream(document, blankPage);
contentStream.beginText();
contentStream.setFont( font, 12 );
contentStream.moveTextPositionByAmount( 100, 700 );
contentStream.drawString( "1. Erinnerung an Schulgeometrie (2 Punkte)\n" );
contentStream.drawString(" Schreiben Sie einen Beitrag zu folgendem Thema ins Forum: \n");
contentStream.drawString("(Hinweis: Jedes Abgabepaar schreibt entweder je einen Beitrag oder einen Beitrag ");
contentStream.endText();
contentStream.close();
document.save("BlankPage.pdf");
document.close();
} catch (IOException e) {
e.printStackTrace();
}
ImageToPDF im = new ImageToPDF();
String[] st = {"WiSe2012_Mathe_Muste_Uebung_.png"} ;
ImageToPDF.main(st);
//TODO: Use that for converting DOCX files that contain images only. i.e. extract the images and start the pdf conversion.
im.createPDFFromImage("bla.pdf","WiSe2012_Mathe_Muste_Uebung_.png");
}
}