Hello fellow developers,
I have a problem when printing PDFs that I've automatically generated with a Java application using iText 7. When I print such a PDF, the printout contains all pictures and graphics, but no text whatsoever.
Can someone tell me what the problem could possibly be? I've tried the "print as image" option in Adobe and came up with the same result.
Thank you very much.
EDIT/Added code and link:
Link to PDF file created this way
document = new Document(new PdfDocument(new PdfWriter(new FileOutputStream(dest))));
this.form = PdfAcroForm.getAcroForm(document.getPdfDocument(), true);
PdfTextFormField fw1Field = PdfTextFormField.createText(document.getPdfDocument(),
new Rectangle(Variables.llx, Variables.lly, Variables.urx, Variables.ury), "Feld1");
fw1Field.setValue(fw1);
fw1Field.setReadOnly(Variables.readonly);
fw1Field.setBorderColor(Color.WHITE);
form.addField(fw1Field);
PdfTextFormField fsText = PdfTextFormField.createText(document.getPdfDocument(),
new Rectangle(Variables.llx + 150, Variables.lly, Variables.urx + 50, Variables.ury), "FSText");
fsText.setValue("Freigabeschein:");
fsText.setBackgroundColor(Variables.backgroundColourText);
fsText.setBorderColor(Color.WHITE);
fsText.setReadOnly(Variables.readonlyText);
fsText.setBorderColor(Color.WHITE);
form.addField(fsText);
PdfTextFormField idField = PdfTextFormField.createText(document.getPdfDocument(),
new Rectangle(Variables.llx + 250, Variables.lly, Variables.urx, Variables.ury), "Freigabeschein Nummer");
idField.setValue(id);
idField.setReadOnly(Variables.readonly);
idField.setBorderColor(Color.WHITE);
form.addField(idField);
PdfTextFormField datumText = PdfTextFormField.createText(document.getPdfDocument(),
new Rectangle(Variables.llx + 350, Variables.lly, Variables.urx, Variables.ury), "DatumText");
datumText.setValue("Datum:");
datumText.setBackgroundColor(Variables.backgroundColourText);
datumText.setBorderColor(Color.WHITE);
datumText.setReadOnly(Variables.readonlyText);
form.addField(datumText);
//more Text, created exactly as above
PdfButtonFormField buttonSpeichern = PdfFormField.createPushButton(document.getPdfDocument(), new Rectangle(450, 20, 100, 30), "speichern", "SPEICHERN");
buttonSpeichern.setBackgroundColor(Color.LIGHT_GRAY);
buttonSpeichern.setValue("Speichern");
buttonSpeichern.setVisibility(PdfFormField.VISIBLE_BUT_DOES_NOT_PRINT);
buttonSpeichern.setAdditionalAction(PdfName.D, PdfAction.createJavaScript("saveFSFunction(1);"));
form.addField(buttonSpeichern);
PdfButtonFormField buttonDrucken = PdfFormField.createPushButton(document.getPdfDocument(), new Rectangle(300, 20, 100, 30), "drucken", "DRUCKEN");
buttonDrucken.setBackgroundColor(Color.LIGHT_GRAY);
buttonDrucken.setValue("Drucken");
buttonDrucken.setVisibility(PdfFormField.VISIBLE_BUT_DOES_NOT_PRINT);
buttonDrucken.setAdditionalAction(PdfName.D, PdfAction.createJavaScript("printFunction(1, 0, 1, \"FS\");"));
form.addField(buttonDrucken);
document.close();
.setVisibility(0);
There was no enum for visible, so I assumed that's the standard behaviour - obviously not. – Harry