I have added a question in my answer to iTextSharp - when extracting a page it fails to carry over Adobe rectangle highlighting important info
I don't want to sound frustrating, but I would really love to hear why so many people always copy bad examples instead of using the examples on the official iText site (Java, C#) or from the book. We aren't hiding the documentation. What can we do to take away the perception that there's no documentation? What can we do to fight the abundance of bad examples?
I'm the original developer of iText. I'm also the author of the "iText in Action" books. In other words: I know what iText is about. I admit that iTextSharp - when extracting a page it fails to carry over Adobe rectangle highlighting important info isn't an exact duplicate of questions such as:
- How to keep original rotate page in itextSharp (dll)
- ITextSharp include all pages from the input file
- Itext pdf Merge : Document overflow outside pdf (Text truncated) page and not displaying
- and many other questions on StackOverflow...
However, the nature of the problem is always identical: instead of reading the official documentation that clearly explains why PdfWriter
shouldn't be used and why PdfStamper
or PdfCopy
are the better solution, people always refer to bad examples published online by people who aren't affiliated with iText in any way.
Is there a way to close a question with a friendly version of RTFM? If not, would it make sense to add this as a reason when voting to close a question. I've thought about "duplicate of", but losing an annotation (iTextSharp - when extracting a page it fails to carry over Adobe rectangle highlighting important info) is different from losing rotation (How to keep original rotate page in itextSharp (dll)) is different from losing page size (Itext pdf Merge : Document overflow outside pdf (Text truncated) page and not displaying) and so on... Only the cause is identical (not reading the official documentation, but instead copy/paste of a bad example).
PdfWriter
shouldn't be used and whyPdfStamper
orPdfCopy
are the better solution" Then why doesPdfWriter
even exist? Even more so, because if I were looking to write a friggen pdf, the first thing I'd latch onto would be something called PdfWriter Signed, Genuinely ConfusedPdfWriter
is the original, and is less functional than the others - and that it still exists only for compatibility.PdfWriter
is the class you use to create documents from scratch. You can import pages from existing pages, for instance scaling them to thumbnails. Scaling and tiling ("N-upping" a document) are also common use cases for whichPdfWriter
is useful. However: if you want to copy documents, you should usePdfCopy
. If you want to stamp stuff on a document, you should usePdfStamper
.PdfWriter
,PdfCopy
andPdfStamper
;-)