Agregue escenario y qr dinamico

This commit is contained in:
luis.aguilar 2025-03-18 19:56:14 -06:00
parent cf2ea35e24
commit 9571e0988e
5 changed files with 14 additions and 5 deletions
.idea
src/main
java/org/example/saladeconciertos
resources

View File

@ -5,6 +5,7 @@
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>

View File

@ -2,5 +2,6 @@
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@ -43,21 +43,25 @@ public class PDFGenerator {
// Configurar la fuente y el tamaño para el contenido del reporte
contentStream.setFont(font, 12);
contentStream.beginText();
contentStream.newLineAtOffset(50, 680);
float textY = 680;
contentStream.newLineAtOffset(50, textY);
// Dividir el texto en líneas y escribir cada línea por separado
String[] lines = ticketDetails.split("\n");
for (String line : lines) {
contentStream.showText(line);
textY -= 15;
contentStream.newLineAtOffset(0, -15); // Mover hacia abajo para la siguiente línea
}
contentStream.endText();
float imageHeight = 150; // Altura de la imagen
float imageY = textY - 50 - imageHeight; // 50 unidades de margen + altura de la imagen
// Agregar la imagen del código QR (si existe)
if (qrImagePath != null && !qrImagePath.isEmpty()) {
PDImageXObject qrImage = PDImageXObject.createFromFile(qrImagePath, document);
contentStream.drawImage(qrImage, 50, 50, 150, 150); // Ajusta la posición y el tamaño de la imagen
contentStream.drawImage(qrImage, 50, imageY, 150, 150); // Ajusta la posición y el tamaño de la imagen
}
}

View File

@ -99,9 +99,9 @@ public class VentaBoletos extends Application {
titleLabel.getStyleClass().add("title");
// Agregar el logo de la aplicación
ImageView logo = new ImageView(new Image(getClass().getResourceAsStream("/logo.png")));
logo.setFitWidth(100);
logo.setFitHeight(100);
ImageView logo = new ImageView(new Image(getClass().getResourceAsStream("/escenario.png")));
logo.setFitWidth(500);
logo.setFitHeight(130);
// Crear y configurar el label de bienvenida
Label welcomeLabel = new Label("Seleccione sus asientos");
@ -282,5 +282,8 @@ public class VentaBoletos extends Application {
public static void main(String[] args) {
launch(args);
System.setProperty("org.apache.pdfbox.rendering.UsePureJavaCMYK", "true");
System.setProperty("org.apache.pdfbox.rendering.UsePureJavaRendering", "true");
System.setProperty("org.apache.pdfbox.base.disableFontCache", "true");
}
}

Binary file not shown.

After

(image error) Size: 15 KiB