SlideShare une entreprise Scribd logo
1  sur  71
Télécharger pour lire hors ligne
iText in Action — 2nd Edition
               Bruno Lowagie @ Zenika
                   March 10, 2011

1T3XT BVBA, the iText Company      http://itextpdf.com/
About this talk
• 2010:
    – History of iText: development & IP
    – How to write a book
    – Book preview
• 2011:
    – Book overview
    – Samples: code snippets, PDFs, techniques
    – The future of iText

1T3XT BVBA, the iText Company        http://itextpdf.com/
First edition: 2006




1T3XT BVBA, the iText Company    http://itextpdf.com/
Second Edition: 2010

                                10Q2:
                                ebooks: 1526
                                pbooks: 1953




1T3XT BVBA, the iText Company       http://itextpdf.com/
Examples on SourceForge




1T3XT BVBA, the iText Company   http://itextpdf.com/
Chapter info on itextpdf.com




1T3XT BVBA, the iText Company   http://itextpdf.com/
Part 1
Creating PDF from scratch
• Ch 1: Introducing PDF and iText
• Ch 2: Using iText’s basic building blocks
• Ch 3: Adding content at absolute
  positions
• Ch 4: Organizing content in tables
• Ch 5: Table, cell, and page events

1T3XT BVBA, the iText Company            http://itextpdf.com/
Creating PDF from scratch
                          Hello World

Creating PDF with iText   // step 1
1. Create a Document      Document document = new Document();
2. Create a Writer        // step 2
3. Open the Document      PdfWriter.getInstance(
4. Add content              document, new FileOutputStream(filename));
                          // step 3
5. Close the Document
                          document.open();
                          // step 4
                          document.add(new Paragraph("Hello World!"));
                          // step 5
                          document.close();




        1T3XT BVBA, the iText Company                 http://itextpdf.com/
Basic Building Blocks




1T3XT BVBA, the iText Company   http://itextpdf.com/
Database




1T3XT BVBA, the iText Company        http://itextpdf.com/
Report using tables




1T3XT BVBA, the iText Company   http://itextpdf.com/
Report using direct content




1T3XT BVBA, the iText Company   http://itextpdf.com/
Combining approaches




1T3XT BVBA, the iText Company   http://itextpdf.com/
Part 2
Manipulating existing PDF documents
• Ch 6: Working with existing PDFs
• Ch 7: Making documents interactive
• Ch 8: Filling out interactive forms




1T3XT BVBA, the iText Company            http://itextpdf.com/
Invoice application




1T3XT BVBA, the iText Company   http://itextpdf.com/
An all PDF web app?!?




1T3XT BVBA, the iText Company   http://itextpdf.com/
AcroForm
• AcroForm
        PdfReader reader =
                 new PdfReader("resources/pdf/subscribe.pdf");
        PdfStamper stamper = new PdfStamper(reader,
                 new FileOutputStream("results/subscribed.pdf"));
        AcroFields form = stamper.getAcroFields();
        form.setField("personal.name", "Bruno Lowagie");
        form.setField("personal.loginname", "blowagie");
        form.setField("personal.password", "12345678");
        form.setField("personal.reason",
                 "Because!nI want to be subscribed");
        stamper.setFormFlattening(true);
        stamper.close();




1T3XT BVBA, the iText Company                    http://itextpdf.com/
AcroForm
    Interactive                  Flattened




1T3XT BVBA, the iText Company        http://itextpdf.com/
XML Data




1T3XT BVBA, the iText Company        http://itextpdf.com/
XML Schema Definition




1T3XT BVBA, the iText Company   http://itextpdf.com/
Creating a dynamic XFA form




1T3XT BVBA, the iText Company   http://itextpdf.com/
Importing an XSD




1T3XT BVBA, the iText Company   http://itextpdf.com/
Rearranged fields




1T3XT BVBA, the iText Company   http://itextpdf.com/
Dynamic XFA form




1T3XT BVBA, the iText Company   http://itextpdf.com/
Fill out the form
• XFA
        PdfReader reader = new PdfReader(src);
        PdfStamper stamper = new PdfStamper(reader,
                new FileOutputStream(dest));
        AcroFields form = stamper.getAcroFields();
        XfaForm xfa = form.getXfa();
        xfa.fillXfaForm(new FileInputStream(xml));
        stamper.close();




1T3XT BVBA, the iText Company                 http://itextpdf.com/
Form with data




1T3XT BVBA, the iText Company   http://itextpdf.com/
A look inside the form




