Active6 years, 8 months ago
I want to add a text to an existing PDF file using iTextSharp, I found different ways but in all of them the writer and reader are separate pdf files.I want a way so I can open a pdf then write different things in different positions.right now I have this code, but it makes a new file.
Edit PDF This online PDF editor allows you to directly edit a PDF document. Add text or images or draw boxes, circles and arrows on your PDF page. You can also highlight passages or add a watermark to the PDF. Question: How do I use PDF-XChange Editor to edit PDF documents? Answer: There are multiple facets which allow modifications to PDF documents. This article details how to edit the base content of unrestricted PDF documents such as text and images.
Christian Mark5,8711313 gold badges3737 silver badges7676 bronze badges
Mina NMina N9622 gold badges55 silver badges1515 bronze badges
1 Answer
You want to add a text to an existing PDF file using iTextSharp, found different ways but in all of them the writer and reader are separate pdf files.
As the normal way in which iText(Sharp) manipulates a PDF using a PdfStamper, can involve major reorganization of existing PDF elements, iText does not edit a file in place. The other way, using append mode, would allow for editing in place; but such an option is not implemented. A big draw-back of in-place editing is that in case of some program failure, the file in question might remain in an intermediary, unusable state.
That being said, you can save the new file to the path of the original file by first reading the file into memory completely and then starting to create the output with the same path. In case of your sample code that would imply at least moving the PdfReader constructor use before the creation of the output stream:
Alternatively you could create the result file in memory, i.e. in a MemoryStream instead of a FileStream, and, when finished, write the contents of the memory stream to your source file path.
mklmkl60.2k1212 gold badges7373 silver badges164164 bronze badges
Not the answer you're looking for? Browse other questions tagged c#itextsharp or ask your own question.
When you add text in a PDF, by default Acrobat picks nearby font attributes for the new text. Similarly, when you edit existing text in a PDF and the font is not available on the system, by default the font fall-backs to a specific font in a particular script; for example, font fall-backs to Minion Pro in roman script fonts. This default behavior can lead to fonts with inconsistent appearance in a PDF document. To make it consistent throughout all the PDFs, instead of using the default settings, you can choose a specific font for both Add Text and the fallback option in edit text features using the Font Options under the Content Editing preferences.
Note:
If you don't see the 'Fallback font for Editing' and the 'Default font for Add Text' settings under the Font Options section, update your Acrobat DC to the latest version. To automatically update from Acrobat DC, choose Help > Check for updates, and then follow the steps in the Updater window to download and install the latest updates.
To change the default fallback font for editing text:
Pdf Edit Existing Text Message
- Go to Edit > Preferences > Content Editing > Font Options.
- Hp 3055 scanner setup. Select an appropriate font in the Fallback font for editing drop-down list.
To change the default font properties for Add Text:
- Go to Edit > Preferences > Content Editing > Font Options.
- Select an appropriate font in the Default font for Add Text drop-down list.
- Select an appropriate font size in the Font Size drop-down list.
Note:
To restore the default behavior, select Let Acrobat choose in the drop-down list.
Drawboard Pdf Edit Existing Text
Twitter™ and Facebook posts are not covered under the terms of Creative Commons.
Pdf Edit Existing Text File
Legal Notices | Online Privacy Policy