1

We need to print a pdf document on the page which has predefined fields on it, a formular basically, which fields needs to be filled.

We are using iTextSharp to create pdfs and we use absoulte positioning for elements based on the formular fields positioning. For instance, if the field starts 20mm from left and 20 mm from top I will put data to start at 21mm from the left and 21 mm from top so it fits inside that field. And it works well on my printer.

But my question is, can different printers mess up positioning because of different margins, font sizes, etc... Maybe it will be the same, I am not aware of what differences can different printers bring.

Is it important that user chooses Actual size option when printing pdf?

I need to know what difficulties I can expect, better to know it now then waiting customers calling when this is in production.

Aleksa
  • 2,976
  • 4
  • 30
  • 49

1 Answers1

3

The problem you anticipate, exist. It can be avoided by setting a viewer preference.

See How to prevent the resizing of pages in PDF?

You have to set the print scaling to none:

writer.addViewerPreference(PdfName.PRINTSCALING, PdfName.NONE);

That's the line you'll need if you are using iText 5 (writer is an instance of PdfWriter). If you are using iText 7, you can define the viewer preferences like this:

PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
PdfViewerPreferences preferences = new PdfViewerPreferences();
preferences.setPrintScaling(PdfViewerPreferencesConstants.NONE);
pdf.getCatalog().setViewerPreferences(preferences);

See Handling events; setting viewer preferences and printer properties.

Of course, end users can always overrule the print scaling in their PDF viewer, but that's their responsibility, not yours.

Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165