1 | Index: modules/org.sophie2.extra.func.pdf/src/main/java/org/sophie2/extra/func/pdf/model/PDFResource.java |
---|
2 | =================================================================== |
---|
3 | --- modules/org.sophie2.extra.func.pdf/src/main/java/org/sophie2/extra/func/pdf/model/PDFResource.java (revision 4748) |
---|
4 | +++ modules/org.sophie2.extra.func.pdf/src/main/java/org/sophie2/extra/func/pdf/model/PDFResource.java (working copy) |
---|
5 | @@ -5,6 +5,7 @@ |
---|
6 | import org.sophie2.base.commons.util.BinData; |
---|
7 | import org.sophie2.base.model.resources.Resource; |
---|
8 | import org.sophie2.base.model.resources.ResourceSpace; |
---|
9 | +import org.sophie2.core.logging.SophieLog; |
---|
10 | import org.sophie2.core.prolib.errors.NotAvailableException; |
---|
11 | import org.sophie2.core.prolib.impl.AutoProperty; |
---|
12 | import org.sophie2.core.prolib.interfaces.Prop; |
---|
13 | @@ -57,8 +58,8 @@ |
---|
14 | try { |
---|
15 | return new PDFFile(pdfData().get().toByteBuffer()); |
---|
16 | } catch (IOException e) { |
---|
17 | - throw new RuntimeException(e); |
---|
18 | - |
---|
19 | + SophieLog.error("Exception was thrown while trying to construct a PDFFile. Possible reason: file format is not PDF."); |
---|
20 | + return null; |
---|
21 | } |
---|
22 | } |
---|
23 | } |
---|
24 | Index: modules/org.sophie2.extra.func.pdf/src/main/java/org/sophie2/extra/func/pdf/view/logic/PDFLogic.java |
---|
25 | =================================================================== |
---|
26 | --- modules/org.sophie2.extra.func.pdf/src/main/java/org/sophie2/extra/func/pdf/view/logic/PDFLogic.java (revision 4748) |
---|
27 | +++ modules/org.sophie2.extra.func.pdf/src/main/java/org/sophie2/extra/func/pdf/view/logic/PDFLogic.java (working copy) |
---|
28 | @@ -84,9 +84,14 @@ |
---|
29 | BinData pdfData = new BinData(pdfFile); |
---|
30 | pdfResource.pdfData().set(pdfData); |
---|
31 | pdfResource.pdfPageNum().set(0); |
---|
32 | + if (pdfResource.pdfFile().get() == null) { |
---|
33 | + DialogUtils.showErrorDialog(pageView.swingComponent() |
---|
34 | + .get(), "This may not be a PDF File", "Unsupported file format"); |
---|
35 | + pdfResource = null; |
---|
36 | + } |
---|
37 | } catch (final IOException e) { |
---|
38 | DialogUtils.showExceptionDialog(pageView.swingComponent() |
---|
39 | - .get(), e, "Unsupported file format"); |
---|
40 | + .get(), e, "Error"); |
---|
41 | } |
---|
42 | } |
---|
43 | return pdfResource; |
---|