[ https://issues.apache.org/jira/browse/PDFBOX-3620?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15837287#comment-15837287 ]
Tilman Hausherr commented on PDFBOX-3620: ----------------------------------------- See their comment {quote} Please: 1) attach the original ODF document used to create this PDF 2) provide information about your operating system 3) try to test with latest build 4.1.3 {quote} > Acroform fields bad encoding > ---------------------------- > > Key: PDFBOX-3620 > URL: https://issues.apache.org/jira/browse/PDFBOX-3620 > Project: PDFBox > Issue Type: Bug > Components: AcroForm, Rendering > Affects Versions: 2.0.3, 2.0.4 > Environment: Windows 7 > Reporter: Neus > Labels: acroform > Attachments: CONTRACTE.pdf, helloworld-Arial-Symbolic.pdf, > helloworld.pdf > > > There's a problem with acroform fields filled using Java. > Setting a string containing characters like óá, etc. in an Acroform field, > when sending the pdf to the printer these characters are replaced by > another ones. But if the pdf is saved to the disk, when I open the pdf the > characters are correct not replaced! > Here it is the pdf I'm using > https://drive.google.com/file/d/0B1_3_sVPnBolbjc3U21LTUFTeDg/view?usp=sharing > Also I have tried to save the document in a temp file, read that > file using pdfbox and send it to the printer and the characters like ó, é, > etc. don't appear well neither. > Here's the code I'm using > {code} > PDDocument pdfDocument; > try { > pdfDocument = PDDocument.load(PrintUtils.class.getClassLoader(). > getResourceAsStream("\\application\\vistes\\clients\\contractes\\informes\\ > CONTRACTE.pdf")); > PDDocumentCatalog docCatalog = pdfDocument.getDocumentCatalog(); > PDAcroForm acroForm = docCatalog.getAcroForm(); > acroForm.setNeedAppearances(false); > AcroForm.omplirCamp(acroForm, "num_contracte", contracte.getId()); > AcroForm.omplirCamp(acroForm, "identificacio_caldera", > (contracte.getMarca() + " " + contracte.getAparell() + " " + > contracte.getNumero_fabricacio()).trim()); > AcroForm.omplirCamp(acroForm, "data_instalacio", > dataFormatter.format(contracte.getDataInstalacio())); > AcroForm.omplirCamp(acroForm, "nom_usuari", > contracte.getNom_usuari()); > AcroForm.omplirCamp(acroForm, "nom_usuari2", > contracte.getNom_usuari()); > AcroForm.omplirCamp(acroForm, "nif", contracte.getNif()); > AcroForm.omplirCamp(acroForm, "carrer", contracte.getDireccio()); > AcroForm.omplirCamp(acroForm, "num_casa", contracte.getNumeroCasa()); > AcroForm.omplirCamp(acroForm, "telefon", contracte.getTelefon()); > AcroForm.omplirCamp(acroForm, "municipi", contracte.getPoblacio()); > AcroForm.omplirCamp(acroForm, "euros", decimalFormatter.format( > contracte.getCost_anual())); > //Create AttributeSet > PrintRequestAttributeSet pset = new > HashPrintRequestAttributeSet(); > //Add Duplex Option to AttributeSet > pset.add(Sides.DUPLEX); > PrinterJob job = PrinterJob.getPrinterJob(); > job.setJobName("Contracte " + (contracte.getId() != null ? > contracte.getId() : "nou")); > PageFormat format = job.getPageFormat(pset); > format.setOrientation(PageFormat.PORTRAIT); > Paper paper = new Paper(); > paper.setSize(20, 14.5); > format.setPaper(paper); > job.defaultPage(format); > job.setPageable(new PDFPageable(pdfDocument)); > if (job.printDialog(pset)) { > job.print(pset); > } > pdfDocument.close(); > } catch (IOException e) { > e.printStackTrace(); > } catch (PrinterException e) { > e.printStackTrace(); > } > public static void omplirCamp(PDAcroForm acroForm, String nomCamp, String > valor) throws IOException{ > PDField field = acroForm.getField(nomCamp); > if( field != null ) { > field.setValue(valor != null ? valor : ""); > } > else { > System.err.println( "No s'ha trobat el camp "+nomCamp+"!"); > } > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org For additional commands, e-mail: dev-h...@pdfbox.apache.org