1T3XT BVBA, the iText Company   http://itextpdf.com/
Part 3
Essential iText skills
• Ch 9: Integrating iText in your web
  application
• Ch 10: Brightening your document with
  color and images
• Ch 11: Choosing the right font
• Ch 12: Protecting your PDF

1T3XT BVBA, the iText Company            http://itextpdf.com/
Structure of a
         PDF file                    %PDF-1.x
                                     %âãÏ•
                                         Ó
                                     1 0 obj
                                     ...
A PDF file consists                  2 0 obj
of a collection of                   ... (Hello World) Tj ...
objects.                             xref
A PDF files starts                   0 81
                                     0000000000 65535 f
with %PDF-1.x and                    0000000015 00000 n
                                     ...
ends with %%EOF                      trailer
                                     << ... >>
                                     startxref
                                     15787
                                     %%EOF

     1T3XT BVBA, the iText Company                   http://itextpdf.com/
Changing the
         content of a
         PDF file                    %PDF-1.x
                                     %âãÏ•
                                         Ó
                                     1 0 obj
                                     ...
                                     2 0 obj
You can use                          ... (Hello People) Tj ...
software to change                   121 0 obj
                                     ...
the content of a                     xref
PDF document:                        0 85
                                     0000000000 65535 f
change a stream,                     0000000015 00000 n
add objects (e.g                     ...
                                     trailer
annotations), and                    << ... >>
so on.                               startxref
                                     16157
                                     %%EOF

     1T3XT BVBA, the iText Company                   http://itextpdf.com/
What are our concerns?
• Integrity—we want assurance that the
  document hasn’t been changed
  somewhere in the workflow
• Authenticity—we want assurance that
  the author of the document is who we
  think it is (and not somebody else)
• Non-repudiation—we want assurance
  that the author can’t deny his authorship.

1T3XT BVBA, the iText Company   http://itextpdf.com/
Integrity
• A digest is computed over a range of
  bytes from the file.
• This ByteRange is signed using the private
  key of the sender.
• This digest and the sender’s Certificate
  are embedded in the PDF.
• The receiver compares the embedded
  digest with the digest of the content.
1T3XT BVBA, the iText Company          http://itextpdf.com/
Digital
         Signature
         field                       %PDF-1.x
                                     %âãÏ•Ó
                                     1 0 obj
                                     ...
                                     2 0 obj
A signed PDF file                    <<
contains a signature                    /Type/Sig /Contents/...
                                     >>
dictionary.                          ...
The binary value of                  xref
                                     0 81
the PDF signature is                 0000000000 65535 f
                                     ...
placed into the                      trailer
Contents entry of a                  << ... >>
                                     startxref
signature dictionary.                15787
                                     %%EOF

     1T3XT BVBA, the iText Company                   http://itextpdf.com/
Embedded
         Digital
         Signature                   %PDF-1.x
                                     %âãÏ•
                                         Ó
                                     ...
                                     2 0 obj
                                     <<... /Type/Sig /Contents<
The digital
                                     DIGITAL
signature isn’t part                 SIGNATURE
of the ByteRange.                    > ... >>
                                     xref
There are no bytes                   0 81
in the PDF that                      0000000000 65535 f
                                     ...
aren’t covered,                      trailer
other than the PDF                   << ... >>
                                     startxref
signature itself.                    15787
                                     %%EOF


     1T3XT BVBA, the iText Company                   http://itextpdf.com/
Cryptography
• Symmetric key algorithms: the same key
  is used to encrypt and decrypt content.
• Asymmetric key algorithms: a public key
  is used to encrypt, a private key is used to
  decrypt (for encryption purposes).
• Or, a private key is used to encrypt, a
  public key is used to decrypt (for digital
  signatures).

1T3XT BVBA, the iText Company    http://itextpdf.com/
Obtain a public/private key
• Create your own keystore (with the
  private key) and self-signed certificate
  (with the public key); e.g. using keytool
• Ask a Certificate Authority (CA) to sign
  your certificate to prove your identity
• A Certificate signed by a CA’s private key
  can be decrypted with the CA’s root
  certificate (stored in Adobe Reader)

1T3XT BVBA, the iText Company    http://itextpdf.com/
Digital Signatures
Stored on the producer’s side         Received by the consumer
• Certificate                         %PDF-1.x
   – Public key                       ...
                                      /ByteRange ...
   – Identity info
                                      /Contents<
• Private key                         DIGITAL SIGNATURE
• Original document                   • Certificate
                                      • Signed Message Digest
       ByteRange                      • Timestamp
                                      >...
                                      %%EOF




      1T3XT BVBA, the iText Company                    http://itextpdf.com/
