itextsharp | [DEPRECATED] .NET port of the iText library, only security fixes will be added — please use iText 7 | Document Editor library
kandi X-RAY | itextsharp Summary
kandi X-RAY | itextsharp Summary
PLEASE NOTE: iTextSharp is EOL, and has been replaced by iText 7. Only security fixes will be added.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of itextsharp
itextsharp Key Features
itextsharp Examples and Code Snippets
Community Discussions
Trending Discussions on itextsharp
QUESTION
I'm using VS2022, and I received an old project, where iTextSharp was used, but I can't determine a specific version of the mentioned.
I've tried - Tools -> Nuget Package Manager -> Manage Nuget Packages for Solution...
But was unable to find iTextSharp.
Thanks in advance.
...ANSWER
Answered 2022-Apr-04 at 09:44It sounds like the assembly has been included directly in the source control, as was common place before nuget. Take a look in your project's references and you should be able to locate the dll. Checking the file's properties in VS should show you the assembly's details in the properties panel and should also show you which version is being used, if not the path or filename may give you a clue as to the version being used.
QUESTION
I'd like to read an multipage pdf file from the file system and split it to separated pages. The splitted pages i like to save to an list object. The page in the list i want to save in a base64 encoded structure in a xml and send it over a rest api service.
What i have already done:
- Read the pdf file
- Split the pdf file to pages
- Save the pages to a list
What's not relevant and only for completeness of my problem:
- Send the pages with a rest api service waqsy( current no code implemented)
- Xml structure
What's my problem? If i save the pages from the byte array list to the file system and open the pdf (with only one page of the original page) the the pdf file is defect and can't open.
Which error had i made on this process?
What version of iTextSharp i use? 5.4.2
...ANSWER
Answered 2022-Apr-03 at 10:05The PDF in the MemoryStream
is not finished before document
is closed. Thus, you store incomplete PDFs.
To fix this, move
QUESTION
I am pulling data from a printable PDF using iTextSharp. This is the text that I have extracted:
...ANSWER
Answered 2022-Mar-22 at 19:15You could match the last occurrence of Print Name:
and then match as least as possible of the allowed chars until you encounter the same using a backreference until the end of the string.
Note that \s
can also match a newline.
QUESTION
IronBarcode (preferred)
We want to print a QR Code in a Label with iTextSharp. We use IronBarcode to generate the Barcode. Also see: IronBarcode Tutorial
...ANSWER
Answered 2022-Feb-21 at 08:58If you using iTextSharp Why don't do it all the way in iTextSharp?
QUESTION
I've searched all over, but all of the documentation focuses on Java answers which don't have the same methods in the .NET version. I am trying to insert an image to specific positions on a PDF, but I am unable to insert them properly. I can get accurate X/Y coordinates but when it inserts into the PDF, it inserts all of them onto the first page only.
I'm also finding that the height and width don't come out the same as the fields they're replacing. The variables in my watch window show the correct height and width, but it ends up compressed on the PDF. This wasn't a problem with itextSharp when I used to use that.
...ANSWER
Answered 2022-Feb-18 at 13:47According to your code you already do have a page object, the PdfPage page
, and are looking for its page number in the document. You can use the PdfDocument
method
QUESTION
I need to add stamp or image annotation in a signed PDF but it gives me an "invalid signature" error and, after moving this annotation, it gives me an "at least one signature required validating" error. How can I solve this?
I also found a solution but for text annotation in this question. It worked fine with text annotation but I cannot do the same for the stamp.
...ANSWER
Answered 2022-Feb-07 at 10:03This
QUESTION
I'm using iText 7.1.15 and SignDeferred to apply signatures to pdf documents. SignDeferred is required since the signature is created PKCS11 hardware token (usb key).
When i sign a "regular" pdf, e.g. created via word, i can apply multiple signatures and all signatures are shown as valid in the adobe acrobat reader.
If the pdf was created by combining multiple pdf documents with adobe DC, the first signature is valid but becomes invalid as soon as the seconds signature is applied.
Document in Adobe reader after the first signature is applied:
Document in Adobe reader after the second signature is applied:
The signatures of the same document are shown as valid in foxit reader.
I've found a similar issue on stackoverflow (multiple signatures invalidate first signature in iTextSharp pdf signing), but it was using iText 5 and i'm not sure it is the same problem.
Question: What can i do in order to keep both signatures valid in the Acrobat Reader?
Unsigned Pdf document on which the first signature becomes invalid: https://github.com/suntsu42/iTextDemoInvalidSecondSignature/blob/master/test.pdf
Twice signed document which is invalid: https://github.com/suntsu42/iTextDemoInvalidSecondSignature/blob/master/InvalidDocumentSignedTwice.pdf
Code used for signing
...ANSWER
Answered 2022-Jan-28 at 16:35As already mentioned in a comment, the example document "InvalidDocumentSignedTwice.pdf" has the signature not applied in an incremental update, so here it is obvious that former signatures will break. But this is not the issue of the OP's example project. Thus, the issue is processed with an eye on the actual outputs of the example project.
Analyzing the IssueWhen validating signed PDFs Adobe Acrobat executes two types of checks:
- It checks the signature itself and whether the revision of the PDF it covers is untouched.
- (If there are additions to the PDF after the revision covered by the signature:) It checks whether changes applied in incremental updates only consist of allowed changes.
The former check is pretty stable and standard but the second one is very whimsical and prone to incorrect negative validation results. Like in your case...
In case of your example document one can simply determine that the first check must positively validate the first signature: The file with only one (valid!) signature constitutes a byte-wise starting piece of the file with two signatures, so nothing can have been broken here.
Thus, the second type of check, the fickle type, must go wrong in the case at hand.
To find out what change one has to analyze the changes done during signing. A helpful fact is that doing the same using iText 5 does not produce the issue; thus, the change that triggered the check must be in what iText 7 does differently than iText 5 here. And the main difference in this context is that iText 7 has a more thorough tagging support than iText 5 and, therefore, also adds a reference to the new signature field to the document structure tree.
This by itself does not yet trigger the whimsical check, though, it only does so here because one outline element refers to the parent structure tree element of the change as its structure element (SE). Apparently Adobe Acrobat considers the change in the associated structure element as a change of the outline link and, therefore, as a (disallowed) change of the behavior of the document revision signed by the first signature.
So is this an iText error (adding entries to the structure tree) or an Adobe Acrobat error (complaining about the additions)? Well, in a tagged PDF (and your PDF has the corresponding Marked entry set to true) the content including annotations and form fields is expected to be tagged. Thus, addition of structure tree entries for the newly added signature field and its appearance not only should be allowed but actually recommended or even required! So this appears to be an error of Adobe Acrobat.
A Work-AroundKnowing that this appears to be an Adobe Acrobat bug is all well and good, but at the end of the day one might need a way now to sign such documents multiple times without current Adobe Acrobat calling that invalid.
It is possible to make iText believe there is no structure tree and no need to update a structure tree. This can be done by making the initialization of the document tag structure fail. For this we override the PdfDocument
method TryInitTagStructure
. As the iText PdfSigner
creates its document object internally, we do this in an override of the PdfSigner
method InitDocument
.
I.e. instead of PdfSigner
we use the class MySigner
defined like this:
QUESTION
ANSWER
Answered 2021-Dec-20 at 13:15When you are wondering about details of the PDF format, you should have a look into the PDF specification ISO 32000.
Operands Operator Description array TJ Show one or more text strings, allowing individual glyph positioning. Each element of array shall be either a string or a number. If the element is a string, this operator shall show the string. If it is a number, the operator shall adjust the text position by that amount; that is, it shall translate the text matrix, Tm. The number shall be expressed in thousandths of a unit of text space (see 9.4.4, "Text Space Details"). This amount shall be subtracted from the current horizontal or vertical coordinate, depending on the writing mode. In the default coordinate system, a positive adjustment has the effect of moving the next glyph painted either to the left or down by the given amount. Figure 46 shows an example of the effect of passing offsets to TJ.(ISO 32000-1, Table 109 – Text-showing operators)
Thus,
I'm suspecting that the numbers between the literal characters (e.g -1688.21,-492.975,...), may be useful, but I didnt find explanation about such parameters.
What they represent?
For each such number, the operator adjusts the text position by that amount. The number is expressed in thousandths of a unit of text space. This amount is subtracted from the current horizontal or vertical coordinate, depending on the writing mode.
QUESTION
I PDF signing problems with the latest iTextSharp 5. I know that version is already deprecated, but I must use the older one, because I need to use it in an environment, where no newer than .NET Framework v3.5 is allowed.
For singing documents, the clients may use software or hardware keys. We already used RSA signatures in our company, but now we have toimplement support for ECDsa keys too. That's why I tried to sign PDF files with iText's PrivateKeySignature
class, and calling MakeSignature.SignDetached
method.
When I use RSA key for signing a PDF, and try to verify signature with European Commission's DSS Demonstration App (https://ec.europa.eu/cefdigital/DSS/webapp-demo/validation), it has no issue with the signature, only that it not accepts the certificate issuer as a trusted CA. That's fine, because I use a test key generated by an internal CA for developer use only.
But if I use ECDSA key for signing a PDF, the DSS Demonstration App says "Signature is not intact.".
The code I use for signing:
...ANSWER
Answered 2021-Dec-01 at 13:49Just like @mval mentioned in a comment, iText uses the public key algorithm OID as signature algorithm OID.
In case of RSA that is ok as here the same OID is specified for a RSA key and for RSASSA (with PKCS#1 v1.5 padding).
This is not the case for ECDSA, so eSignature DSS complains. Adobe Acrobat (Reader) on the other hand is very lax. It actually ignores the signature algorithm OID field, you could even have an ECDSA signature with the RSA OID in that field and the current Acrobat wouldn't complain.
To fix this use an IExternalSignatureContainer
implementation instead of an IExternalSignature
implementation and call MakeSignature.SignExternalContainer
instead of MakeSignature.SignDetached
. In your IExternalSignatureContainer
implementation you can use BouncyCastle or Windows Crypto API classes to create a CMS signature container.
Other questions related to incorrect signature algorithm OIDs in respect to iText:
QUESTION
With libraries like iTextSharp or iText you can extract metadata from PDF documents via a PdfReader:
...ANSWER
Answered 2021-Nov-09 at 10:07With PDF4NET you can extract the XMP metadata without loading the entire document in memory:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install itextsharp
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page