mirror of
https://github.com/LucasVbr/LecteurPdfDoubleAffichage.git
synced 2026-05-13 17:11:51 +00:00
Cleaning GitHub
Supression différents fichiers
This commit is contained in:
-131
@@ -1,131 +0,0 @@
|
||||
/*
|
||||
* FichierPDF, 13/11/2021
|
||||
* IUT Rodez 2021, INFO2
|
||||
* pas de copyright, aucun droits
|
||||
*/
|
||||
|
||||
package com.lecteurpdfdoubleaffichage.lecteurpdfdoubleaffichage;
|
||||
|
||||
import javafx.scene.image.Image;
|
||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||
import org.apache.pdfbox.rendering.PDFRenderer;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Classe permettant la manipulation de fichier PDF et son affichage.
|
||||
*
|
||||
* @author Lucas
|
||||
*/
|
||||
public class FichierPDF {
|
||||
|
||||
/**
|
||||
* Fichier à charger
|
||||
*/
|
||||
private final File fichier;
|
||||
|
||||
/**
|
||||
* Document pdf chargé à partir du fichier
|
||||
*/
|
||||
private final PDDocument pdDocument;
|
||||
|
||||
/**
|
||||
* Outils de rendu pour l’affichage des pages
|
||||
*/
|
||||
private final PDFRenderer render;
|
||||
|
||||
/**
|
||||
* Liste des pages du PDF sous forme d’images
|
||||
*/
|
||||
private final ArrayList<Image> documentPages = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* @param file Le fichier que l’on veut charger
|
||||
*/
|
||||
public FichierPDF(File file) {
|
||||
if (file == null || !file.isFile()) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
try {
|
||||
this.pdDocument = PDDocument.load(file);
|
||||
} catch (IOException e) {
|
||||
throw new IllegalArgumentException(e.getMessage());
|
||||
}
|
||||
|
||||
this.fichier = file;
|
||||
this.render = new PDFRenderer(pdDocument);
|
||||
|
||||
/* Remplis le tableau documentPages */
|
||||
for (int i = 0; i < pdDocument.getNumberOfPages(); i++) {
|
||||
documentPages.add(pageToImage(i));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return La liste des pages du PDF sous forme d’images
|
||||
*/
|
||||
public ArrayList<Image> getDocumentPages() {
|
||||
return documentPages;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Le document pdf chargé
|
||||
*/
|
||||
public PDDocument getPdDocument() {
|
||||
return pdDocument;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Le Fichier chargé
|
||||
*/
|
||||
public File getFichier() {
|
||||
return fichier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convertis une page PdfBox en image JavaFX
|
||||
* @param pageNumber Le numéro de la page que l’on veut convertir
|
||||
* @return L’image compatible avec JavaFX
|
||||
*/
|
||||
public Image pageToImage(int pageNumber) {
|
||||
if (pageNumber <= pdDocument.getNumberOfPages()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
BufferedImage pageImage = null;
|
||||
try {
|
||||
pageImage = render.renderImage(pageNumber);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return bufferedImageToFxImage(pageImage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Methode qui convertis une image dans le buffer en image compatible
|
||||
* avec JavaFX
|
||||
* @param bufferedImg Image dans le buffer à convertir
|
||||
* @return Image compatible avec JavaFX
|
||||
*/
|
||||
private static Image bufferedImageToFxImage(BufferedImage bufferedImg) {
|
||||
|
||||
ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
|
||||
|
||||
try {
|
||||
ImageIO.write(bufferedImg, "jpg", arrayOutputStream);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
InputStream inStream = new ByteArrayInputStream(
|
||||
arrayOutputStream.toByteArray());
|
||||
|
||||
return new Image(inStream);
|
||||
}
|
||||
}
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
package com.lecteurpdfdoubleaffichage.lecteurpdfdoubleaffichage;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class HelloApplication extends Application {
|
||||
@Override
|
||||
public void start(Stage stage) throws IOException {
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(
|
||||
HelloApplication.class.getResource("hello-view.fxml"));
|
||||
Scene scene = new Scene(fxmlLoader.load(), 320, 240);
|
||||
stage.setTitle("Hello!");
|
||||
stage.setScene(scene);
|
||||
stage.show();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch();
|
||||
}
|
||||
}
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
package com.lecteurpdfdoubleaffichage.lecteurpdfdoubleaffichage;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Label;
|
||||
|
||||
public class HelloController {
|
||||
@FXML
|
||||
private Label welcomeText;
|
||||
|
||||
@FXML
|
||||
protected void onHelloButtonClick() {
|
||||
welcomeText.setText("Welcome to JavaFX Application!");
|
||||
}
|
||||
}
|
||||
-91
@@ -1,91 +0,0 @@
|
||||
/*
|
||||
* TestChargerFichier, 13/11/2021
|
||||
* IUT Rodez 2021, INFO2
|
||||
* pas de copyright, aucun droits
|
||||
*/
|
||||
|
||||
package com.lecteurpdfdoubleaffichage.lecteurpdfdoubleaffichage.test;
|
||||
|
||||
import com.lecteurpdfdoubleaffichage.lecteurpdfdoubleaffichage.FichierPDF;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Classe de test de {@link FichierPDF}
|
||||
*
|
||||
* @author Lucas Vabre
|
||||
*/
|
||||
public class TestFichierPDF {
|
||||
|
||||
public FichierPDF FIXTURE = new FichierPDF(
|
||||
new File("fichierTest/test_pdf.pdf"));
|
||||
|
||||
/**
|
||||
* Tests unitaires de {@link FichierPDF#FichierPDF(File)}
|
||||
*/
|
||||
public static void testFichierPdfFile() {
|
||||
System.out.print("Test unitaire de FichierPDF#FichierPDF(File)");
|
||||
|
||||
File[] INVALIDES = {
|
||||
/* Chemin inconnu */
|
||||
new File(" "),
|
||||
new File("\n"),
|
||||
new File("aaa.pdf"),
|
||||
new File("iii.png")
|
||||
};
|
||||
|
||||
for (int i = 0; i < INVALIDES.length; i++) {
|
||||
try {
|
||||
new FichierPDF(INVALIDES[i]);
|
||||
throw new AssertionError("Erreur au test n°" + i);
|
||||
} catch (IllegalArgumentException ignored) {}
|
||||
}
|
||||
|
||||
System.out.println(" => OK");
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests unitaires de {@link FichierPDF#getDocumentPages()}
|
||||
*/
|
||||
public static void testGetDocumentPages() {
|
||||
System.out.println("Test unitaire de FichierPDF#getDocumentPages():");
|
||||
// TODO
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests unitaires de {@link FichierPDF#getPdDocument()}
|
||||
*/
|
||||
public static void testGetPdDocument() {
|
||||
System.out.println("Test unitaire de FichierPDF#getPdDocument():");
|
||||
// TODO
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests unitaires de {@link FichierPDF#getFichier()}
|
||||
*/
|
||||
public static void testGetFichier() {
|
||||
System.out.println("Test unitaire de FichierPDF#getFichier():");
|
||||
// TODO
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests unitaires de {@link FichierPDF#pageToImage(int)}
|
||||
*/
|
||||
public static void testPageToImage() {
|
||||
System.out.println("Test unitaire de FichierPDF#pageToImage(int):");
|
||||
// TODO
|
||||
}
|
||||
|
||||
/**
|
||||
* Lance les tests de la classe {@link FichierPDF}
|
||||
*
|
||||
* @param args non utilisé
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
testFichierPdfFile();
|
||||
// testGetDocumentPages();
|
||||
// testGetPdDocument();
|
||||
// testGetFichier();
|
||||
// testPageToImage();
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
%PDF-1.4
|
||||
%Çì�¢
|
||||
5 0 obj
|
||||
<</Length 6 0 R/Filter /FlateDecode>>
|
||||
stream
|
||||
xœMޱNÄ0†÷<…Çd¨ÏNœ¸^OÀÀ§l'¦Šc*¨âx’RªÚƒÿóo{BŽ@=ÿ›ivnq#¦«xì§ÎÕ�.
|
||||
ÍQoŽÐÌ„WÆ „#h!¨³»ú‡À˜5Sò_a Œ&¦â§�°•Ÿƒ4‡!¢ÊÅ¿ÿÑϽwÊ%çÑC—Y4[ò/a�ö³n‡D¢
|
||||
‹æhû¨Z<nØö‡�1F3Ýaj–·úì«{mùµi:uendstream
|
||||
endobj
|
||||
6 0 obj
|
||||
180
|
||||
endobj
|
||||
4 0 obj
|
||||
<</Type/Page/MediaBox [0 0 595 842]
|
||||
/Rotate 0/Parent 3 0 R
|
||||
/Resources<</ProcSet[/PDF /Text]
|
||||
/Font 8 0 R
|
||||
>>
|
||||
/Contents 5 0 R
|
||||
>>
|
||||
endobj
|
||||
3 0 obj
|
||||
<< /Type /Pages /Kids [
|
||||
4 0 R
|
||||
] /Count 1
|
||||
>>
|
||||
endobj
|
||||
1 0 obj
|
||||
<</Type /Catalog /Pages 3 0 R
|
||||
/Metadata 9 0 R
|
||||
>>
|
||||
endobj
|
||||
8 0 obj
|
||||
<</R7
|
||||
7 0 R>>
|
||||
endobj
|
||||
7 0 obj
|
||||
<</BaseFont/Times-Roman/Type/Font
|
||||
/Subtype/Type1>>
|
||||
endobj
|
||||
9 0 obj
|
||||
<</Type/Metadata
|
||||
/Subtype/XML/Length 1549>>stream
|
||||
<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
|
||||
<?adobe-xap-filters esc="CRLF"?>
|
||||
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='XMP toolkit 2.9.1-13, framework 1.6'>
|
||||
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' xmlns:iX='http://ns.adobe.com/iX/1.0/'>
|
||||
<rdf:Description rdf:about='uuid:81d69fb9-8bc7-11e4-0000-66b1dd18110c' xmlns:pdf='http://ns.adobe.com/pdf/1.3/'><pdf:Producer>GPL Ghostscript 9.06</pdf:Producer>
|
||||
<pdf:Keywords>()</pdf:Keywords>
|
||||
</rdf:Description>
|
||||
<rdf:Description rdf:about='uuid:81d69fb9-8bc7-11e4-0000-66b1dd18110c' xmlns:xmp='http://ns.adobe.com/xap/1.0/'><xmp:ModifyDate>2014-12-22T00:49:20+01:00</xmp:ModifyDate>
|
||||
<xmp:CreateDate>2014-12-22T00:49:20+01:00</xmp:CreateDate>
|
||||
<xmp:CreatorTool>PDFCreator Version 1.6.0</xmp:CreatorTool></rdf:Description>
|
||||
<rdf:Description rdf:about='uuid:81d69fb9-8bc7-11e4-0000-66b1dd18110c' xmlns:xapMM='http://ns.adobe.com/xap/1.0/mm/' xapMM:DocumentID='uuid:81d69fb9-8bc7-11e4-0000-66b1dd18110c'/>
|
||||
<rdf:Description rdf:about='uuid:81d69fb9-8bc7-11e4-0000-66b1dd18110c' xmlns:dc='http://purl.org/dc/elements/1.1/' dc:format='application/pdf'><dc:title><rdf:Alt><rdf:li xml:lang='x-default'>test_word</rdf:li></rdf:Alt></dc:title><dc:creator><rdf:Seq><rdf:li>Seb</rdf:li></rdf:Seq></dc:creator><dc:description><rdf:Seq><rdf:li>()</rdf:li></rdf:Seq></dc:description></rdf:Description>
|
||||
</rdf:RDF>
|
||||
</x:xmpmeta>
|
||||
|
||||
|
||||
<?xpacket end='w'?>
|
||||
endstream
|
||||
endobj
|
||||
2 0 obj
|
||||
<</Producer(GPL Ghostscript 9.06)
|
||||
/CreationDate(D:20141222004920+01'00')
|
||||
/ModDate(D:20141222004920+01'00')
|
||||
/Title(\376\377\000t\000e\000s\000t\000_\000w\000o\000r\000d)
|
||||
/Creator(\376\377\000P\000D\000F\000C\000r\000e\000a\000t\000o\000r\000 \000V\000e\000r\000s\000i\000o\000n\000 \0001\000.\0006\000.\0000)
|
||||
/Author(\376\377\000S\000e\000b)
|
||||
/Keywords()
|
||||
/Subject()>>endobj
|
||||
xref
|
||||
0 10
|
||||
0000000000 65535 f
|
||||
0000000484 00000 n
|
||||
0000002268 00000 n
|
||||
0000000425 00000 n
|
||||
0000000284 00000 n
|
||||
0000000015 00000 n
|
||||
0000000265 00000 n
|
||||
0000000577 00000 n
|
||||
0000000548 00000 n
|
||||
0000000643 00000 n
|
||||
trailer
|
||||
<< /Size 10 /Root 1 0 R /Info 2 0 R
|
||||
/ID [<0CB231047435B33BCE0B1C6881DCF011><0CB231047435B33BCE0B1C6881DCF011>]
|
||||
>>
|
||||
startxref
|
||||
2648
|
||||
%%EOF
|
||||
@@ -1,10 +0,0 @@
|
||||
module com.lecteurpdfdoubleaffichage.lecteurpdfdoubleaffichage {
|
||||
requires javafx.controls;
|
||||
requires javafx.fxml;
|
||||
requires org.apache.pdfbox;
|
||||
requires java.desktop;
|
||||
|
||||
|
||||
opens com.lecteurpdfdoubleaffichage.lecteurpdfdoubleaffichage to javafx.fxml;
|
||||
exports com.lecteurpdfdoubleaffichage.lecteurpdfdoubleaffichage;
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
|
||||
<?import javafx.scene.control.Button?>
|
||||
<VBox alignment="CENTER" spacing="20.0" xmlns:fx="http://javafx.com/fxml"
|
||||
fx:controller="com.lecteurpdfdoubleaffichage.lecteurpdfdoubleaffichage.HelloController">
|
||||
<padding>
|
||||
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0"/>
|
||||
</padding>
|
||||
|
||||
<Label fx:id="welcomeText"/>
|
||||
<Button text="Hello!" onAction="#onHelloButtonClick"/>
|
||||
</VBox>
|
||||
Reference in New Issue
Block a user