Possible architecture
                                        Application    Device
 %PDF-1.x
 ...
                           DIGITAL SIGNATURE
                           • Certificate
                                                       • Signed Message
                                                         Digest
                           • Timestamp
...
%%EOF

 Existing PDF document      Fill out signature field    Externally sign digest
Created by PDF producer            Using iText           created with iText

        1T3XT BVBA, the iText Company                     http://itextpdf.com/
Displaying digital signatures
• Digital signatures are part of the file
  structure: it isn’t mandatory for a digital
  signature to be displayed on a page.
• Digital signatures are listed in the
  signature panel.
• A digital signature can be visualized as a
  field widget (this widget can consist of
  graphics, text,...).

1T3XT BVBA, the iText Company     http://itextpdf.com/
Invisible signature




1T3XT BVBA, the iText Company    http://itextpdf.com/
Visible signature




1T3XT BVBA, the iText Company    http://itextpdf.com/
Invalid signature




1T3XT BVBA, the iText Company    http://itextpdf.com/
Custom signature




1T3XT BVBA, the iText Company   http://itextpdf.com/
Important note
• A signature signs the complete
  document.
• The concept of signing separate pages in
  a document (“to initial a document”)
  doesn’t exist in PDF.
• Legal issue: how to prove that a person
  who signed for approval has read the
  complete document?

1T3XT BVBA, the iText Company   http://itextpdf.com/
Serial
         signatures                  %PDF-1.x
                                     % Original document
                                     DIGITAL SIGNATURE 1
                                     ...
A PDF document can                   %%EOF                         Rev1
be signed more than                  % Additional content 1
once, but parallel                   ...
                                     DIGITAL SIGNATURE 2
signatures aren’t
                                     ...
supported, only                      %%EOF                         Rev2
serial signatures:                   % Additional content 2
                                     ...
additional signatures
                                     DIGITAL SIGNATURE 3
sign all previous
                                     ...
signatures.                          %%EOF                         Rev3

     1T3XT BVBA, the iText Company              http://itextpdf.com/
Demo: two signatures




1T3XT BVBA, the iText Company   http://itextpdf.com/
Types of signatures
• Certification (aka author) signature—
  only possible for the first revision;
  involves modification detection
  permissions.
• Approval (aka recipient) signature—
  workflow with subsequent signers.
• Usage Rights signature— involving
  Adobe’s private key to Reader enable a
  PDF (off-topic here).

1T3XT BVBA, the iText Company   http://itextpdf.com/
Problems solved?
• Integrity—signature is invalidated if bytes
  are changed
• Authenticity—Certificate Authority
  verifies the identity of the owner of the
  private key
• Non-repudiation—the author is the only
  one who has access to the private key


1T3XT BVBA, the iText Company    http://itextpdf.com/
What if?
• What if the author’s private key is
  compromised?
• What if the author falsifies the creation
  date of the document?
• What if the certificate expires too soon?




1T3XT BVBA, the iText Company         http://itextpdf.com/
Revocation checking
• Certificate Revocation List (CRL)
    The certificate is checked against a list of
    revoked certificates.
• Online Certificate Status Protocol (OCSP)
    The revokation status is obtained from a
    server.
    If the certificate was revoked, the
    signature is invalid.

1T3XT BVBA, the iText Company           http://itextpdf.com/
OCSP




1T3XT BVBA, the iText Company          http://itextpdf.com/
Timestamping
• The timestamp of a signature can be
  based on the signer’s local machine time,
• Or the signer can involve a Time Stamp
  Authority (TSA). The message digest is
  sent to a trusted timestamp server. This
  server adds a timestamp and signs the
  resulting hash using the TSA’s private key.
• The signer can’t forge the time anymore.

1T3XT BVBA, the iText Company    http://itextpdf.com/
Timestamp




1T3XT BVBA, the iText Company       http://itextpdf.com/
PAdES - LTV
• PAdES: PDF Advanced Electronic Signatures
• LTV: Long Term Validation
• Requires extensions to ISO-32000-1
• Described by ETSI in TS 102 778 part 4
• Requires Document Security Store (DSS)
  and Document Timestamp
• A new DSS+TS are added before expiration
  of the last document timestamp
1T3XT BVBA, the iText Company         http://itextpdf.com/
Part 4
Under the hood
• Ch 13: PDFs inside-out
• Ch 14: The imaging model
• Ch 15: Page content and structure
• Ch 16: PDF streams




