Question
Issue with the number fomatting in german
I have created a adobe java service to create a pdf from the excel file. The excel is having the correct number formatting for the german but when it is send for the pdf generation then the pdf is showing the number format as indian number system and not the german number system.
public byte[] convertExcelToPdf(byte[] excelFile) throws Exception {
try {
// Create PDFServices instance using the injected credentials with EU region
PDFServices pdfServices = new PDFServices(adobeCredentials);
// Create a temporary file from the uploaded file
File tempFile = createTempFile(excelFile);
try {
// Create PDF using Adobe PDF Services with European locale
return createPdfFromFile(tempFile, pdfServices, adobeConfig.getRegion());
} finally {
// Keep the temporary file for debugging - comment out the deletion
if (tempFile.exists()) {
tempFile.delete();
}
}
} catch (Exception e) {
throw new Exception("Failed to convert Excel file to PDF: " + e.getMessage(), e);
}
}
private File createTempFile(byte[] fileBytes) throws IOException {
// Create a temporary file with Excel extension
File tempFile = File.createTempFile("excel_", ".xlsx");
// Verify the file was created properly
if (!tempFile.exists() || tempFile.length() == 0) {
throw new IOException("Failed to create temporary Excel file");
}
return tempFile;
}
private byte[] createPdfFromFile(File inputFile, PDFServices pdfServices, String region) throws Exception {
try {
// Create input stream and upload asset
FileInputStream inputStream = new FileInputStream(inputFile);
Asset asset = pdfServices.upload(inputStream, PDFServicesMediaType.XLSX.getMediaType());
// Create a new job instance (for simple Excel to PDF conversion)
CreatePDFJob createPDFJob = new CreatePDFJob(asset);
// Submit the job and get the job result
String location = pdfServices.submit(createPDFJob);
PDFServicesResponse<CreatePDFResult> pdfServicesResponse = pdfServices.getJobResult(location, CreatePDFResult.class);
// Get content from the resulting asset
Asset resultAsset = pdfServicesResponse.getResult().getAsset();
StreamAsset streamAsset = pdfServices.getContent(resultAsset);
// Convert to byte array
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
streamAsset.getInputStream().transferTo(outputStream);
return outputStream.toByteArray();
} catch (ServiceApiException | ServiceUsageException | SDKException e) {
throw new Exception("Adobe API conversion failed: " + e.getMessage(), e);
} catch (IOException e) {
throw new Exception("File processing error: " + e.getMessage(), e);
}
}
This is my java code
