Skip to content

Commit

Permalink
Merge pull request #138 from JiaHaoLim/master
Browse files Browse the repository at this point in the history
[v1.4] Bugfix
  • Loading branch information
kthSim authored Apr 5, 2019
2 parents 9227bbc + b9233ea commit 5ecab0f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/java/seedu/address/storage/InOutAddressBookStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static java.util.Objects.requireNonNull;

import java.awt.image.BufferedImage;
import java.io.IOException;
import java.nio.file.Path;
import java.time.LocalDateTime;
Expand All @@ -10,6 +11,8 @@
import java.util.Optional;
import java.util.logging.Logger;

import javax.imageio.ImageIO;

import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.PDPageContentStream;
Expand All @@ -19,6 +22,7 @@
import org.apache.pdfbox.pdmodel.graphics.image.LosslessFactory;
import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject;

import seedu.address.MainApp;
import seedu.address.commons.core.LogsCenter;
import seedu.address.commons.exceptions.DataConversionException;
import seedu.address.commons.exceptions.IllegalValueException;
Expand All @@ -45,7 +49,7 @@ public class InOutAddressBookStorage implements AddressBookStorage {
private static final PDFont FONT = PDType1Font.HELVETICA;
private static final int FONT_SIZE = 12;
private static final int LINE_SPACING = 3;
private static final String TEETH_IMAGE_PATH = "src/main/resources/images/tooth.png";
private static final String TEETH_IMAGE_PATH = "images/tooth.png";

private static final Logger logger = LogsCenter.getLogger(InOutAddressBookStorage.class);

Expand Down Expand Up @@ -157,7 +161,10 @@ private void writeModelObject(PDDocument doc, PdfAdaptedInterface pdfAdaptedObj,
PDPageContentStream[] contents = new PDPageContentStream[1];
contents[0] = new PDPageContentStream(doc, page);

PDImageXObject titleImage = PDImageXObject.createFromFile(TEETH_IMAGE_PATH, doc);
BufferedImage titleImageloader = ImageIO.read(MainApp.class.getClassLoader()
.getResourceAsStream(TEETH_IMAGE_PATH));

PDImageXObject titleImage = LosslessFactory.createFromImage(doc, titleImageloader);
contents[0].setFont(TITLE_FONT, TITLE_FONT_SIZE);
ty = writeTitle(contents[0], page, titleImage, ty);

Expand Down

0 comments on commit 5ecab0f

Please sign in to comment.