1T3XT BVBA, the iText Company            http://itextpdf.com/
Parsing PDF




1T3XT BVBA, the iText Company         http://itextpdf.com/
Render
                listener
                interface


RenderListener                      public void renderText(
                                            TextRenderInfo renderInfo) {
beginTextBlock()
                                      System.out.print("<");
renderText(TextRenderInfo info)       System.out.print(renderInfo.getText());
endTextBlock()                        System.out.print(" @ (");
renderImage(ImageRenderInfo info)     System.out.print(
                                        renderInfo.getBaseline()
                                          .getStartPoint().get(0));
                                       System.out.print(", ");
                                       System.out.print(
                                         renderInfo.getBaseline()
                                           .getStartPoint().get(1));
                                      System.out.print(") l: ");
                                      System.out.print(
                                        renderInfo.getBaseline()
                                          .getLength());
                                      System.out.println(">");
                                    }



          1T3XT BVBA, the iText Company                        http://itextpdf.com/
Output




1T3XT BVBA, the iText Company            http://itextpdf.com/
Tagged PDF




1T3XT BVBA, the iText Company        http://itextpdf.com/
Optional Content
• A different type of marked content:
        PdfLayer a1 = new PdfLayer("answer 1", writer);
        a1.setOn(false);
        BaseFont bf = BaseFont.createFont();
        PdfContentByte cb = writer.getDirectContent();
        cb.setRGBColorFill(0xFF, 0x00, 0x00);
        cb.beginText();
        cb.setFontAndSize(bf, 18);
        cb.beginLayer(a1);
        cb.showTextAligned(Element.ALIGN_LEFT,
                 "A1: Stanley Kubrick", 50, 742, 0);
        cb.endLayer();
        cb.endText();




1T3XT BVBA, the iText Company                    http://itextpdf.com/
Portable collections




1T3XT BVBA, the iText Company   http://itextpdf.com/
Creating a Flash Component




1T3XT BVBA, the iText Company   http://itextpdf.com/
Flash component in HTML




1T3XT BVBA, the iText Company   http://itextpdf.com/
Online XML data




1T3XT BVBA, the iText Company   http://itextpdf.com/
Crossdomain.xml




1T3XT BVBA, the iText Company   http://itextpdf.com/
Flash component in PDF




1T3XT BVBA, the iText Company   http://itextpdf.com/
The future of iText
Five ideas for 2011
•   The frustration of working with HTMLWorker
•   Finally start working on XFA to PDF conversion
•   Digital Signatures: PAdES, timestamps,...
•   Eclipse plug-in for iText
•   iText for Android
Additional ideas:
• Accessibility (Tagged PDF, PDF/UA?)
• GIS Options

1T3XT BVBA, the iText Company         http://itextpdf.com/
HTMLWorker
• Support for straight forward HTML
    – No URL to PDF conversion yet
    – Support for more HTML tags and CSS styles
    – Target for iText 5.1 (April 2011)
        • HTML generated with FCKEditor and TinyMC
        • “Rich Text” as defined in XFA and PDF specs
• Support for all HTML would be nice too
    – Full blown HTML to PDF conversion
    – Do what a browser does

1T3XT BVBA, the iText Company             http://itextpdf.com/
XFA to PDF
• The new HTMLWorker will be based on a
  new class XMLWorker
• XFA is the XML Forms Architecture
• With Adobe’s “Rich Text”, we’re already
  implementing a small part of the XFA.
• Once iText 5.1 is released we’re ready to
  start an XFA to PDF project, but...
• Is there a sponsor for such a project?
1T3XT BVBA, the iText Company         http://itextpdf.com/
Digital Signatures
• PAdES: needs to be in future iText version
• Signing server: product?
• Timestamp server: service?




1T3XT BVBA, the iText Company   http://itextpdf.com/
iText for Android
• iText light for phones
    – Demo: Hello world
• iText full for tablet PCs




1T3XT BVBA, the iText Company    http://itextpdf.com/

Contenu connexe

Similaire à Zenika - iText in Action

The Factors For The Website
The Factors For The WebsiteThe Factors For The Website
The Factors For The Website
Julie May
 
OSSBarCamp Talk on Dexy
OSSBarCamp Talk on DexyOSSBarCamp Talk on Dexy
OSSBarCamp Talk on Dexy
ananelson
 
C5 c++ development environment
C5 c++ development environmentC5 c++ development environment
C5 c++ development environment
snchnchl
 
