@@ -0,0 +1,2088 @@
+package dk.statsbiblioteket.newspaper.editions;%0A%0Aimport org.apache.pdfbox.exceptions.COSVisitorException;%0Aimport org.apache.pdfbox.pdmodel.PDDocument;%0Aimport org.apache.pdfbox.pdmodel.PDPage;%0Aimport org.apache.pdfbox.pdmodel.common.PDRectangle;%0Aimport org.apache.pdfbox.pdmodel.edit.PDPageContentStream;%0Aimport org.apache.pdfbox.pdmodel.font.PDFont;%0Aimport org.apache.pdfbox.pdmodel.font.PDType1Font;%0Aimport org.apache.pdfbox.pdmodel.graphics.xobject.PDJpeg;%0Aimport org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectImage;%0Aimport org.junit.Assert;%0Aimport org.testng.annotations.Test;%0A%0Aimport javax.imageio.ImageIO;%0Aimport java.awt.image.BufferedImage;%0Aimport java.io.File;%0Aimport java.io.IOException;%0Aimport java.io.OutputStream;%0Aimport java.net.URL;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertNotNull;%0A%0Apublic class JpegToPdfPdfBoxProofOfConcept %7B%0A%0A    @Test%0A    public void test() throws Exception %7B%0A%0A        final BufferedImage bufferedImage = canReadSampleJP2000Image();%0A%0A        File outputfile = new File(%22saved.png%22);%0A        ImageIO.write(bufferedImage, %22png%22, outputfile);%0A%0A        // Create a document and add a page to it%0A        PDDocument document = new PDDocument();%0A        PDPage page = new PDPage(new PDRectangle(bufferedImage.getWidth(),bufferedImage.getHeight()));%0A        document.addPage(page);%0A%0A%0A        PDJpeg pdfjpg = new PDJpeg(document, bufferedImage,1.0f);%0A%0A        PDPageContentStream contentStream = new PDPageContentStream(document, page,false,false);%0A        contentStream.drawImage(pdfjpg,0,0);%0A        contentStream.close();%0A%0A        // Save the results and ensure that the document is properly closed:%0A        document.save(%22Hello World2.pdf%22);%0A        document.close();%0A    %7D%0A%0A    public BufferedImage canReadSampleJP2000Image() throws Exception %7B%0A%0A        String resourceName = %22/berlingsketidende-1749-01-03-01-0005A-presentation.jp2%22;%0A%0A        URL r = getClass().getResource(resourceName);%0A        Assert.assertNotNull(%22cannot locate resource %22 + resourceName, r);%0A%0A        return ImageIO.read(r);%0A    %7D%0A%7D%0A%0A%0A

Create image pdf