Phpconf taiwan-2012
Phpconf taiwan-2012Phpconf taiwan-2012
Phpconf taiwan-2012
Hash Lin
 

Similaire à Zenika - iText in Action (20)

Easy contributable internationalization process with Sphinx (PyCon APAC 2015 ...
Easy contributable internationalization process with Sphinx (PyCon APAC 2015 ...Easy contributable internationalization process with Sphinx (PyCon APAC 2015 ...
Easy contributable internationalization process with Sphinx (PyCon APAC 2015 ...
 
Camptocamp webkit
Camptocamp webkitCamptocamp webkit
Camptocamp webkit
 
Easy contributable internationalization process with Sphinx @ pyconsg2015
Easy contributable internationalization process with Sphinx @ pyconsg2015Easy contributable internationalization process with Sphinx @ pyconsg2015
Easy contributable internationalization process with Sphinx @ pyconsg2015
 
Openpicus Flyport interfaces the cloud services
Openpicus Flyport interfaces the cloud servicesOpenpicus Flyport interfaces the cloud services
Openpicus Flyport interfaces the cloud services
 
The Factors For The Website
The Factors For The WebsiteThe Factors For The Website
The Factors For The Website
 
0 csc 3311 slide internet programming
0 csc 3311 slide internet programming0 csc 3311 slide internet programming
0 csc 3311 slide internet programming
 
4 - Standards
4  - Standards4  - Standards
4 - Standards
 
Hiding Malicious Content in PDF Documents
Hiding Malicious Content in PDF DocumentsHiding Malicious Content in PDF Documents
Hiding Malicious Content in PDF Documents
 
How to Integrate Internet of Things with Webserver with
How to Integrate Internet of Things with Webserver with How to Integrate Internet of Things with Webserver with
How to Integrate Internet of Things with Webserver with
 
Easy contributable internationalization process with Sphinx @ pyconmy2015
Easy contributable internationalization process with Sphinx @ pyconmy2015Easy contributable internationalization process with Sphinx @ pyconmy2015
Easy contributable internationalization process with Sphinx @ pyconmy2015
 
python programming.pptx
python programming.pptxpython programming.pptx
python programming.pptx
 
World Wide Web(WWW)
World Wide Web(WWW)World Wide Web(WWW)
World Wide Web(WWW)
 
Easy contributable internationalization process with Sphinx @ PyCon APAC 2016
Easy contributable internationalization process with Sphinx @ PyCon APAC 2016Easy contributable internationalization process with Sphinx @ PyCon APAC 2016
Easy contributable internationalization process with Sphinx @ PyCon APAC 2016
 
OSSBarCamp Talk on Dexy
OSSBarCamp Talk on DexyOSSBarCamp Talk on Dexy
OSSBarCamp Talk on Dexy
 
Advanced Pdf Tricks
Advanced Pdf TricksAdvanced Pdf Tricks
Advanced Pdf Tricks
 
C5 c++ development environment
C5 c++ development environmentC5 c++ development environment
C5 c++ development environment
 
How bol.com makes sense of its logs, using the Elastic technology stack.
How bol.com makes sense of its logs, using the Elastic technology stack.How bol.com makes sense of its logs, using the Elastic technology stack.
How bol.com makes sense of its logs, using the Elastic technology stack.
 
Internet and html
Internet and htmlInternet and html
Internet and html
 
Phpconf taiwan-2012
Phpconf taiwan-2012Phpconf taiwan-2012
Phpconf taiwan-2012
 
Switch to alfresco with wasaaiq [compatibility mode]
Switch to alfresco with wasaaiq [compatibility mode]Switch to alfresco with wasaaiq [compatibility mode]
Switch to alfresco with wasaaiq [compatibility mode]
 

Plus de Bruno Lowagie

Plus de Bruno Lowagie (19)

The Dark Magic of Start-Up Valuation
The Dark Magic of Start-Up ValuationThe Dark Magic of Start-Up Valuation
The Dark Magic of Start-Up Valuation
 
Open Source Survival: A Story from the Trenches
Open Source Survival: A Story from the TrenchesOpen Source Survival: A Story from the Trenches
Open Source Survival: A Story from the Trenches
 
Entreprenerd: presenting the book
Entreprenerd: presenting the bookEntreprenerd: presenting the book
Entreprenerd: presenting the book
 
The Secret of your Success
The Secret of your SuccessThe Secret of your Success
The Secret of your Success
 
Blockchain: use cases for the future
Blockchain: use cases for the futureBlockchain: use cases for the future
Blockchain: use cases for the future
 
Blockchain Fundamentals
Blockchain FundamentalsBlockchain Fundamentals
Blockchain Fundamentals
 
How can large open source projects be monetized?
How can large open source projects be monetized?How can large open source projects be monetized?
How can large open source projects be monetized?
 
Open source: an introduction to IP and Legal
Open source: an introduction to IP and LegalOpen source: an introduction to IP and Legal
Open source: an introduction to IP and Legal
 
How can large open source projects be monetized?
How can large open source projects be monetized?How can large open source projects be monetized?
How can large open source projects be monetized?
 
Four failures and one hit
Four failures and one hitFour failures and one hit
Four failures and one hit
 
Startup Legal and IP
Startup Legal and IPStartup Legal and IP
Startup Legal and IP
 
Startup Weekend Ghent
Startup Weekend GhentStartup Weekend Ghent
Startup Weekend Ghent
 
Community Leadership Summit - Calistoga March 2013
Community Leadership Summit - Calistoga March 2013Community Leadership Summit - Calistoga March 2013
Community Leadership Summit - Calistoga March 2013
 
Bizcamp #8: The Founder's Dilemmas, Control vs. Wealth decisions
Bizcamp #8: The Founder's Dilemmas, Control vs. Wealth decisionsBizcamp #8: The Founder's Dilemmas, Control vs. Wealth decisions
Bizcamp #8: The Founder's Dilemmas, Control vs. Wealth decisions
 
Kruispunt Brugsepoortstraat
Kruispunt BrugsepoortstraatKruispunt Brugsepoortstraat
Kruispunt Brugsepoortstraat
 
What's new in PDF 2.0 regarding digital signatures
What's new in PDF 2.0 regarding digital signaturesWhat's new in PDF 2.0 regarding digital signatures
What's new in PDF 2.0 regarding digital signatures
 
De lijn
De lijnDe lijn
De lijn
 
PDF Digital signatures
PDF Digital signaturesPDF Digital signatures
PDF Digital signatures
 
A Hippopotamus for Christmas
A Hippopotamus for ChristmasA Hippopotamus for Christmas
A Hippopotamus for Christmas
 

Dernier

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Dernier (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 

Zenika - iText in Action

  • 1. iText in Action — 2nd Edition Bruno Lowagie @ Zenika March 10, 2011 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 2. About this talk • 2010: – History of iText: development & IP – How to write a book – Book preview • 2011: – Book overview – Samples: code snippets, PDFs, techniques – The future of iText 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 3. First edition: 2006 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 4. Second Edition: 2010 10Q2: ebooks: 1526 pbooks: 1953 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 5. Examples on SourceForge 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 6. Chapter info on itextpdf.com 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 7. Part 1 Creating PDF from scratch • Ch 1: Introducing PDF and iText • Ch 2: Using iText’s basic building blocks • Ch 3: Adding content at absolute positions • Ch 4: Organizing content in tables • Ch 5: Table, cell, and page events 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 8. Creating PDF from scratch Hello World Creating PDF with iText // step 1 1. Create a Document Document document = new Document(); 2. Create a Writer // step 2 3. Open the Document PdfWriter.getInstance( 4. Add content document, new FileOutputStream(filename)); // step 3 5. Close the Document document.open(); // step 4 document.add(new Paragraph("Hello World!")); // step 5 document.close(); 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 9. Basic Building Blocks 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 10. Database 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 11. Report using tables 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 12. Report using direct content 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 13. Combining approaches 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 14. Part 2 Manipulating existing PDF documents • Ch 6: Working with existing PDFs • Ch 7: Making documents interactive • Ch 8: Filling out interactive forms 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 15. Invoice application 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 16. An all PDF web app?!? 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 17. AcroForm • AcroForm PdfReader reader = new PdfReader("resources/pdf/subscribe.pdf"); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("results/subscribed.pdf")); AcroFields form = stamper.getAcroFields(); form.setField("personal.name", "Bruno Lowagie"); form.setField("personal.loginname", "blowagie"); form.setField("personal.password", "12345678"); form.setField("personal.reason", "Because!nI want to be subscribed"); stamper.setFormFlattening(true); stamper.close(); 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 18. AcroForm Interactive Flattened 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 19. XML Data 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 20. XML Schema Definition 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 21. Creating a dynamic XFA form 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 22. Importing an XSD 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 23. Rearranged fields 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 24. Dynamic XFA form 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 25. Fill out the form • XFA PdfReader reader = new PdfReader(src); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest)); AcroFields form = stamper.getAcroFields(); XfaForm xfa = form.getXfa(); xfa.fillXfaForm(new FileInputStream(xml)); stamper.close(); 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 26. Form with data 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 27. A look inside the form 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 28. Part 3 Essential iText skills • Ch 9: Integrating iText in your web application • Ch 10: Brightening your document with color and images • Ch 11: Choosing the right font • Ch 12: Protecting your PDF 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 29. Structure of a PDF file %PDF-1.x %âãÏ• Ó 1 0 obj ... A PDF file consists 2 0 obj of a collection of ... (Hello World) Tj ... objects. xref A PDF files starts 0 81 0000000000 65535 f with %PDF-1.x and 0000000015 00000 n ... ends with %%EOF trailer << ... >> startxref 15787 %%EOF 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 30. Changing the content of a PDF file %PDF-1.x %âãÏ• Ó 1 0 obj ... 2 0 obj You can use ... (Hello People) Tj ... software to change 121 0 obj ... the content of a xref PDF document: 0 85 0000000000 65535 f change a stream, 0000000015 00000 n add objects (e.g ... trailer annotations), and << ... >> so on. startxref 16157 %%EOF 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 31. What are our concerns? • Integrity—we want assurance that the document hasn’t been changed somewhere in the workflow • Authenticity—we want assurance that the author of the document is who we think it is (and not somebody else) • Non-repudiation—we want assurance that the author can’t deny his authorship. 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 32. Integrity • A digest is computed over a range of bytes from the file. • This ByteRange is signed using the private key of the sender. • This digest and the sender’s Certificate are embedded in the PDF. • The receiver compares the embedded digest with the digest of the content. 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 33. Digital Signature field %PDF-1.x %âãÏ•Ó 1 0 obj ... 2 0 obj A signed PDF file << contains a signature /Type/Sig /Contents/... >> dictionary. ... The binary value of xref 0 81 the PDF signature is 0000000000 65535 f ... placed into the trailer Contents entry of a << ... >> startxref signature dictionary. 15787 %%EOF 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 34. Embedded Digital Signature %PDF-1.x %âãÏ• Ó ... 2 0 obj <<... /Type/Sig /Contents< The digital DIGITAL signature isn’t part SIGNATURE of the ByteRange. > ... >> xref There are no bytes 0 81 in the PDF that 0000000000 65535 f ... aren’t covered, trailer other than the PDF << ... >> startxref signature itself. 15787 %%EOF 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 35. Cryptography • Symmetric key algorithms: the same key is used to encrypt and decrypt content. • Asymmetric key algorithms: a public key is used to encrypt, a private key is used to decrypt (for encryption purposes). • Or, a private key is used to encrypt, a public key is used to decrypt (for digital signatures). 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 36. Obtain a public/private key • Create your own keystore (with the private key) and self-signed certificate (with the public key); e.g. using keytool • Ask a Certificate Authority (CA) to sign your certificate to prove your identity • A Certificate signed by a CA’s private key can be decrypted with the CA’s root certificate (stored in Adobe Reader) 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 37. Digital Signatures Stored on the producer’s side Received by the consumer • Certificate %PDF-1.x – Public key ... /ByteRange ... – Identity info /Contents< • Private key DIGITAL SIGNATURE • Original document • Certificate • Signed Message Digest ByteRange • Timestamp >... %%EOF 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 38. Possible architecture Application Device %PDF-1.x ... DIGITAL SIGNATURE • Certificate • Signed Message Digest • Timestamp ... %%EOF Existing PDF document Fill out signature field Externally sign digest Created by PDF producer Using iText created with iText 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 39. Displaying digital signatures • Digital signatures are part of the file structure: it isn’t mandatory for a digital signature to be displayed on a page. • Digital signatures are listed in the signature panel. • A digital signature can be visualized as a field widget (this widget can consist of graphics, text,...). 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 40. Invisible signature 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 41. Visible signature 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 42. Invalid signature 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 43. Custom signature 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 44. Important note • A signature signs the complete document. • The concept of signing separate pages in a document (“to initial a document”) doesn’t exist in PDF. • Legal issue: how to prove that a person who signed for approval has read the complete document? 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 45. Serial signatures %PDF-1.x % Original document DIGITAL SIGNATURE 1 ... A PDF document can %%EOF Rev1 be signed more than % Additional content 1 once, but parallel ... DIGITAL SIGNATURE 2 signatures aren’t ... supported, only %%EOF Rev2 serial signatures: % Additional content 2 ... additional signatures DIGITAL SIGNATURE 3 sign all previous ... signatures. %%EOF Rev3 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 46. Demo: two signatures 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 47. Types of signatures • Certification (aka author) signature— only possible for the first revision; involves modification detection permissions. • Approval (aka recipient) signature— workflow with subsequent signers. • Usage Rights signature— involving Adobe’s private key to Reader enable a PDF (off-topic here). 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 48. Problems solved? • Integrity—signature is invalidated if bytes are changed • Authenticity—Certificate Authority verifies the identity of the owner of the private key • Non-repudiation—the author is the only one who has access to the private key 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 49. What if? • What if the author’s private key is compromised? • What if the author falsifies the creation date of the document? • What if the certificate expires too soon? 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 50. Revocation checking • Certificate Revocation List (CRL) The certificate is checked against a list of revoked certificates. • Online Certificate Status Protocol (OCSP) The revokation status is obtained from a server. If the certificate was revoked, the signature is invalid. 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 51. OCSP 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 52. Timestamping • The timestamp of a signature can be based on the signer’s local machine time, • Or the signer can involve a Time Stamp Authority (TSA). The message digest is sent to a trusted timestamp server. This server adds a timestamp and signs the resulting hash using the TSA’s private key. • The signer can’t forge the time anymore. 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 53. Timestamp 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 54. PAdES - LTV • PAdES: PDF Advanced Electronic Signatures • LTV: Long Term Validation • Requires extensions to ISO-32000-1 • Described by ETSI in TS 102 778 part 4 • Requires Document Security Store (DSS) and Document Timestamp • A new DSS+TS are added before expiration of the last document timestamp 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 55. Part 4 Under the hood • Ch 13: PDFs inside-out • Ch 14: The imaging model • Ch 15: Page content and structure • Ch 16: PDF streams 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 56. Parsing PDF 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 57. Render listener interface RenderListener public void renderText( TextRenderInfo renderInfo) { beginTextBlock() System.out.print("<"); renderText(TextRenderInfo info) System.out.print(renderInfo.getText()); endTextBlock() System.out.print(" @ ("); renderImage(ImageRenderInfo info) System.out.print( renderInfo.getBaseline() .getStartPoint().get(0)); System.out.print(", "); System.out.print( renderInfo.getBaseline() .getStartPoint().get(1)); System.out.print(") l: "); System.out.print( renderInfo.getBaseline() .getLength()); System.out.println(">"); } 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 58. Output 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 59. Tagged PDF 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 60. Optional Content • A different type of marked content: PdfLayer a1 = new PdfLayer("answer 1", writer); a1.setOn(false); BaseFont bf = BaseFont.createFont(); PdfContentByte cb = writer.getDirectContent(); cb.setRGBColorFill(0xFF, 0x00, 0x00); cb.beginText(); cb.setFontAndSize(bf, 18); cb.beginLayer(a1); cb.showTextAligned(Element.ALIGN_LEFT, "A1: Stanley Kubrick", 50, 742, 0); cb.endLayer(); cb.endText(); 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 61. Portable collections 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 62. Creating a Flash Component 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 63. Flash component in HTML 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 64. Online XML data 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 65. Crossdomain.xml 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 66. Flash component in PDF 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 67. The future of iText Five ideas for 2011 • The frustration of working with HTMLWorker • Finally start working on XFA to PDF conversion • Digital Signatures: PAdES, timestamps,... • Eclipse plug-in for iText • iText for Android Additional ideas: • Accessibility (Tagged PDF, PDF/UA?) • GIS Options 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 68. HTMLWorker • Support for straight forward HTML – No URL to PDF conversion yet – Support for more HTML tags and CSS styles – Target for iText 5.1 (April 2011) • HTML generated with FCKEditor and TinyMC • “Rich Text” as defined in XFA and PDF specs • Support for all HTML would be nice too – Full blown HTML to PDF conversion – Do what a browser does 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 69. XFA to PDF • The new HTMLWorker will be based on a new class XMLWorker • XFA is the XML Forms Architecture • With Adobe’s “Rich Text”, we’re already implementing a small part of the XFA. • Once iText 5.1 is released we’re ready to start an XFA to PDF project, but... • Is there a sponsor for such a project? 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 70. Digital Signatures • PAdES: needs to be in future iText version • Signing server: product? • Timestamp server: service? 1T3XT BVBA, the iText Company http://itextpdf.com/
  • 71. iText for Android • iText light for phones – Demo: Hello world • iText full for tablet PCs 1T3XT BVBA, the iText Company http://itextpdf.com/