├── .gitattributes ├── .gitignore ├── .mailmap ├── README.md ├── WebContent ├── WEB-INF │ └── web.xml ├── embedded.html ├── fdf_form.html ├── helloworld.jsp ├── index.html ├── javascript.html ├── javascript.pdf ├── movies.xml ├── submit_me.pdf └── subscribe.pdf ├── index.php ├── pom.xml ├── resources ├── calendar │ ├── 01.jpg │ ├── 02.jpg │ ├── 03.jpg │ ├── 04.jpg │ ├── 05.jpg │ ├── 06.jpg │ ├── 07.jpg │ ├── 08.jpg │ ├── 09.jpg │ ├── 10.jpg │ ├── 11.jpg │ ├── 12.jpg │ ├── 2010.txt │ ├── 2011.txt │ ├── 2012.txt │ └── content.txt ├── db │ └── filmfestival.script ├── encryption │ ├── .keystore │ └── foobar.cer ├── fonts │ ├── Puritan2.otf │ ├── abserif4_5.ttf │ ├── cmr10.afm │ ├── cmr10.pfb │ ├── cmr10.pfm │ ├── copyright_notices.txt │ ├── damase.ttf │ ├── fsex2p00_public.ttf │ ├── wds011402.ttf │ └── wds011402.txt ├── img │ ├── 1t3xt.gif │ ├── amb.jb2 │ ├── animated_fox_dog.gif │ ├── bruno.jpg │ ├── bruno_ingeborg.jpg │ ├── butterfly.bmp │ ├── butterfly.wmf │ ├── close.bmp │ ├── close.png │ ├── foxdog.mpg │ ├── hitchcock.gif │ ├── hitchcock.png │ ├── iia2.jpg │ ├── info.png │ ├── kubrick.jpg │ ├── kubrick_box.jpg │ ├── loa.jpg │ ├── logo.gif │ ├── map.jp2 │ ├── marbles.tif │ ├── movie.gif │ ├── sRGB.profile │ └── teapot.u3d ├── js │ ├── buttons.js │ ├── calculator.js │ ├── extra.js │ ├── find_director.js │ ├── post_from_html.js │ ├── post_to_html.js │ ├── print_page.js │ ├── show_date.js │ └── viewer_version.js ├── jsp │ └── helloworld.jsp ├── pdfs │ ├── broken_form.pdf │ ├── datasheet.odt │ ├── datasheet.pdf │ ├── hero.pdf │ ├── logo.pdf │ ├── movie_overview.odt │ ├── movie_overview.pdf │ ├── preface.pdf │ ├── xfa_enabled.pdf │ ├── xfa_movie.pdf │ └── xfa_movies.pdf ├── posters │ ├── 0033467.jpg │ ├── 0042876.jpg │ ├── 0044741.jpg │ ├── 0047478.jpg │ ├── 0048254.jpg │ ├── 0049406.jpg │ ├── 0050825.jpg │ ├── 0051808.jpg │ ├── 0054331.jpg │ ├── 0055630.jpg │ ├── 0056172.jpg │ ├── 0056193.jpg │ ├── 0056443.jpg │ ├── 0057012.jpg │ ├── 0062622.jpg │ ├── 0066921.jpg │ ├── 0072684.jpg │ ├── 0081505.jpg │ ├── 0088128.jpg │ ├── 0088247.jpg │ ├── 0088847.jpg │ ├── 0090060.jpg │ ├── 0090563.jpg │ ├── 0090583.jpg │ ├── 0091288.jpg │ ├── 0091480.jpg │ ├── 0091790.jpg │ ├── 0092005.jpg │ ├── 0093058.jpg │ ├── 0093206.jpg │ ├── 0094006.jpg │ ├── 0094625.jpg │ ├── 0095765.jpg │ ├── 0095953.jpg │ ├── 0096018.jpg │ ├── 0097576.jpg │ ├── 0098635.jpg │ ├── 0099902.jpg │ ├── 0100436.jpg │ ├── 0100935.jpg │ ├── 0101700.jpg │ ├── 0102494.jpg │ ├── 0103064.jpg │ ├── 0104029.jpg │ ├── 0105652.jpg │ ├── 0107156.jpg │ ├── 0108399.jpg │ ├── 0111797.jpg │ ├── 0113568.jpg │ ├── 0113627.jpg │ ├── 0119349.jpg │ ├── 0120601.jpg │ ├── 0120663.jpg │ ├── 0120679.jpg │ ├── 0120903.jpg │ ├── 0137523.jpg │ ├── 0145487.jpg │ ├── 0154420.jpg │ ├── 0164711.jpg │ ├── 0169102.jpg │ ├── 0180093.jpg │ ├── 0181852.jpg │ ├── 0190332.jpg │ ├── 0201265.jpg │ ├── 0203515.jpg │ ├── 0210727.jpg │ ├── 0211915.jpg │ ├── 0235060.jpg │ ├── 0245429.jpg │ ├── 0245712.jpg │ ├── 0246578.jpg │ ├── 0247586.jpg │ ├── 0255589.jpg │ ├── 0256009.jpg │ ├── 0259393.jpg │ ├── 0266308.jpg │ ├── 0268126.jpg │ ├── 0269217.jpg │ ├── 0270288.jpg │ ├── 0278736.jpg │ ├── 0279064.jpg │ ├── 0283509.jpg │ ├── 0290334.jpg │ ├── 0299977.jpg │ ├── 0301357.jpg │ ├── 0311648.jpg │ ├── 0316654.jpg │ ├── 0320042.jpg │ ├── 0323872.jpg │ ├── 0338013.jpg │ ├── 0339230.jpg │ ├── 0344510.jpg │ ├── 0347149.jpg │ ├── 0348150.jpg │ ├── 0362496.jpg │ ├── 0368619.jpg │ ├── 0372782.jpg │ ├── 0372784.jpg │ ├── 0374546.jpg │ ├── 0376007.jpg │ ├── 0376994.jpg │ ├── 0378284.jpg │ ├── 0385004.jpg │ ├── 0388795.jpg │ ├── 0402595.jpg │ ├── 0413300.jpg │ ├── 0418832.jpg │ ├── 0419073.jpg │ ├── 0423866.jpg │ ├── 0445691.jpg │ ├── 0449059.jpg │ ├── 0452623.jpg │ ├── 0457430.jpg │ ├── 0468569.jpg │ ├── 0473444.jpg │ ├── 0482901.jpg │ ├── 0809931.jpg │ ├── 0813547.jpg │ ├── 0857355.jpg │ └── 0948530.jpg ├── scripts │ ├── filmfestival.sql │ ├── filmfestival_hsqldb.sql │ └── filmfestival_mysql.sql ├── swf │ ├── FestivalCalendar1.mxml │ ├── FestivalCalendar1.swf │ ├── FestivalCalendar2.mxml │ └── FestivalCalendar2.swf ├── txt │ ├── hero.txt │ └── test.txt └── xml │ ├── foobarcity.svg │ ├── foobarrues.svg │ ├── foobarstraten.svg │ ├── foobarstreets.svg │ ├── moby.xml │ ├── movies.xsd │ ├── peace.xml │ ├── say_peace.xml │ └── xfa.xml └── src ├── com └── lowagie │ ├── database │ ├── CreateHsqldbTables.java │ ├── DatabaseConnection.java │ ├── HsqldbConnection.java │ └── MySqlConnection.java │ └── filmfestival │ ├── Category.java │ ├── Country.java │ ├── Director.java │ ├── Entry.java │ ├── FilmFonts.java │ ├── Movie.java │ ├── MovieComparator.java │ ├── PojoFactory.java │ ├── PojoToElementFactory.java │ └── Screening.java ├── part1 ├── chapter01 │ ├── HelloWorld.java │ ├── HelloWorldColumn.java │ ├── HelloWorldDirect.java │ ├── HelloWorldLandscape1.java │ ├── HelloWorldLandscape2.java │ ├── HelloWorldLetter.java │ ├── HelloWorldMaximum.java │ ├── HelloWorldMemory.java │ ├── HelloWorldMirroredMargins.java │ ├── HelloWorldMirroredMarginsTop.java │ ├── HelloWorldNarrow.java │ ├── HelloWorldVersion_1_7.java │ └── HelloZip.java ├── chapter02 │ ├── CountryChunks.java │ ├── DatabaseTest.java │ ├── DirectorOverview1.java │ ├── DirectorOverview2.java │ ├── DirectorOverview3.java │ ├── DirectorPhrases1.java │ ├── DirectorPhrases2.java │ ├── MovieChain.java │ ├── MovieHistory.java │ ├── MovieLinks1.java │ ├── MovieLinks2.java │ ├── MovieLists1.java │ ├── MovieLists2.java │ ├── MovieLists3.java │ ├── MovieLists4.java │ ├── MovieParagraphs1.java │ ├── MovieParagraphs2.java │ ├── MoviePosters1.java │ ├── MoviePosters2.java │ ├── MoviePosters3.java │ ├── MovieTitles.java │ ├── PipeSplitCharacter.java │ ├── PositionedArrow.java │ ├── RiverPhoenix.java │ └── StarSeparator.java ├── chapter03 │ ├── ColumnMovies1.java │ ├── ColumnMovies2.java │ ├── FestivalOpening.java │ ├── FoobarFilmFestival.java │ ├── GraphicsStateStack.java │ ├── ImageDirect.java │ ├── ImageInline.java │ ├── ImageSkew.java │ ├── MovieCalendar.java │ ├── MovieColumns1.java │ ├── MovieColumns2.java │ ├── MovieColumns3.java │ ├── MovieColumns4.java │ ├── MoviePosters.java │ ├── MovieTemplates.java │ ├── MovieTextInfo.java │ ├── MovieTimeBlocks.java │ └── MovieTimeTable.java ├── chapter04 │ ├── CellHeights.java │ ├── ColumnTable.java │ ├── ColumnWidths.java │ ├── HeaderFooter1.java │ ├── HeaderFooter2.java │ ├── MemoryTests.java │ ├── MovieCompositeMode.java │ ├── MovieTextMode.java │ ├── MyFirstTable.java │ ├── NestedTable.java │ ├── NestedTables.java │ ├── PdfCalendar.java │ ├── RotationAndColors.java │ ├── Spacing.java │ ├── TableAlignment.java │ ├── TableHeight.java │ ├── XMen.java │ └── Zhang.java └── chapter05 │ ├── AlternatingBackground.java │ ├── Hero1.java │ ├── Hero2.java │ ├── Hero3.java │ ├── MovieCountries1.java │ ├── MovieCountries2.java │ ├── MovieHistory1.java │ ├── MovieHistory2.java │ ├── MovieSlideShow.java │ ├── MovieYears.java │ ├── NewPage.java │ ├── PdfCalendar.java │ ├── PressPreviews.java │ └── RunLengthEvent.java ├── part2 ├── chapter06 │ ├── Burst.java │ ├── Concatenate.java │ ├── ConcatenateForms1.java │ ├── ConcatenateForms2.java │ ├── ConcatenateStamp.java │ ├── DataSheets1.java │ ├── DataSheets2.java │ ├── FillDataSheet.java │ ├── FormInformation.java │ ├── ImportingPages1.java │ ├── ImportingPages2.java │ ├── InsertPages.java │ ├── Layers.java │ ├── MemoryInfo.java │ ├── NUpTool.java │ ├── PageInformation.java │ ├── SelectPages.java │ ├── StampStationery.java │ ├── StampText.java │ ├── Stationery.java │ ├── Superimposing.java │ ├── TilingHero.java │ └── TwoPasses.java ├── chapter07 │ ├── AddVersionChecker.java │ ├── Advertisement.java │ ├── BookmarkedTimeTable.java │ ├── ButtonsActions.java │ ├── Calculator.java │ ├── ConcatenateBookmarks.java │ ├── ConcatenateNamedDestinations.java │ ├── CreateOutlineTree.java │ ├── EventsAndActions.java │ ├── FindDirectors.java │ ├── GenericAnnotations.java │ ├── LaunchAction.java │ ├── LinkActions.java │ ├── MovieAnnotations1.java │ ├── MovieAnnotations2.java │ ├── MovieAnnotations3.java │ ├── MoviePosters1.java │ ├── MoviePosters2.java │ ├── NamedActions.java │ ├── PrintTimeTable.java │ ├── TimetableAnnotations1.java │ ├── TimetableAnnotations2.java │ ├── TimetableAnnotations3.java │ └── TimetableDestinations.java └── chapter08 │ ├── Buttons.java │ ├── ChildFieldEvent.java │ ├── ChoiceFields.java │ ├── MovieAds.java │ ├── RadioButtons.java │ ├── ReaderEnabledForm.java │ ├── ReplaceIcon.java │ ├── Subscribe.java │ ├── TextFieldActions.java │ ├── TextFieldFonts.java │ ├── TextFields.java │ ├── XfaMovie.java │ └── XfaMovies.java ├── part3 ├── chapter09 │ ├── CreateFDF.java │ ├── FDFServlet.java │ ├── FormServlet.java │ ├── Hello.java │ ├── HtmlMovies1.java │ ├── HtmlMovies2.java │ ├── JSForm.java │ ├── MovieServlet.java │ ├── PdfServlet.java │ ├── ShowData.java │ ├── SubmitForm.java │ ├── XFDFServlet.java │ └── XmlHandler.java ├── chapter10 │ ├── Barcodes.java │ ├── ClippingPath.java │ ├── CompressAwt.java │ ├── CompressImage.java │ ├── DeviceColor.java │ ├── ImageMask.java │ ├── ImageTypes.java │ ├── PagedImages.java │ ├── RawImage.java │ ├── SeparationColor.java │ ├── ShadingPatternColor.java │ ├── TemplateClip.java │ ├── TilingPatternColor.java │ ├── Transparency1.java │ ├── Transparency2.java │ ├── TransparentAwt.java │ ├── TransparentImage.java │ └── TransparentOverlay.java ├── chapter11 │ ├── CJKExample.java │ ├── Diacritics1.java │ ├── Diacritics2.java │ ├── EncodingExample.java │ ├── EncodingNames.java │ ├── ExtraCharSpace.java │ ├── FontFactoryExample.java │ ├── FontFileAndSizes.java │ ├── FontSelectionExample.java │ ├── FontTypes.java │ ├── Ligatures1.java │ ├── Ligatures2.java │ ├── Monospace.java │ ├── Peace.java │ ├── RightToLeftExample.java │ ├── SayPeace.java │ ├── TTCExample.java │ ├── Type3Example.java │ ├── UnicodeExample.java │ ├── VerticalTextExample1.java │ └── VerticalTextExample2.java └── chapter12 │ ├── EncryptWithCertificate.java │ ├── EncryptionPdf.java │ ├── HelloWorldCompression.java │ ├── MetadataPdf.java │ ├── MetadataXmp.java │ ├── SignWithBC.java │ ├── SignatureExternalHash.java │ ├── SignatureField.java │ ├── Signatures.java │ └── TimestampOCSP.java └── part4 ├── chapter13 ├── AddJavaScriptToForm.java ├── AppendMode.java ├── Bookmarks2NamedDestinations.java ├── CropPages.java ├── FixBrokenForm.java ├── InspectForm.java ├── PageLabelExample.java ├── PageLayoutExample.java ├── PdfXPdfA.java ├── PrintPreferencesExample.java ├── RemoveLaunchActions.java ├── ReplaceURL.java ├── RotatePages.java └── ViewerPreferencesExample.java ├── chapter14 ├── DirectorCharts.java ├── GetContentStream.java ├── Graphics2DFonts.java ├── GraphicsStateOperators.java ├── PathConstructionAndPainting.java ├── PearExample.java ├── PearToPdf.java ├── Text1ToPdf1.java ├── Text1ToPdf2.java ├── Text2ToPdf1.java ├── Text2ToPdf2.java ├── Text2ToPdf3.java ├── Text3ToPdf.java ├── Text4ToPdf.java ├── TextExample1.java ├── TextExample2.java ├── TextExample3.java ├── TextExample4.java ├── TextMethods.java ├── TextStateOperators.java ├── TransformationMatrix1.java ├── TransformationMatrix2.java └── TransformationMatrix3.java ├── chapter15 ├── ContentParser.java ├── ExtractImages.java ├── ExtractPageContent.java ├── ExtractPageContentArea.java ├── ExtractPageContentSorted1.java ├── ExtractPageContentSorted2.java ├── InspectPageContent.java ├── LayerMembershipExample1.java ├── LayerMembershipExample2.java ├── MyImageRenderListener.java ├── MyTextRenderListener.java ├── ObjectData.java ├── OptionalContentActionExample.java ├── OptionalContentExample.java ├── ParseTaggedPdf.java ├── ParsingHelloWorld.java ├── PeekABoo.java ├── ReadOutLoud.java ├── ShowTextMargins.java ├── StructureParser.java ├── StructuredContent.java ├── SvgLayers.java └── SvgToPdf.java └── chapter16 ├── EmbedFontPostFacto.java ├── FestivalCalendar1.java ├── FestivalCalendar2.java ├── FileAttachmentEvent.java ├── KubrickBox.java ├── KubrickCollection.java ├── KubrickDocumentary.java ├── KubrickDvds.java ├── KubrickMovies.java ├── ListUsedFonts.java ├── LocalDestinationEvent.java ├── MovieAnnotation.java ├── Pdf3D.java ├── PdfActionEvent.java ├── ResizeImage.java └── SpecialId.java /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set the default behavior, in case people don't have core.autocrlf set. 2 | * text=auto 3 | 4 | # Explicitly declare text files you want to always be normalized and converted 5 | # to native line endings on checkout. 6 | *.afm text 7 | *.cmap text 8 | *.crt text 9 | *.cs text 10 | *.html text 11 | *.java text ident 12 | *.lng text 13 | *.md text 14 | *.pom text 15 | *.properties text 16 | *.txt text 17 | *.xfdf text 18 | *.xml text 19 | 20 | # Declare files that will always have CRLF line endings on checkout. 21 | *.bat text eol=crlf 22 | *.csproj text eol=crlf 23 | *.sln text eol=crlf 24 | 25 | # Denote all files that are truly binary and should not be modified. 26 | *.bmp binary 27 | *.cmp binary 28 | *.dib binary 29 | *.gif binary 30 | *.j2k binary 31 | *.jb2 binary 32 | *.jp2 binary 33 | *.jpg binary 34 | *.key binary 35 | *.otf binary 36 | *.pdf binary 37 | *.pfb binary 38 | *.png binary 39 | *.tif binary 40 | *.tiff binary 41 | *.ttc binary 42 | *.ttf binary 43 | *.wmf binary 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [iText 5 Java Samples: book](http://developers.itextpdf.com/content/itext-5-examples/itext-action-second-edition) 2 | --- 3 | These are the examples written in the context of the book "iText in Action - Second Editon" (2010) -------------------------------------------------------------------------------- /WebContent/embedded.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | -------------------------------------------------------------------------------- /WebContent/fdf_form.html: -------------------------------------------------------------------------------- 1 | 2 | Form to create an FDF form 3 | 4 |
5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | 27 |
name
login
password
reason
24 | 25 |
28 |
29 | 30 | -------------------------------------------------------------------------------- /WebContent/helloworld.jsp: -------------------------------------------------------------------------------- 1 | <%@ 2 | page import="java.io.*, com.itextpdf.text.*, com.itextpdf.text.pdf.*" 3 | %><% 4 | response.setContentType( "application/pdf" ); 5 | 6 | // step 1: 7 | Document document = new Document(); 8 | // step 2: 9 | ByteArrayOutputStream buffer = new ByteArrayOutputStream(); 10 | PdfWriter.getInstance( document, buffer ); 11 | // step 3: 12 | document.open(); 13 | // step 4: 14 | document.add(new Paragraph("Hello World")); 15 | // step 5: 16 | document.close(); 17 | // we output the writer as bytes to the response output 18 | DataOutput output = new DataOutputStream( response.getOutputStream() ); 19 | byte[] bytes = buffer.toByteArray(); 20 | response.setContentLength(bytes.length); 21 | for( int i = 0; i < bytes.length; i++ ) { output.writeByte( bytes[i] ); } 22 | %> -------------------------------------------------------------------------------- /WebContent/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | iText in Action 2E: web applications 4 | 5 | 6 |
7 |
8 | 9 |
10 |
11 |
12 |
13 | 14 |
15 | 16 | -------------------------------------------------------------------------------- /WebContent/javascript.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Talk to HTML test 4 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 |
Name:Login:
38 |
39 | 41 | 42 | -------------------------------------------------------------------------------- /WebContent/javascript.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/WebContent/javascript.pdf -------------------------------------------------------------------------------- /WebContent/submit_me.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/WebContent/submit_me.pdf -------------------------------------------------------------------------------- /WebContent/subscribe.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/WebContent/subscribe.pdf -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /resources/calendar/01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/calendar/01.jpg -------------------------------------------------------------------------------- /resources/calendar/02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/calendar/02.jpg -------------------------------------------------------------------------------- /resources/calendar/03.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/calendar/03.jpg -------------------------------------------------------------------------------- /resources/calendar/04.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/calendar/04.jpg -------------------------------------------------------------------------------- /resources/calendar/05.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/calendar/05.jpg -------------------------------------------------------------------------------- /resources/calendar/06.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/calendar/06.jpg -------------------------------------------------------------------------------- /resources/calendar/07.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/calendar/07.jpg -------------------------------------------------------------------------------- /resources/calendar/08.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/calendar/08.jpg -------------------------------------------------------------------------------- /resources/calendar/09.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/calendar/09.jpg -------------------------------------------------------------------------------- /resources/calendar/10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/calendar/10.jpg -------------------------------------------------------------------------------- /resources/calendar/11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/calendar/11.jpg -------------------------------------------------------------------------------- /resources/calendar/12.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/calendar/12.jpg -------------------------------------------------------------------------------- /resources/calendar/2010.txt: -------------------------------------------------------------------------------- 1 | 0101 New Year 2 | 0404 Easter 3 | 0405 Easter Monday 4 | 0704 4th of July 5 | 1225 Christmas -------------------------------------------------------------------------------- /resources/calendar/2011.txt: -------------------------------------------------------------------------------- 1 | 0101 New Year 2 | 0424 Easter 3 | 0425 Easter Monday 4 | 0704 4th of July 5 | 1225 Christmas -------------------------------------------------------------------------------- /resources/calendar/2012.txt: -------------------------------------------------------------------------------- 1 | 0101 New Year 2 | 0408 Easter 3 | 0409 Easter Monday 4 | 0704 4th of July 5 | 1225 Christmas -------------------------------------------------------------------------------- /resources/calendar/content.txt: -------------------------------------------------------------------------------- 1 | 01.jpg Brass Buddha 2 | 02.jpg Heart Chairs at Bishop St. Cafe 3 | 03.jpg Pipes and Chains 4 | 04.jpg Phone Booths 5 | 05.jpg Kalakaua Intersection 6 | 06.jpg Kayaker on the Ala Wai 7 | 07.jpg Honolulu from Makiki Heights 8 | 08.jpg Orange Navel 9 | 09.jpg Escalators at Big Kahuna 10 | 10.jpg Moiliili Cityscape 11 | 11.jpg KUKU 12 | 12.jpg Fireworks -------------------------------------------------------------------------------- /resources/encryption/.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/encryption/.keystore -------------------------------------------------------------------------------- /resources/encryption/foobar.cer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/encryption/foobar.cer -------------------------------------------------------------------------------- /resources/fonts/Puritan2.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/fonts/Puritan2.otf -------------------------------------------------------------------------------- /resources/fonts/abserif4_5.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/fonts/abserif4_5.ttf -------------------------------------------------------------------------------- /resources/fonts/cmr10.pfb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/fonts/cmr10.pfb -------------------------------------------------------------------------------- /resources/fonts/cmr10.pfm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/fonts/cmr10.pfm -------------------------------------------------------------------------------- /resources/fonts/damase.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/fonts/damase.ttf -------------------------------------------------------------------------------- /resources/fonts/fsex2p00_public.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/fonts/fsex2p00_public.ttf -------------------------------------------------------------------------------- /resources/fonts/wds011402.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/fonts/wds011402.ttf -------------------------------------------------------------------------------- /resources/img/1t3xt.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/img/1t3xt.gif -------------------------------------------------------------------------------- /resources/img/amb.jb2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/img/amb.jb2 -------------------------------------------------------------------------------- /resources/img/animated_fox_dog.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/img/animated_fox_dog.gif -------------------------------------------------------------------------------- /resources/img/bruno.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/img/bruno.jpg -------------------------------------------------------------------------------- /resources/img/bruno_ingeborg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/img/bruno_ingeborg.jpg -------------------------------------------------------------------------------- /resources/img/butterfly.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/img/butterfly.bmp -------------------------------------------------------------------------------- /resources/img/butterfly.wmf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/img/butterfly.wmf -------------------------------------------------------------------------------- /resources/img/close.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/img/close.bmp -------------------------------------------------------------------------------- /resources/img/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/img/close.png -------------------------------------------------------------------------------- /resources/img/foxdog.mpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/img/foxdog.mpg -------------------------------------------------------------------------------- /resources/img/hitchcock.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/img/hitchcock.gif -------------------------------------------------------------------------------- /resources/img/hitchcock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/img/hitchcock.png -------------------------------------------------------------------------------- /resources/img/iia2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/img/iia2.jpg -------------------------------------------------------------------------------- /resources/img/info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/img/info.png -------------------------------------------------------------------------------- /resources/img/kubrick.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/img/kubrick.jpg -------------------------------------------------------------------------------- /resources/img/kubrick_box.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/img/kubrick_box.jpg -------------------------------------------------------------------------------- /resources/img/loa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/img/loa.jpg -------------------------------------------------------------------------------- /resources/img/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/img/logo.gif -------------------------------------------------------------------------------- /resources/img/map.jp2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/img/map.jp2 -------------------------------------------------------------------------------- /resources/img/marbles.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/img/marbles.tif -------------------------------------------------------------------------------- /resources/img/movie.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/img/movie.gif -------------------------------------------------------------------------------- /resources/img/sRGB.profile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/img/sRGB.profile -------------------------------------------------------------------------------- /resources/img/teapot.u3d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/img/teapot.u3d -------------------------------------------------------------------------------- /resources/js/buttons.js: -------------------------------------------------------------------------------- 1 | function showButtonState() { 2 | app.alert('Checkboxes:' 3 | + ' English: ' + this.getField('English').value 4 | + ' German: ' + this.getField('German').value 5 | + ' French: ' + this.getField('French').value 6 | + ' Spanish: ' + this.getField('Spanish').value 7 | + ' Dutch: ' + this.getField('Dutch').value 8 | + '; Radioboxes: ' + this.getField('language').value); 9 | } -------------------------------------------------------------------------------- /resources/js/calculator.js: -------------------------------------------------------------------------------- 1 | var previous = 0; 2 | var current = 0; 3 | var operation = ''; 4 | 5 | function showCurrent() { 6 | this.getField('result').value = current; 7 | } 8 | function showMove(s) { 9 | this.getField('move').value = s; 10 | } 11 | function augment(digit) { 12 | current = current * 10 + digit; 13 | showCurrent(); 14 | } 15 | function register(op) { 16 | previous = current; 17 | current = 0; 18 | operation = op; 19 | showCurrent(); 20 | } 21 | function calculateResult() { 22 | if (operation == '+') 23 | current = previous + current; 24 | else if (operation == '-') 25 | current = previous - current; 26 | else if (operation == '*') 27 | current = previous * current; 28 | else if (operation == '/') 29 | current = previous / current; 30 | showCurrent(); 31 | } 32 | function reset(all) { 33 | current = 0; 34 | if(all) previous = 0; 35 | showCurrent(); 36 | } 37 | showCurrent(); -------------------------------------------------------------------------------- /resources/js/extra.js: -------------------------------------------------------------------------------- 1 | function setReadOnly(readonly) { 2 | var partner = this.getField('partner'); 3 | if(readonly) { 4 | partner.value = ''; 5 | } 6 | partner.readonly = readonly; 7 | } 8 | function validate() { 9 | var married = this.getField('married'); 10 | var partner = this.getField('partner'); 11 | if (married.value == 'yes' && partner.value == '') { 12 | app.alert('please enter the name of your partner'); 13 | } 14 | else { 15 | this.submitForm({ 16 | cURL:"http://itextpdf.com:8080/book/request", 17 | cSubmitAs: "HTML" 18 | }); 19 | } 20 | } -------------------------------------------------------------------------------- /resources/js/find_director.js: -------------------------------------------------------------------------------- 1 | function findDirector(name) { 2 | if (search.available) { 3 | search.query(name, "ActiveDoc"); 4 | } 5 | else { 6 | app.alert("The Search plug-in isn't installed."); 7 | } 8 | } -------------------------------------------------------------------------------- /resources/js/post_from_html.js: -------------------------------------------------------------------------------- 1 | this.disclosed = true; 2 | if (this.external && this.hostContainer) { 3 | function onMessageFunc( stringArray ) { 4 | var name = this.myDoc.getField("personal.name"); 5 | var login = this.myDoc.getField("personal.loginname"); 6 | try{ 7 | name.value = stringArray[0]; 8 | login.value = stringArray[1]; 9 | } 10 | catch(e){ 11 | onErrorFunc(e); 12 | } 13 | } 14 | function onErrorFunc( e ) { 15 | console.show(); 16 | console.println(e.toString()); 17 | } 18 | try { 19 | if(!this.hostContainer.messageHandler); 20 | this.hostContainer.messageHandler = new Object(); 21 | this.hostContainer.messageHandler.myDoc = this; 22 | this.hostContainer.messageHandler.onMessage = onMessageFunc; 23 | this.hostContainer.messageHandler.onError = onErrorFunc; 24 | this.hostContainer.messageHandler.onDisclose = function(){return true;}; 25 | } 26 | catch(e){ 27 | onErrorFunc(e); 28 | } 29 | } -------------------------------------------------------------------------------- /resources/js/post_to_html.js: -------------------------------------------------------------------------------- 1 | if(this.hostContainer) { 2 | var names = new Array(); 3 | names[0] = this.getField("personal.name").value.toString(); 4 | names[1] = this.getField("personal.loginname").value.toString(); 5 | try{ 6 | this.hostContainer.postMessage(names); 7 | } 8 | catch(e){ 9 | app.alert(e.message); 10 | } 11 | } -------------------------------------------------------------------------------- /resources/js/print_page.js: -------------------------------------------------------------------------------- 1 | function printCurrentPage() { 2 | var pp = this.getPrintParams(); 3 | pp.firstPage = this.pageNum; 4 | pp.lastPage = pp.firstPage; 5 | this.print(pp); 6 | } -------------------------------------------------------------------------------- /resources/js/show_date.js: -------------------------------------------------------------------------------- 1 | function showDate(txt) { 2 | this.getField("date").value = "This is the festival program for " + txt; 3 | } -------------------------------------------------------------------------------- /resources/js/viewer_version.js: -------------------------------------------------------------------------------- 1 | console.clear(); 2 | console.show(); 3 | console.println("Hello"); 4 | console.println("You are using: " + app.viewerType); 5 | console.println("The version of " + app.viewerType + " is: " + app.viewerVersion); -------------------------------------------------------------------------------- /resources/jsp/helloworld.jsp: -------------------------------------------------------------------------------- 1 | <%@ 2 | page import="java.io.*, com.itextpdf.text.*, com.itextpdf.text.pdf.*" 3 | %><% 4 | response.setContentType( "application/pdf" ); 5 | 6 | // step 1: 7 | Document document = new Document(); 8 | // step 2: 9 | ByteArrayOutputStream buffer = new ByteArrayOutputStream(); 10 | PdfWriter.getInstance( document, buffer ); 11 | // step 3: 12 | document.open(); 13 | // step 4: 14 | document.add(new Paragraph("Hello World")); 15 | // step 5: 16 | document.close(); 17 | // we output the writer as bytes to the response output 18 | DataOutput output = new DataOutputStream( response.getOutputStream() ); 19 | byte[] bytes = buffer.toByteArray(); 20 | response.setContentLength(bytes.length); 21 | for( int i = 0; i < bytes.length; i++ ) { output.writeByte( bytes[i] ); } 22 | %> -------------------------------------------------------------------------------- /resources/pdfs/broken_form.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/pdfs/broken_form.pdf -------------------------------------------------------------------------------- /resources/pdfs/datasheet.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/pdfs/datasheet.odt -------------------------------------------------------------------------------- /resources/pdfs/datasheet.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/pdfs/datasheet.pdf -------------------------------------------------------------------------------- /resources/pdfs/hero.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/pdfs/hero.pdf -------------------------------------------------------------------------------- /resources/pdfs/logo.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/pdfs/logo.pdf -------------------------------------------------------------------------------- /resources/pdfs/movie_overview.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/pdfs/movie_overview.odt -------------------------------------------------------------------------------- /resources/pdfs/movie_overview.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/pdfs/movie_overview.pdf -------------------------------------------------------------------------------- /resources/pdfs/preface.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/pdfs/preface.pdf -------------------------------------------------------------------------------- /resources/pdfs/xfa_enabled.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/pdfs/xfa_enabled.pdf -------------------------------------------------------------------------------- /resources/pdfs/xfa_movie.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/pdfs/xfa_movie.pdf -------------------------------------------------------------------------------- /resources/pdfs/xfa_movies.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/pdfs/xfa_movies.pdf -------------------------------------------------------------------------------- /resources/posters/0033467.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0033467.jpg -------------------------------------------------------------------------------- /resources/posters/0042876.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0042876.jpg -------------------------------------------------------------------------------- /resources/posters/0044741.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0044741.jpg -------------------------------------------------------------------------------- /resources/posters/0047478.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0047478.jpg -------------------------------------------------------------------------------- /resources/posters/0048254.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0048254.jpg -------------------------------------------------------------------------------- /resources/posters/0049406.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0049406.jpg -------------------------------------------------------------------------------- /resources/posters/0050825.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0050825.jpg -------------------------------------------------------------------------------- /resources/posters/0051808.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0051808.jpg -------------------------------------------------------------------------------- /resources/posters/0054331.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0054331.jpg -------------------------------------------------------------------------------- /resources/posters/0055630.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0055630.jpg -------------------------------------------------------------------------------- /resources/posters/0056172.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0056172.jpg -------------------------------------------------------------------------------- /resources/posters/0056193.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0056193.jpg -------------------------------------------------------------------------------- /resources/posters/0056443.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0056443.jpg -------------------------------------------------------------------------------- /resources/posters/0057012.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0057012.jpg -------------------------------------------------------------------------------- /resources/posters/0062622.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0062622.jpg -------------------------------------------------------------------------------- /resources/posters/0066921.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0066921.jpg -------------------------------------------------------------------------------- /resources/posters/0072684.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0072684.jpg -------------------------------------------------------------------------------- /resources/posters/0081505.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0081505.jpg -------------------------------------------------------------------------------- /resources/posters/0088128.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0088128.jpg -------------------------------------------------------------------------------- /resources/posters/0088247.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0088247.jpg -------------------------------------------------------------------------------- /resources/posters/0088847.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0088847.jpg -------------------------------------------------------------------------------- /resources/posters/0090060.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0090060.jpg -------------------------------------------------------------------------------- /resources/posters/0090563.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0090563.jpg -------------------------------------------------------------------------------- /resources/posters/0090583.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0090583.jpg -------------------------------------------------------------------------------- /resources/posters/0091288.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0091288.jpg -------------------------------------------------------------------------------- /resources/posters/0091480.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0091480.jpg -------------------------------------------------------------------------------- /resources/posters/0091790.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0091790.jpg -------------------------------------------------------------------------------- /resources/posters/0092005.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0092005.jpg -------------------------------------------------------------------------------- /resources/posters/0093058.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0093058.jpg -------------------------------------------------------------------------------- /resources/posters/0093206.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0093206.jpg -------------------------------------------------------------------------------- /resources/posters/0094006.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0094006.jpg -------------------------------------------------------------------------------- /resources/posters/0094625.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0094625.jpg -------------------------------------------------------------------------------- /resources/posters/0095765.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0095765.jpg -------------------------------------------------------------------------------- /resources/posters/0095953.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0095953.jpg -------------------------------------------------------------------------------- /resources/posters/0096018.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0096018.jpg -------------------------------------------------------------------------------- /resources/posters/0097576.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0097576.jpg -------------------------------------------------------------------------------- /resources/posters/0098635.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0098635.jpg -------------------------------------------------------------------------------- /resources/posters/0099902.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0099902.jpg -------------------------------------------------------------------------------- /resources/posters/0100436.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0100436.jpg -------------------------------------------------------------------------------- /resources/posters/0100935.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0100935.jpg -------------------------------------------------------------------------------- /resources/posters/0101700.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0101700.jpg -------------------------------------------------------------------------------- /resources/posters/0102494.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0102494.jpg -------------------------------------------------------------------------------- /resources/posters/0103064.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0103064.jpg -------------------------------------------------------------------------------- /resources/posters/0104029.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0104029.jpg -------------------------------------------------------------------------------- /resources/posters/0105652.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0105652.jpg -------------------------------------------------------------------------------- /resources/posters/0107156.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0107156.jpg -------------------------------------------------------------------------------- /resources/posters/0108399.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0108399.jpg -------------------------------------------------------------------------------- /resources/posters/0111797.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0111797.jpg -------------------------------------------------------------------------------- /resources/posters/0113568.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0113568.jpg -------------------------------------------------------------------------------- /resources/posters/0113627.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0113627.jpg -------------------------------------------------------------------------------- /resources/posters/0119349.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0119349.jpg -------------------------------------------------------------------------------- /resources/posters/0120601.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0120601.jpg -------------------------------------------------------------------------------- /resources/posters/0120663.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0120663.jpg -------------------------------------------------------------------------------- /resources/posters/0120679.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0120679.jpg -------------------------------------------------------------------------------- /resources/posters/0120903.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0120903.jpg -------------------------------------------------------------------------------- /resources/posters/0137523.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0137523.jpg -------------------------------------------------------------------------------- /resources/posters/0145487.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0145487.jpg -------------------------------------------------------------------------------- /resources/posters/0154420.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0154420.jpg -------------------------------------------------------------------------------- /resources/posters/0164711.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0164711.jpg -------------------------------------------------------------------------------- /resources/posters/0169102.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0169102.jpg -------------------------------------------------------------------------------- /resources/posters/0180093.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0180093.jpg -------------------------------------------------------------------------------- /resources/posters/0181852.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0181852.jpg -------------------------------------------------------------------------------- /resources/posters/0190332.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0190332.jpg -------------------------------------------------------------------------------- /resources/posters/0201265.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0201265.jpg -------------------------------------------------------------------------------- /resources/posters/0203515.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0203515.jpg -------------------------------------------------------------------------------- /resources/posters/0210727.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0210727.jpg -------------------------------------------------------------------------------- /resources/posters/0211915.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0211915.jpg -------------------------------------------------------------------------------- /resources/posters/0235060.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0235060.jpg -------------------------------------------------------------------------------- /resources/posters/0245429.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0245429.jpg -------------------------------------------------------------------------------- /resources/posters/0245712.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0245712.jpg -------------------------------------------------------------------------------- /resources/posters/0246578.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0246578.jpg -------------------------------------------------------------------------------- /resources/posters/0247586.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0247586.jpg -------------------------------------------------------------------------------- /resources/posters/0255589.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0255589.jpg -------------------------------------------------------------------------------- /resources/posters/0256009.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0256009.jpg -------------------------------------------------------------------------------- /resources/posters/0259393.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0259393.jpg -------------------------------------------------------------------------------- /resources/posters/0266308.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0266308.jpg -------------------------------------------------------------------------------- /resources/posters/0268126.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0268126.jpg -------------------------------------------------------------------------------- /resources/posters/0269217.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0269217.jpg -------------------------------------------------------------------------------- /resources/posters/0270288.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0270288.jpg -------------------------------------------------------------------------------- /resources/posters/0278736.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0278736.jpg -------------------------------------------------------------------------------- /resources/posters/0279064.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0279064.jpg -------------------------------------------------------------------------------- /resources/posters/0283509.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0283509.jpg -------------------------------------------------------------------------------- /resources/posters/0290334.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0290334.jpg -------------------------------------------------------------------------------- /resources/posters/0299977.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0299977.jpg -------------------------------------------------------------------------------- /resources/posters/0301357.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0301357.jpg -------------------------------------------------------------------------------- /resources/posters/0311648.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0311648.jpg -------------------------------------------------------------------------------- /resources/posters/0316654.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0316654.jpg -------------------------------------------------------------------------------- /resources/posters/0320042.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0320042.jpg -------------------------------------------------------------------------------- /resources/posters/0323872.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0323872.jpg -------------------------------------------------------------------------------- /resources/posters/0338013.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0338013.jpg -------------------------------------------------------------------------------- /resources/posters/0339230.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0339230.jpg -------------------------------------------------------------------------------- /resources/posters/0344510.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0344510.jpg -------------------------------------------------------------------------------- /resources/posters/0347149.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0347149.jpg -------------------------------------------------------------------------------- /resources/posters/0348150.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0348150.jpg -------------------------------------------------------------------------------- /resources/posters/0362496.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0362496.jpg -------------------------------------------------------------------------------- /resources/posters/0368619.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0368619.jpg -------------------------------------------------------------------------------- /resources/posters/0372782.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0372782.jpg -------------------------------------------------------------------------------- /resources/posters/0372784.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0372784.jpg -------------------------------------------------------------------------------- /resources/posters/0374546.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0374546.jpg -------------------------------------------------------------------------------- /resources/posters/0376007.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0376007.jpg -------------------------------------------------------------------------------- /resources/posters/0376994.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0376994.jpg -------------------------------------------------------------------------------- /resources/posters/0378284.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0378284.jpg -------------------------------------------------------------------------------- /resources/posters/0385004.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0385004.jpg -------------------------------------------------------------------------------- /resources/posters/0388795.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0388795.jpg -------------------------------------------------------------------------------- /resources/posters/0402595.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0402595.jpg -------------------------------------------------------------------------------- /resources/posters/0413300.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0413300.jpg -------------------------------------------------------------------------------- /resources/posters/0418832.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0418832.jpg -------------------------------------------------------------------------------- /resources/posters/0419073.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0419073.jpg -------------------------------------------------------------------------------- /resources/posters/0423866.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0423866.jpg -------------------------------------------------------------------------------- /resources/posters/0445691.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0445691.jpg -------------------------------------------------------------------------------- /resources/posters/0449059.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0449059.jpg -------------------------------------------------------------------------------- /resources/posters/0452623.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0452623.jpg -------------------------------------------------------------------------------- /resources/posters/0457430.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0457430.jpg -------------------------------------------------------------------------------- /resources/posters/0468569.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0468569.jpg -------------------------------------------------------------------------------- /resources/posters/0473444.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0473444.jpg -------------------------------------------------------------------------------- /resources/posters/0482901.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0482901.jpg -------------------------------------------------------------------------------- /resources/posters/0809931.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0809931.jpg -------------------------------------------------------------------------------- /resources/posters/0813547.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0813547.jpg -------------------------------------------------------------------------------- /resources/posters/0857355.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0857355.jpg -------------------------------------------------------------------------------- /resources/posters/0948530.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/posters/0948530.jpg -------------------------------------------------------------------------------- /resources/scripts/filmfestival_hsqldb.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE FILM_MOVIETITLE IF EXISTS; 2 | CREATE TABLE FILM_MOVIETITLE(ID INTEGER NOT NULL PRIMARY KEY,TITLE VARCHAR(120) NOT NULL,ORIGINAL_TITLE VARCHAR(120) DEFAULT NULL,IMDB VARCHAR(7) NOT NULL,YEAR INTEGER NOT NULL,DURATION INTEGER NOT NULL); 3 | DROP TABLE FILM_DIRECTOR IF EXISTS; 4 | CREATE TABLE FILM_DIRECTOR(ID INTEGER NOT NULL PRIMARY KEY,NAME VARCHAR(60) NOT NULL,GIVEN_NAME VARCHAR(60) NOT NULL); 5 | DROP TABLE FILM_MOVIE_DIRECTOR IF EXISTS; 6 | CREATE TABLE FILM_MOVIE_DIRECTOR(FILM_ID INTEGER NOT NULL,DIRECTOR_ID INTEGER NOT NULL); 7 | DROP TABLE FILM_COUNTRY IF EXISTS; 8 | CREATE TABLE FILM_COUNTRY(ID CHAR(2) NOT NULL PRIMARY KEY,COUNTRY VARCHAR(60) NOT NULL); 9 | DROP TABLE FILM_MOVIE_COUNTRY IF EXISTS; 10 | CREATE TABLE FILM_MOVIE_COUNTRY(FILM_ID INTEGER NOT NULL,COUNTRY_ID CHAR(2) NOT NULL); 11 | DROP TABLE FESTIVAL_CATEGORY IF EXISTS; 12 | CREATE TABLE FESTIVAL_CATEGORY(ID INTEGER NOT NULL PRIMARY KEY,NAME VARCHAR(40) NOT NULL,KEYWORD CHAR(4) NOT NULL,PARENT INTEGER NOT NULL,COLOR CHAR(6) NOT NULL); 13 | DROP TABLE FESTIVAL_ENTRY IF EXISTS; 14 | CREATE TABLE FESTIVAL_ENTRY(FILM_ID INTEGER NOT NULL,YEAR INTEGER NOT NULL,CATEGORY_ID INTEGER NOT NULL,PRIMARY KEY(FILM_ID,YEAR)); 15 | DROP TABLE FESTIVAL_SCREENING IF EXISTS; 16 | CREATE TABLE FESTIVAL_SCREENING(ID INTEGER NOT NULL PRIMARY KEY,DAY DATE NOT NULL,TIME TIME NOT NULL,LOCATION VARCHAR(4) NOT NULL,FILM_ID INTEGER NOT NULL,PRESS INTEGER NOT NULL); -------------------------------------------------------------------------------- /resources/scripts/filmfestival_mysql.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS `festival_category` ( 2 | `id` int(11) NOT NULL AUTO_INCREMENT, 3 | `name` varchar(40) COLLATE utf8_bin NOT NULL, 4 | `keyword` char(4) COLLATE utf8_bin NOT NULL, 5 | `parent` int(11) NOT NULL, 6 | `color` char(6) COLLATE utf8_bin NOT NULL, 7 | PRIMARY KEY (`id`) 8 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; 9 | 10 | CREATE TABLE IF NOT EXISTS `festival_entry` ( 11 | `film_id` int(11) NOT NULL, 12 | `year` smallint(4) NOT NULL DEFAULT '2011', 13 | `category_id` tinyint(1) NOT NULL, 14 | PRIMARY KEY (`film_id`,`year`) 15 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; 16 | 17 | CREATE TABLE IF NOT EXISTS `festival_screening` ( 18 | `id` int(11) NOT NULL AUTO_INCREMENT, 19 | `day` date NOT NULL, 20 | `time` time NOT NULL, 21 | `location` varchar(4) COLLATE utf8_bin NOT NULL, 22 | `film_id` int(11) NOT NULL DEFAULT '0', 23 | `press` tinyint(1) NOT NULL, 24 | PRIMARY KEY (`id`) 25 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; 26 | 27 | CREATE TABLE IF NOT EXISTS `film_country` ( 28 | `id` char(2) COLLATE utf8_bin NOT NULL, 29 | `country` varchar(60) COLLATE utf8_bin NOT NULL, 30 | PRIMARY KEY (`id`) 31 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; 32 | 33 | CREATE TABLE IF NOT EXISTS `film_director` ( 34 | `id` int(11) NOT NULL AUTO_INCREMENT, 35 | `name` varchar(60) COLLATE utf8_bin NOT NULL, 36 | `given_name` varchar(60) COLLATE utf8_bin NOT NULL, 37 | PRIMARY KEY (`id`) 38 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; 39 | 40 | CREATE TABLE IF NOT EXISTS `film_movietitle` ( 41 | `id` int(11) NOT NULL AUTO_INCREMENT, 42 | `title` varchar(120) COLLATE utf8_bin NOT NULL, 43 | `original_title` varchar(120) COLLATE utf8_bin DEFAULT NULL, 44 | `imdb` varchar(7) COLLATE utf8_bin NOT NULL, 45 | `year` int(11) NOT NULL, 46 | `duration` int(11) NOT NULL, 47 | PRIMARY KEY (`id`) 48 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; 49 | 50 | CREATE TABLE IF NOT EXISTS `film_movie_country` ( 51 | `film_id` int(11) NOT NULL, 52 | `country_id` char(2) COLLATE utf8_bin NOT NULL 53 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; 54 | 55 | CREATE TABLE IF NOT EXISTS `film_movie_director` ( 56 | `film_id` int(11) NOT NULL, 57 | `director_id` int(11) NOT NULL 58 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; 59 | -------------------------------------------------------------------------------- /resources/swf/FestivalCalendar1.mxml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 16 | 17 | 19 | 20 | 21 | 22 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /resources/swf/FestivalCalendar1.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/swf/FestivalCalendar1.swf -------------------------------------------------------------------------------- /resources/swf/FestivalCalendar2.mxml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /resources/swf/FestivalCalendar2.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/swf/FestivalCalendar2.swf -------------------------------------------------------------------------------- /resources/txt/test.txt: -------------------------------------------------------------------------------- 1 | This is a plain text file -------------------------------------------------------------------------------- /resources/xml/foobarrues.svg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itext/i5js-book/d5a376b0dac8ffbee5ba41f77e51363f03a9c106/resources/xml/foobarrues.svg -------------------------------------------------------------------------------- /resources/xml/movies.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /resources/xml/say_peace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Say Peace in all languages! 4 | The people of the world prefer peace to war and they deserve to have it. 5 | Bombs are not needed to solve international problems when they can be solved 6 | just as well with respect and communication. The Internet Internationalization 7 | (I18N) community, which values diversity and human life everywhere, offers 8 | "Peace" in many languages as a small step in this direction. 9 | 10 | 11 | أنطقوا سلام بكل 12 | اللغات! 13 | كل شععوب العالم تفصل السلام علي الحرب وكلها تستحق أن تنعم بع. 14 | إن القنابل لا تحل مشاكل العالم ويتم تحقيق ذلك فقط بالاحترام 15 | والتواصل. 16 | مجموعة تدويل الإنترنت (I18N) ، والتي تأخذ بعين 17 | التقدير الاختلافات الثقافية والعادات الحياتية 18 | بين الشعوب، فإنها تقدم "السلام" بلغات كثيرة، كخطوة متواضعة في هذا 19 | الاتجاه. 20 | 21 | 22 | אמרו "שלום" בכל השפות! אנשי העולם מעדיפים את השלום על-פני המלחמה והם 23 | ראויים לו. אין צורך בפצצות כדי לפתור בעיות בין-לאומיות, רק בכבוד 24 | ובהידברות. קהילת בינאום האינטרנט (I18N), אשר מוקירה רב-גוניות וחיי אדם 25 | בכל מקום, מושיטה יד ל"שלום" בשפות רבות כצעד קטן בכיוון זה. 26 | 27 | -------------------------------------------------------------------------------- /src/com/lowagie/database/CreateHsqldbTables.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package com.lowagie.database; 9 | 10 | import java.io.BufferedReader; 11 | import java.io.FileReader; 12 | import java.io.IOException; 13 | import java.io.UnsupportedEncodingException; 14 | import java.sql.SQLException; 15 | 16 | 17 | /** 18 | * Creates the hsqldatabase using SQL scripts containing 19 | * CREATE statements with the table definitions, and 20 | * INSERT statements with the data. 21 | */ 22 | public class CreateHsqldbTables { 23 | 24 | /** 25 | * Imports a number of SQL scripts into an HSQLDB database. 26 | * @param args no arguments needed 27 | * @throws SQLException 28 | * @throws IOException 29 | * @throws UnsupportedEncodingException 30 | */ 31 | public static void main(String[] args) 32 | throws SQLException, UnsupportedEncodingException, IOException { 33 | DatabaseConnection conn = new HsqldbConnection("filmfestival"); 34 | BufferedReader in; 35 | String line; 36 | conn.update("SET IGNORECASE TRUE"); 37 | in = new BufferedReader( 38 | new FileReader("resources/scripts/filmfestival_hsqldb.sql")); 39 | while( (line = in.readLine()) != null) { 40 | conn.update(line); 41 | } 42 | in = new BufferedReader( 43 | new FileReader("resources/scripts/filmfestival.sql")); 44 | while( (line = in.readLine()) != null) { 45 | conn.update(line); 46 | } 47 | conn.close(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/com/lowagie/database/DatabaseConnection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package com.lowagie.database; 9 | 10 | import java.sql.Connection; 11 | import java.sql.PreparedStatement; 12 | import java.sql.SQLException; 13 | import java.sql.Statement; 14 | 15 | /** 16 | * This is a helper class to access the database 17 | * that comes with the book samples. 18 | */ 19 | 20 | public abstract class DatabaseConnection { 21 | 22 | /** our connection to the db. */ 23 | protected Connection connection; 24 | 25 | /** 26 | * Closes the connection to the database. 27 | */ 28 | public void close() throws SQLException { 29 | connection.close(); 30 | } 31 | 32 | /** 33 | * Creates a statement. 34 | * @return a statement 35 | * @throws SQLException 36 | */ 37 | public Statement createStatement() throws SQLException { 38 | return connection.createStatement(); 39 | } 40 | 41 | /** 42 | * Creates a prepated statement using a query. 43 | * @param query the query that will be used to create 44 | * a prepared statement. 45 | * @return a statement 46 | * @throws SQLException 47 | */ 48 | public PreparedStatement createPreparedStatement(String query) 49 | throws SQLException { 50 | return connection.prepareStatement(query); 51 | } 52 | 53 | /** 54 | * Performs an update in the database. 55 | * @param expression an SQL expression 56 | * (CREATE, DROP, INSERT, UPDATE) 57 | */ 58 | public void update(String expression) throws SQLException { 59 | Statement st = createStatement(); 60 | int i = st.executeUpdate(expression); 61 | st.close(); 62 | if (i == -1) { 63 | throw new SQLException("db error : " + expression); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/com/lowagie/database/HsqldbConnection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package com.lowagie.database; 9 | 10 | import java.sql.DriverManager; 11 | import java.sql.SQLException; 12 | import java.sql.Statement; 13 | 14 | /** 15 | * This is a helper class to access an hsqldb database. 16 | * The database scripts are supposed to be present in directory: 17 | * resources/db 18 | */ 19 | public class HsqldbConnection extends DatabaseConnection { 20 | 21 | /** 22 | * Creates the connection. 23 | * @param db_file_name_prefix the database name, 24 | * which is the prefix of the database file 25 | * @throws SQLException 26 | */ 27 | public HsqldbConnection(String db_file_name_prefix) 28 | throws SQLException { 29 | try { 30 | Class.forName("org.hsqldb.jdbcDriver"); 31 | } catch (ClassNotFoundException e) { 32 | throw new SQLException("HSQLDB database driver not found"); 33 | } 34 | connection = DriverManager.getConnection( 35 | "jdbc:hsqldb:resources/db/" + db_file_name_prefix, "SA", ""); 36 | } 37 | 38 | /** 39 | * Shuts down the database and closes the connection. 40 | */ 41 | public void close() throws SQLException { 42 | Statement st = createStatement(); 43 | st.execute("SHUTDOWN"); 44 | super.close(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/com/lowagie/database/MySqlConnection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package com.lowagie.database; 9 | 10 | import java.io.FileInputStream; 11 | import java.io.IOException; 12 | import java.sql.DriverManager; 13 | import java.sql.SQLException; 14 | import java.util.Properties; 15 | 16 | /** 17 | * This is a helper class to access a mySql database. 18 | * The username and password of the database are supposed to be present 19 | * in a properties file mysql.props (in the working directory) 20 | */ 21 | public class MySqlConnection extends DatabaseConnection { 22 | 23 | /** 24 | * Creates the connection. 25 | * @param db_file_name_prefix the database name, 26 | * which is the prefix of the database file 27 | * @throws SQLException 28 | */ 29 | public MySqlConnection(String database) throws SQLException { 30 | try { 31 | Class.forName("com.mysql.jdbc.Driver"); 32 | } catch (ClassNotFoundException e) { 33 | throw new SQLException("mySql database driver not found"); 34 | } 35 | Properties credentials = new Properties(); 36 | try { 37 | credentials.load(new FileInputStream("mysql.props")); 38 | } catch (IOException e) { 39 | throw new SQLException("Can't read mysql.props."); 40 | } 41 | connection = DriverManager.getConnection( 42 | "jdbc:mysql://localhost/" + database, 43 | credentials.getProperty("username"), 44 | credentials.getProperty("password")); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/com/lowagie/filmfestival/Category.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package com.lowagie.filmfestival; 9 | 10 | /** 11 | * POJO for an object that corresponds with a record 12 | * in the table festival_category. 13 | */ 14 | public class Category { 15 | 16 | /** The name of the category. */ 17 | protected String name; 18 | /** A short keyword for the category. */ 19 | protected String keyword; 20 | /** The color code of the category. */ 21 | protected String color; 22 | /** The parent category (if any). */ 23 | protected Category parent = null; 24 | 25 | /** 26 | * @return the name 27 | */ 28 | public String getName() { 29 | return name; 30 | } 31 | /** 32 | * @param name the name to set 33 | */ 34 | public void setName(String name) { 35 | this.name = name; 36 | } 37 | /** 38 | * @return the keyword 39 | */ 40 | public String getKeyword() { 41 | return keyword; 42 | } 43 | /** 44 | * @param keyword the keyword to set 45 | */ 46 | public void setKeyword(String keyword) { 47 | this.keyword = keyword; 48 | } 49 | /** 50 | * @return the parent 51 | */ 52 | public Category getParent() { 53 | return parent; 54 | } 55 | /** 56 | * @param parent the parent to set 57 | */ 58 | public void setParent(Category parent) { 59 | this.parent = parent; 60 | } 61 | /** 62 | * @return the color 63 | */ 64 | public String getColor() { 65 | return color; 66 | } 67 | /** 68 | * @param color the color to set 69 | */ 70 | public void setColor(String color) { 71 | this.color = color; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/com/lowagie/filmfestival/Country.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package com.lowagie.filmfestival; 9 | 10 | /** 11 | * POJO for an object that corresponds with a record 12 | * in the table film_country. 13 | */ 14 | public class Country { 15 | /** The name of a country. */ 16 | protected String country; 17 | 18 | /** 19 | * @return the country 20 | */ 21 | public String getCountry() { 22 | return country; 23 | } 24 | 25 | /** 26 | * @param country the country to set 27 | */ 28 | public void setCountry(String country) { 29 | this.country = country; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/com/lowagie/filmfestival/Director.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package com.lowagie.filmfestival; 9 | 10 | /** 11 | * POJO for an object that corresponds with a record 12 | * in the table film_director. 13 | */ 14 | public class Director { 15 | 16 | /** The family name of the director. */ 17 | protected String name; 18 | /** The given name of the director. */ 19 | protected String givenName; 20 | 21 | /** 22 | * @return the name 23 | */ 24 | public String getName() { 25 | return name; 26 | } 27 | /** 28 | * @param name the name to set 29 | */ 30 | public void setName(String name) { 31 | this.name = name; 32 | } 33 | /** 34 | * @return the givenName 35 | */ 36 | public String getGivenName() { 37 | return givenName; 38 | } 39 | /** 40 | * @param givenName the givenName to set 41 | */ 42 | public void setGivenName(String givenName) { 43 | this.givenName = givenName; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/com/lowagie/filmfestival/Entry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package com.lowagie.filmfestival; 9 | 10 | import java.util.ArrayList; 11 | import java.util.List; 12 | 13 | /** 14 | * POJO for an object that corresponds with a record 15 | * in the table festival_entry. 16 | */ 17 | public class Entry { 18 | 19 | /** The festival year. */ 20 | protected int year; 21 | /** The movie. */ 22 | protected Movie movie; 23 | /** The category. */ 24 | protected Category category; 25 | /** The screenings. */ 26 | protected List screenings = new ArrayList(); 27 | 28 | /** 29 | * Adds a screening to this entry. 30 | */ 31 | public void addScreening(Screening screening) { 32 | screenings.add(screening); 33 | } 34 | 35 | /** 36 | * @return the year 37 | */ 38 | public int getYear() { 39 | return year; 40 | } 41 | /** 42 | * @param year the year to set 43 | */ 44 | public void setYear(int year) { 45 | this.year = year; 46 | } 47 | /** 48 | * @return the movie 49 | */ 50 | public Movie getMovie() { 51 | return movie; 52 | } 53 | /** 54 | * @param movie the movie to set 55 | */ 56 | public void setMovie(Movie movie) { 57 | this.movie = movie; 58 | if (movie.getEntry() == null) 59 | movie.setEntry(this); 60 | } 61 | /** 62 | * @return the category 63 | */ 64 | public Category getCategory() { 65 | return category; 66 | } 67 | /** 68 | * @param category the category to set 69 | */ 70 | public void setCategory(Category category) { 71 | this.category = category; 72 | } 73 | /** 74 | * @return the screenings 75 | */ 76 | public List getScreenings() { 77 | return screenings; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/com/lowagie/filmfestival/FilmFonts.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package com.lowagie.filmfestival; 9 | 10 | import com.itextpdf.text.Font; 11 | import com.itextpdf.text.Font.FontFamily; 12 | 13 | /** 14 | * Contains a series of static Font objects that are used throughout the book. 15 | */ 16 | public class FilmFonts { 17 | 18 | /** A font used in our PDF file */ 19 | public static final Font NORMAL = new Font(FontFamily.HELVETICA, 12, Font.NORMAL); 20 | /** A font used in our PDF file */ 21 | public static final Font BOLD = new Font(FontFamily.HELVETICA, 12, Font.BOLD); 22 | /** A font used in our PDF file */ 23 | public static final Font ITALIC = new Font(FontFamily.HELVETICA, 12, Font.ITALIC); 24 | /** A font used in our PDF file */ 25 | public static final Font BOLDITALIC = new Font(FontFamily.HELVETICA, 12, Font.BOLDITALIC); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/com/lowagie/filmfestival/MovieComparator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package com.lowagie.filmfestival; 9 | 10 | import java.util.Comparator; 11 | 12 | /** 13 | * Compares movies based on their title or the year, they're made in. 14 | */ 15 | public class MovieComparator implements Comparator { 16 | 17 | /** Type for movies have to be sorted by title. */ 18 | public static int BY_TITLE = 0; 19 | /** Type for movies have to be sorted by production year. */ 20 | public static int BY_YEAR = 1; 21 | 22 | /** The type; can be BY_TITLE or BY_YEAR. */ 23 | protected int type; 24 | 25 | /** 26 | * Creates an instance of the MovieComparator. 27 | * @param type defines how the movies will be sorted; 28 | * can be BY_TITLE or BY_YEAR 29 | */ 30 | public MovieComparator(int type) { 31 | this.type = type; 32 | } 33 | 34 | /** 35 | * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) 36 | */ 37 | public int compare(Movie m1, Movie m2) { 38 | if (type == BY_YEAR) { 39 | int c = m1.getYear() - m2.getYear(); 40 | if (c != 0) 41 | return c; 42 | } 43 | return m1.getTitle().compareTo(m2.getTitle()); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/com/lowagie/filmfestival/Screening.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package com.lowagie.filmfestival; 9 | 10 | import java.sql.Date; 11 | import java.sql.Time; 12 | 13 | /** 14 | * POJO for an object that corresponds with a record 15 | * in the table festival_screening. 16 | */ 17 | public class Screening { 18 | /** The date of the screening. */ 19 | protected Date date; 20 | /** The time of the screening. */ 21 | protected Time time; 22 | /** The location of the screening. */ 23 | protected String location; 24 | /** Is this a screening for the press only? */ 25 | protected boolean press; 26 | /** The movie that will be screened. */ 27 | protected Movie movie = null; 28 | 29 | /** 30 | * @return the date 31 | */ 32 | public Date getDate() { 33 | return date; 34 | } 35 | /** 36 | * @param date the date to set 37 | */ 38 | public void setDate(Date date) { 39 | this.date = date; 40 | } 41 | /** 42 | * @return the time 43 | */ 44 | public Time getTime() { 45 | return time; 46 | } 47 | /** 48 | * @param time the time to set 49 | */ 50 | public void setTime(Time time) { 51 | this.time = time; 52 | } 53 | /** 54 | * @return the location 55 | */ 56 | public String getLocation() { 57 | return location; 58 | } 59 | /** 60 | * @param location the location to set 61 | */ 62 | public void setLocation(String location) { 63 | this.location = location; 64 | } 65 | /** 66 | * @return the press 67 | */ 68 | public boolean isPress() { 69 | return press; 70 | } 71 | /** 72 | * @param press the press to set 73 | */ 74 | public void setPress(boolean press) { 75 | this.press = press; 76 | } 77 | /** 78 | * @return the movie 79 | */ 80 | public Movie getMovie() { 81 | return movie; 82 | } 83 | /** 84 | * @param movie the movie to set 85 | */ 86 | public void setMovie(Movie movie) { 87 | this.movie = movie; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/part1/chapter01/HelloWorld.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part1.chapter01; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import com.itextpdf.text.Document; 14 | import com.itextpdf.text.DocumentException; 15 | import com.itextpdf.text.Paragraph; 16 | import com.itextpdf.text.pdf.PdfWriter; 17 | 18 | /** 19 | * First iText example: Hello World. 20 | */ 21 | public class HelloWorld { 22 | 23 | /** Path to the resulting PDF file. */ 24 | public static final String RESULT 25 | = "results/part1/chapter01/hello.pdf"; 26 | 27 | /** 28 | * Creates a PDF file: hello.pdf 29 | * @param args no arguments needed 30 | */ 31 | public static void main(String[] args) 32 | throws DocumentException, IOException { 33 | new HelloWorld().createPdf(RESULT); 34 | } 35 | 36 | /** 37 | * Creates a PDF document. 38 | * @param filename the path to the new PDF document 39 | * @throws DocumentException 40 | * @throws IOException 41 | */ 42 | public void createPdf(String filename) 43 | throws DocumentException, IOException { 44 | // step 1 45 | Document document = new Document(); 46 | // step 2 47 | PdfWriter.getInstance(document, new FileOutputStream(filename)); 48 | // step 3 49 | document.open(); 50 | // step 4 51 | document.add(new Paragraph("Hello World!")); 52 | // step 5 53 | document.close(); 54 | } 55 | } -------------------------------------------------------------------------------- /src/part1/chapter01/HelloWorldColumn.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part1.chapter01; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import com.itextpdf.text.Document; 14 | import com.itextpdf.text.DocumentException; 15 | import com.itextpdf.text.Element; 16 | import com.itextpdf.text.Phrase; 17 | import com.itextpdf.text.pdf.ColumnText; 18 | import com.itextpdf.text.pdf.PdfContentByte; 19 | import com.itextpdf.text.pdf.PdfWriter; 20 | 21 | /** 22 | * First iText example: Hello World. 23 | */ 24 | public class HelloWorldColumn { 25 | 26 | /** Path to the resulting PDF file. */ 27 | public static final String RESULT 28 | = "results/part1/chapter01/hello_column.pdf"; 29 | 30 | /** 31 | * Creates a PDF file: hello_column.pdf 32 | * @param args no arguments needed 33 | */ 34 | public static void main(String[] args) 35 | throws DocumentException, IOException { 36 | // step 1 37 | Document document = new Document(); 38 | // step 2 39 | PdfWriter writer 40 | = PdfWriter.getInstance(document, new FileOutputStream(RESULT)); 41 | // step 3 42 | document.open(); 43 | // step 4 44 | // we set the compression to 0 so that we can read the PDF syntax 45 | writer.setCompressionLevel(0); 46 | // writes something to the direct content using a convenience method 47 | Phrase hello = new Phrase("Hello World"); 48 | PdfContentByte canvas = writer.getDirectContentUnder(); 49 | ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, 50 | hello, 36, 788, 0); 51 | // step 5 52 | document.close(); 53 | } 54 | } -------------------------------------------------------------------------------- /src/part1/chapter01/HelloWorldDirect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part1.chapter01; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import com.itextpdf.text.Document; 14 | import com.itextpdf.text.DocumentException; 15 | import com.itextpdf.text.pdf.BaseFont; 16 | import com.itextpdf.text.pdf.PdfContentByte; 17 | import com.itextpdf.text.pdf.PdfWriter; 18 | 19 | /** 20 | * First iText example: Hello World. 21 | */ 22 | public class HelloWorldDirect { 23 | 24 | /** Path to the resulting PDF file. */ 25 | public static final String RESULT 26 | = "results/part1/chapter01/hello_direct.pdf"; 27 | 28 | /** 29 | * Creates a PDF file: hello_direct.pdf 30 | * @param args no arguments needed 31 | */ 32 | public static void main(String[] args) 33 | throws DocumentException, IOException { 34 | // step 1 35 | Document document = new Document(); 36 | // step 2 37 | PdfWriter writer = 38 | PdfWriter.getInstance(document, new FileOutputStream(RESULT)); 39 | // step 3 40 | document.open(); 41 | // step 4 42 | PdfContentByte canvas = writer.getDirectContentUnder(); 43 | writer.setCompressionLevel(0); 44 | canvas.saveState(); // q 45 | canvas.beginText(); // BT 46 | canvas.moveText(36, 788); // 36 788 Td 47 | canvas.setFontAndSize(BaseFont.createFont(), 12); // /F1 12 Tf 48 | canvas.showText("Hello World"); // (Hello World)Tj 49 | canvas.endText(); // ET 50 | canvas.restoreState(); // Q 51 | // step 5 52 | document.close(); 53 | } 54 | } -------------------------------------------------------------------------------- /src/part1/chapter01/HelloWorldLandscape1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part1.chapter01; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import com.itextpdf.text.Document; 14 | import com.itextpdf.text.DocumentException; 15 | import com.itextpdf.text.PageSize; 16 | import com.itextpdf.text.Paragraph; 17 | import com.itextpdf.text.pdf.PdfWriter; 18 | 19 | /** 20 | * A possible way to create a document in the landscape format. 21 | */ 22 | public class HelloWorldLandscape1 { 23 | 24 | /** Path to the resulting PDF file. */ 25 | public static final String RESULT 26 | = "results/part1/chapter01/hello_landscape1.pdf"; 27 | 28 | /** 29 | * Creates a PDF file: hello_landscape1.pdf 30 | * @param args no arguments needed 31 | */ 32 | public static void main(String[] args) 33 | throws DocumentException, IOException { 34 | // step 1 35 | // landscape format using the rotate() method 36 | Document document = new Document(PageSize.LETTER.rotate()); 37 | // step 2 38 | PdfWriter.getInstance(document, new FileOutputStream(RESULT)); 39 | // step 3 40 | document.open(); 41 | // step 4 42 | document.add(new Paragraph("Hello World")); 43 | // step 5 44 | document.close(); 45 | } 46 | } -------------------------------------------------------------------------------- /src/part1/chapter01/HelloWorldLandscape2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part1.chapter01; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import com.itextpdf.text.*; 14 | import com.itextpdf.text.pdf.PdfWriter; 15 | 16 | /** 17 | * A possible way to create a document in the landscape format. 18 | */ 19 | public class HelloWorldLandscape2 { 20 | 21 | /** Path to the resulting PDF file. */ 22 | public static final String RESULT 23 | = "results/part1/chapter01/hello_landscape2.pdf"; 24 | 25 | /** 26 | * Creates a PDF file: hello_landscape2.pdf 27 | * @param args no arguments needed 28 | */ 29 | public static void main(String[] args) 30 | throws DocumentException, IOException { 31 | // step 1 32 | // landscape format because width > height 33 | Document document = new Document(new Rectangle(792, 612)); 34 | // step 2 35 | PdfWriter.getInstance(document, new FileOutputStream(RESULT)); 36 | // step 3 37 | document.open(); 38 | // step 4 39 | document.add(new Paragraph("Hello World")); 40 | // step 5 41 | document.close(); 42 | } 43 | } -------------------------------------------------------------------------------- /src/part1/chapter01/HelloWorldLetter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part1.chapter01; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import com.itextpdf.text.Document; 14 | import com.itextpdf.text.DocumentException; 15 | import com.itextpdf.text.PageSize; 16 | import com.itextpdf.text.Paragraph; 17 | import com.itextpdf.text.pdf.PdfWriter; 18 | 19 | /** 20 | * Hello World example using the paper size Letter. 21 | */ 22 | public class HelloWorldLetter { 23 | 24 | /** Path to the resulting PDF file. */ 25 | public static final String RESULT 26 | = "results/part1/chapter01/hello_letter.pdf"; 27 | 28 | /** 29 | * Creates a PDF file: hello_letter.pdf. 30 | * @param args no arguments needed 31 | */ 32 | public static void main(String[] args) throws DocumentException, IOException { 33 | // step 1 34 | // Specifying the page size 35 | Document document = new Document(PageSize.LETTER); 36 | // step 2 37 | PdfWriter.getInstance(document, new FileOutputStream(RESULT)); 38 | // step 3 39 | document.open(); 40 | // step 4 41 | document.add(new Paragraph("Hello World")); 42 | // step 5 43 | document.close(); 44 | } 45 | } -------------------------------------------------------------------------------- /src/part1/chapter01/HelloWorldMaximum.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part1.chapter01; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import com.itextpdf.text.Document; 14 | import com.itextpdf.text.DocumentException; 15 | import com.itextpdf.text.Paragraph; 16 | import com.itextpdf.text.Rectangle; 17 | import com.itextpdf.text.pdf.PdfWriter; 18 | 19 | /** 20 | * Creates a PDF with the biggest possible page size. 21 | */ 22 | public class HelloWorldMaximum { 23 | 24 | /** Path to the resulting PDF file. */ 25 | public static final String RESULT 26 | = "results/part1/chapter01/hello_maximum.pdf"; 27 | 28 | /** 29 | * Creates a PDF file: hello_maximum.pdf 30 | * Important notice: the PDF is valid (in conformance with 31 | * ISO-32000), but some PDF viewers won't be able to render 32 | * the PDF correctly due to their own limitations. 33 | * @param args no arguments needed 34 | */ 35 | public static void main(String[] args) 36 | throws DocumentException, IOException { 37 | // step 1 38 | // maximum page size 39 | Document document = new Document(new Rectangle(14400, 14400)); 40 | // step 2 41 | PdfWriter writer = 42 | PdfWriter.getInstance(document, new FileOutputStream(RESULT)); 43 | // changes the user unit 44 | writer.setUserunit(75000f); 45 | // step 3 46 | document.open(); 47 | // step 4 48 | document.add(new Paragraph("Hello World")); 49 | // step 5 50 | document.close(); 51 | } 52 | } -------------------------------------------------------------------------------- /src/part1/chapter01/HelloWorldMemory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part1.chapter01; 9 | 10 | import java.io.ByteArrayOutputStream; 11 | import java.io.FileOutputStream; 12 | import java.io.IOException; 13 | 14 | import com.itextpdf.text.Document; 15 | import com.itextpdf.text.DocumentException; 16 | import com.itextpdf.text.Paragraph; 17 | import com.itextpdf.text.pdf.PdfWriter; 18 | 19 | /** 20 | * Creates a PDF file in memory. 21 | */ 22 | public class HelloWorldMemory { 23 | 24 | /** Path to the resulting PDF file. */ 25 | public static final String RESULT 26 | = "results/part1/chapter01/hello_memory.pdf"; 27 | 28 | /** 29 | * Creates a PDF file: hello_memory.pdf 30 | * @param args no arguments needed 31 | */ 32 | public static void main(String[] args) 33 | throws DocumentException, IOException { 34 | // step 1 35 | Document document = new Document(); 36 | // step 2 37 | // we'll create the file in memory 38 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); 39 | PdfWriter.getInstance(document, baos); 40 | // step 3 41 | document.open(); 42 | // step 4 43 | document.add(new Paragraph("Hello World!")); 44 | // step 5 45 | document.close(); 46 | 47 | // let's write the file in memory to a file anyway 48 | FileOutputStream fos = new FileOutputStream(RESULT); 49 | fos.write(baos.toByteArray()); 50 | fos.close(); 51 | } 52 | } -------------------------------------------------------------------------------- /src/part1/chapter01/HelloWorldMirroredMargins.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part1.chapter01; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import com.itextpdf.text.Document; 14 | import com.itextpdf.text.DocumentException; 15 | import com.itextpdf.text.Element; 16 | import com.itextpdf.text.PageSize; 17 | import com.itextpdf.text.Paragraph; 18 | import com.itextpdf.text.pdf.PdfWriter; 19 | 20 | /** 21 | * Examples with mirrored margins. 22 | */ 23 | public class HelloWorldMirroredMargins { 24 | 25 | /** Path to the resulting PDF file. */ 26 | public static final String RESULT 27 | = "results/part1/chapter01/hello_mirrored_margins.pdf"; 28 | 29 | /** 30 | * Creates a PDF file: hello_mirrored_margins.pdf 31 | * @param args no arguments needed 32 | */ 33 | public static void main(String[] args) 34 | throws DocumentException, IOException { 35 | // step 1 36 | Document document = new Document(); 37 | // step 2 38 | PdfWriter.getInstance(document, new FileOutputStream(RESULT)); 39 | document.setPageSize(PageSize.A5); 40 | document.setMargins(36, 72, 108, 180); 41 | document.setMarginMirroring(true); 42 | // step 3 43 | document.open(); 44 | // step 4 45 | document.add(new Paragraph( 46 | "The left margin of this odd page is 36pt (0.5 inch); " + 47 | "the right margin 72pt (1 inch); " + 48 | "the top margin 108pt (1.5 inch); " + 49 | "the bottom margin 180pt (2.5 inch).")); 50 | Paragraph paragraph = new Paragraph(); 51 | paragraph.setAlignment(Element.ALIGN_JUSTIFIED); 52 | for (int i = 0; i < 20; i++) { 53 | paragraph.add("Hello World! Hello People! " + 54 | "Hello Sky! Hello Sun! Hello Moon! Hello Stars!"); 55 | } 56 | document.add(paragraph); 57 | document.add(new Paragraph( 58 | "The right margin of this even page is 36pt (0.5 inch); " + 59 | "the left margin 72pt (1 inch).")); 60 | // step 5 61 | document.close(); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/part1/chapter01/HelloWorldMirroredMarginsTop.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part1.chapter01; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import com.itextpdf.text.Document; 14 | import com.itextpdf.text.DocumentException; 15 | import com.itextpdf.text.Element; 16 | import com.itextpdf.text.PageSize; 17 | import com.itextpdf.text.Paragraph; 18 | import com.itextpdf.text.pdf.PdfWriter; 19 | 20 | /** 21 | * Examples with mirrored margins. 22 | */ 23 | public class HelloWorldMirroredMarginsTop { 24 | 25 | /** Path to the resulting PDF file. */ 26 | public static final String RESULT 27 | = "results/part1/chapter01/hello_mirrored_top.pdf"; 28 | 29 | /** 30 | * Creates a PDF file: hello_mirrored_margins.pdf 31 | * @param args no arguments needed 32 | */ 33 | public static void main(String[] args) 34 | throws DocumentException, IOException { 35 | // step 1 36 | Document document = new Document(); 37 | // step 2 38 | PdfWriter.getInstance(document, new FileOutputStream(RESULT)); 39 | // setting page size, margins and mirrered margins 40 | document.setPageSize(PageSize.A5); 41 | document.setMargins(36, 72, 108, 180); 42 | document.setMarginMirroringTopBottom(true); 43 | // step 3 44 | document.open(); 45 | // step 4 46 | document.add(new Paragraph( 47 | "The left margin of this odd page is 36pt (0.5 inch); " + 48 | "the right margin 72pt (1 inch); " + 49 | "the top margin 108pt (1.5 inch); " + 50 | "the bottom margin 180pt (2.5 inch).")); 51 | Paragraph paragraph = new Paragraph(); 52 | paragraph.setAlignment(Element.ALIGN_JUSTIFIED); 53 | for (int i = 0; i < 20; i++) { 54 | paragraph.add("Hello World! Hello People! " + 55 | "Hello Sky! Hello Sun! Hello Moon! Hello Stars!"); 56 | } 57 | document.add(paragraph); 58 | document.add(new Paragraph("The top margin 180pt (2.5 inch).")); 59 | // step 5 60 | document.close(); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/part1/chapter01/HelloWorldNarrow.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part1.chapter01; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import com.itextpdf.text.Document; 14 | import com.itextpdf.text.DocumentException; 15 | import com.itextpdf.text.Paragraph; 16 | import com.itextpdf.text.Rectangle; 17 | import com.itextpdf.text.pdf.PdfWriter; 18 | 19 | /** 20 | * Hello World: document constructor. 21 | */ 22 | public class HelloWorldNarrow { 23 | 24 | /** Path to the resulting PDF file. */ 25 | public static final String RESULT 26 | = "results/part1/chapter01/hello_narrow.pdf"; 27 | 28 | /** 29 | * Creates a PDF file: hello_narrow.pdf 30 | * @param args no arguments needed 31 | */ 32 | public static void main(String[] args) 33 | throws DocumentException, IOException { 34 | // step 1 35 | // Using a custom page size 36 | Rectangle pagesize = new Rectangle(216f, 720f); 37 | Document document = new Document(pagesize, 36f, 72f, 108f, 180f); 38 | // step 2 39 | PdfWriter.getInstance(document, new FileOutputStream(RESULT)); 40 | // step 3 41 | document.open(); 42 | // step 4 43 | document.add(new Paragraph( 44 | "Hello World! Hello People! " + 45 | "Hello Sky! Hello Sun! Hello Moon! Hello Stars!")); 46 | // step 5 47 | document.close(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/part1/chapter01/HelloWorldVersion_1_7.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part1.chapter01; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import com.itextpdf.text.Document; 14 | import com.itextpdf.text.DocumentException; 15 | import com.itextpdf.text.Paragraph; 16 | import com.itextpdf.text.pdf.PdfWriter; 17 | 18 | /** 19 | * Creates a Hello World in PDF version 1.7 20 | */ 21 | public class HelloWorldVersion_1_7 { 22 | 23 | /** Path to the resulting PDF file. */ 24 | public static final String RESULT = 25 | "results/part1/chapter01/hello_1_7.pdf"; 26 | 27 | /** 28 | * Creates a PDF file: hello.pdf 29 | * @param args no arguments needed 30 | */ 31 | public static void main(String[] args) 32 | throws DocumentException, IOException { 33 | // step 1 34 | Document document = new Document(); 35 | // step 2 36 | // Creating a PDF 1.7 document 37 | PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT)); 38 | writer.setPdfVersion(PdfWriter.VERSION_1_7); 39 | // step 3 40 | document.open(); 41 | // step 4 42 | document.add(new Paragraph("Hello World!")); 43 | // step 5 44 | document.close(); 45 | } 46 | } -------------------------------------------------------------------------------- /src/part1/chapter01/HelloZip.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part1.chapter01; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | import java.util.zip.ZipEntry; 13 | import java.util.zip.ZipOutputStream; 14 | 15 | import com.itextpdf.text.Document; 16 | import com.itextpdf.text.DocumentException; 17 | import com.itextpdf.text.Paragraph; 18 | import com.itextpdf.text.pdf.PdfWriter; 19 | 20 | /** 21 | * Writing one PDF file to a ZipOutputStream. 22 | */ 23 | public class HelloZip { 24 | 25 | /** Path to the resulting PDF file. */ 26 | public static final String RESULT 27 | = "results/part1/chapter01/hello.zip"; 28 | 29 | /** 30 | * Creates a zip file with five PDF documents: 31 | * hello1.pdf to hello5.pdf 32 | * @param args no arguments needed 33 | */ 34 | public static void main(String[] args) 35 | throws DocumentException, IOException { 36 | // creating a zip file with different PDF documents 37 | ZipOutputStream zip = 38 | new ZipOutputStream(new FileOutputStream(RESULT)); 39 | for (int i = 1; i <= 3; i++) { 40 | ZipEntry entry = new ZipEntry("hello_" + i + ".pdf"); 41 | zip.putNextEntry(entry); 42 | 43 | // step 1 44 | Document document = new Document(); 45 | // step 2 46 | PdfWriter writer = PdfWriter.getInstance(document, zip); 47 | writer.setCloseStream(false); 48 | // step 3 49 | document.open(); 50 | // step 4 51 | document.add(new Paragraph("Hello " + i)); 52 | // step 5 53 | document.close(); 54 | 55 | zip.closeEntry(); 56 | } 57 | zip.close(); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/part1/chapter02/DatabaseTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part1.chapter02; 9 | 10 | import java.io.FileNotFoundException; 11 | import java.io.FileOutputStream; 12 | import java.io.PrintStream; 13 | import java.io.UnsupportedEncodingException; 14 | import java.sql.ResultSet; 15 | import java.sql.SQLException; 16 | import java.sql.Statement; 17 | 18 | import com.lowagie.database.DatabaseConnection; 19 | import com.lowagie.database.HsqldbConnection; 20 | 21 | /** 22 | * We'll test our hsqldb database with this example 23 | */ 24 | public class DatabaseTest { 25 | 26 | /** The output of this database test: a text file with a list of countries. */ 27 | public static final String RESULT = "results/part1/chapter02/countries.txt"; 28 | 29 | /** 30 | * Writes the names of the countries that are in our database 31 | * @param args no arguments needed 32 | * @throws FileNotFoundException 33 | */ 34 | public static void main(String[] args) 35 | throws SQLException, UnsupportedEncodingException, FileNotFoundException { 36 | // no PDF, just a text file 37 | PrintStream out = new PrintStream(new FileOutputStream(RESULT)); 38 | // Make the connection to the database 39 | DatabaseConnection connection = new HsqldbConnection("filmfestival"); 40 | // create the statement 41 | Statement stm = connection.createStatement(); 42 | // execute the query 43 | ResultSet rs = stm.executeQuery("SELECT country FROM film_country ORDER BY country"); 44 | // loop over the results 45 | while (rs.next()) { 46 | // write a country to the text file 47 | out.println(rs.getString("country")); 48 | } 49 | // close the statement 50 | stm.close(); 51 | // close the database connection 52 | connection.close(); 53 | // flush and close the print stream 54 | out.flush(); 55 | out.close(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/part1/chapter02/MovieTitles.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part1.chapter02; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | import java.sql.SQLException; 13 | import java.util.List; 14 | 15 | import com.lowagie.database.DatabaseConnection; 16 | import com.lowagie.database.HsqldbConnection; 17 | import com.lowagie.filmfestival.PojoFactory; 18 | import com.lowagie.filmfestival.Movie; 19 | import com.itextpdf.text.Document; 20 | import com.itextpdf.text.DocumentException; 21 | import com.itextpdf.text.Paragraph; 22 | import com.itextpdf.text.pdf.PdfWriter; 23 | 24 | /** 25 | * Writes a list of movies titles to a PDF file. 26 | */ 27 | public class MovieTitles { 28 | 29 | /** The resulting PDF file. */ 30 | public static final String RESULT = "results/part1/chapter02/movie_titles.pdf"; 31 | 32 | /** 33 | * Main method. 34 | * 35 | * @param args no arguments needed 36 | * @throws DocumentException 37 | * @throws IOException 38 | * @throws SQLException 39 | */ 40 | public static void main(String[] args) throws IOException, DocumentException, SQLException { 41 | // Create a database connection 42 | DatabaseConnection connection = new HsqldbConnection("filmfestival"); 43 | // step 1 44 | Document document = new Document(); 45 | // step 2 46 | PdfWriter.getInstance(document, new FileOutputStream(RESULT)); 47 | // step 3 48 | document.open(); 49 | // step 4 50 | List movies = PojoFactory.getMovies(connection); 51 | for (Movie movie : movies) { 52 | document.add(new Paragraph(movie.getTitle())); 53 | } 54 | // step 5 55 | document.close(); 56 | // Close the database connection 57 | connection.close(); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/part1/chapter02/PipeSplitCharacter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part1.chapter02; 9 | 10 | import com.itextpdf.text.SplitCharacter; 11 | import com.itextpdf.text.pdf.PdfChunk; 12 | 13 | /** 14 | * Implementation of the SplitCharacter interface. 15 | * Use an instance of this class with Chunk.setSplitCharacter(); 16 | */ 17 | public class PipeSplitCharacter implements SplitCharacter { 18 | 19 | /** 20 | * @see com.itextpdf.text.SplitCharacter#isSplitCharacter(int, int, int, char[], 21 | * com.itextpdf.text.pdf.PdfChunk[]) 22 | */ 23 | public boolean isSplitCharacter(int start, int current, int end, char[] cc, 24 | PdfChunk[] ck) { 25 | char c; 26 | if (ck == null) 27 | c = cc[current]; 28 | else 29 | c = (char)ck[Math.min(current, ck.length - 1)] 30 | .getUnicodeEquivalent(cc[current]); 31 | return (c == '|' || c <= ' ' || c == '-'); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/part1/chapter02/StarSeparator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part1.chapter02; 9 | 10 | import java.io.IOException; 11 | 12 | import com.itextpdf.text.DocumentException; 13 | import com.itextpdf.text.Element; 14 | import com.itextpdf.text.pdf.BaseFont; 15 | import com.itextpdf.text.pdf.PdfContentByte; 16 | import com.itextpdf.text.pdf.draw.DrawInterface; 17 | 18 | public class StarSeparator implements DrawInterface { 19 | 20 | /** The font that will be used to draw the arrow. */ 21 | protected BaseFont bf; 22 | 23 | public static final StarSeparator LINE = new StarSeparator(); 24 | 25 | /** 26 | * Constructs a positioned Arrow mark. 27 | * @param left if true, an arrow will be drawn on the left; 28 | * otherwise, it will be drawn on the right. 29 | * @throws IOException 30 | * @throws DocumentException 31 | */ 32 | public StarSeparator() { 33 | try { 34 | bf = BaseFont.createFont(); 35 | } catch (DocumentException e) { 36 | bf = null; 37 | } catch (IOException e) { 38 | bf = null; 39 | } 40 | } 41 | 42 | /** 43 | * Draws three stars to separate two paragraphs. 44 | * @see com.itextpdf.text.pdf.draw.DrawInterface#draw( 45 | * com.itextpdf.text.pdf.PdfContentByte, float, float, float, float, float) 46 | */ 47 | public void draw(PdfContentByte canvas, 48 | float llx, float lly, float urx, float ury, float y) { 49 | float middle = (llx + urx) / 2; 50 | canvas.beginText(); 51 | canvas.setFontAndSize(bf, 10); 52 | canvas.showTextAligned(Element.ALIGN_CENTER, "*", middle, y, 0); 53 | canvas.showTextAligned(Element.ALIGN_CENTER, "* *", middle, y -10, 0); 54 | canvas.endText(); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/part1/chapter03/ImageDirect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part1.chapter03; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import com.itextpdf.text.Document; 14 | import com.itextpdf.text.DocumentException; 15 | import com.itextpdf.text.Element; 16 | import com.itextpdf.text.Font; 17 | import com.itextpdf.text.Image; 18 | import com.itextpdf.text.PageSize; 19 | import com.itextpdf.text.Paragraph; 20 | import com.itextpdf.text.Font.FontFamily; 21 | import com.itextpdf.text.pdf.PdfWriter; 22 | 23 | public class ImageDirect { 24 | 25 | /** The resulting PDF. */ 26 | public static final String RESULT 27 | = "results/part1/chapter03/image_direct.pdf"; 28 | /** The movie poster. */ 29 | public static final String RESOURCE 30 | = "resources/img/loa.jpg"; 31 | 32 | public static void main(String[] args) 33 | throws IOException, DocumentException { 34 | // step 1 35 | Document document 36 | = new Document(PageSize.POSTCARD, 30, 30, 30, 30); 37 | // step 2 38 | PdfWriter writer 39 | = PdfWriter.getInstance(document, new FileOutputStream(RESULT)); 40 | writer.setCompressionLevel(0); 41 | // step 3 42 | document.open(); 43 | // step 4 44 | Image img = Image.getInstance(RESOURCE); 45 | img.setAbsolutePosition((PageSize.POSTCARD.getWidth() - img.getScaledWidth()) / 2, 46 | (PageSize.POSTCARD.getHeight() - img.getScaledHeight()) / 2); 47 | writer.getDirectContent().addImage(img); 48 | Paragraph p = new Paragraph("Foobar Film Festival", new Font(FontFamily.HELVETICA, 22)); 49 | p.setAlignment(Element.ALIGN_CENTER); 50 | document.add(p); 51 | // step 5 52 | document.close(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/part1/chapter03/ImageInline.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part1.chapter03; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import com.itextpdf.text.Document; 14 | import com.itextpdf.text.DocumentException; 15 | import com.itextpdf.text.Image; 16 | import com.itextpdf.text.PageSize; 17 | import com.itextpdf.text.pdf.PdfWriter; 18 | 19 | public class ImageInline { 20 | 21 | /** The resulting PDF. */ 22 | public static final String RESULT 23 | = "results/part1/chapter03/image_inline.pdf"; 24 | /** The movie poster. */ 25 | public static final String RESOURCE 26 | = "resources/img/loa.jpg"; 27 | 28 | /** 29 | * Main method. 30 | * 31 | * @param args no arguments needed 32 | * @throws DocumentException 33 | * @throws IOException 34 | */ 35 | public static void main(String[] args) 36 | throws IOException, DocumentException { 37 | // step 1 38 | Document document = new Document(PageSize.POSTCARD, 30, 30, 30, 30); 39 | // step 2 40 | PdfWriter writer = PdfWriter.getInstance(document, 41 | new FileOutputStream(RESULT)); 42 | writer.setCompressionLevel(0); 43 | // step 3 44 | document.open(); 45 | // step 4 46 | Image img = Image.getInstance(RESOURCE); 47 | img.setAbsolutePosition( 48 | (PageSize.POSTCARD.getWidth() - img.getScaledWidth()) / 2, 49 | (PageSize.POSTCARD.getHeight() - img.getScaledHeight()) / 2); 50 | writer.getDirectContent().addImage(img, true); 51 | // step 5 52 | document.close(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/part1/chapter03/ImageSkew.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part1.chapter03; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import com.itextpdf.text.Document; 14 | import com.itextpdf.text.DocumentException; 15 | import com.itextpdf.text.Image; 16 | import com.itextpdf.text.PageSize; 17 | import com.itextpdf.text.pdf.PdfWriter; 18 | 19 | public class ImageSkew { 20 | 21 | /** The resulting PDF. */ 22 | public static final String RESULT = "results/part1/chapter03/image_skew.pdf"; 23 | /** The movie poster. */ 24 | public static final String RESOURCE = "resources/img/loa.jpg"; 25 | 26 | /** 27 | * Main method. 28 | * 29 | * @param args no arguments needed 30 | * @throws DocumentException 31 | * @throws IOException 32 | */ 33 | public static void main(String[] args) 34 | throws IOException, DocumentException { 35 | // step 1 36 | Document document = new Document(PageSize.POSTCARD.rotate()); 37 | // step 2 38 | PdfWriter writer = PdfWriter.getInstance(document, 39 | new FileOutputStream(RESULT)); 40 | writer.setCompressionLevel(0); 41 | // step 3 42 | document.open(); 43 | // step 4 44 | Image img = Image.getInstance(RESOURCE); 45 | // Add the image to the upper layer 46 | writer.getDirectContent().addImage(img, 47 | img.getWidth(), 0, 0.35f * img.getHeight(), 48 | 0.65f * img.getHeight(), 30, 30); 49 | // step 5 50 | document.close(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/part1/chapter03/MovieCalendar.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part1.chapter03; 9 | 10 | import java.io.IOException; 11 | 12 | import com.lowagie.filmfestival.Screening; 13 | import com.itextpdf.text.DocumentException; 14 | import com.itextpdf.text.Element; 15 | import com.itextpdf.text.Phrase; 16 | import com.itextpdf.text.Rectangle; 17 | import com.itextpdf.text.pdf.ColumnText; 18 | import com.itextpdf.text.pdf.PdfContentByte; 19 | 20 | /** 21 | * Draws a time table to the direct content using lines and simple shapes, 22 | * adding blocks representing a movies. 23 | */ 24 | public class MovieCalendar extends MovieTextInfo { 25 | 26 | /** The resulting PDF. */ 27 | public static final String RESULT = "results/part1/chapter03/movie_calendar.pdf"; 28 | 29 | /** 30 | * Draws the info about the movie. 31 | * @throws DocumentException 32 | */ 33 | protected void drawMovieInfo(Screening screening, PdfContentByte directcontent) 34 | throws DocumentException { 35 | super.drawMovieInfo(screening, directcontent); 36 | Rectangle rect = getPosition(screening); 37 | ColumnText column = new ColumnText(directcontent); 38 | column.setSimpleColumn(new Phrase(screening.getMovie().getMovieTitle()), 39 | rect.getLeft(), rect.getBottom(), 40 | rect.getRight(), rect.getTop(), 18, Element.ALIGN_CENTER); 41 | column.go(); 42 | } 43 | 44 | /** 45 | * Constructor for the MovieCalendar class; initializes the base font object. 46 | * @throws IOException 47 | * @throws DocumentException 48 | */ 49 | public MovieCalendar() throws DocumentException, IOException { 50 | super(); 51 | } 52 | 53 | /** 54 | * Main method creating the PDF. 55 | * @param args no arguments needed 56 | * @throws DocumentException 57 | * @throws IOException 58 | */ 59 | public static void main(String[] args) 60 | throws IOException, DocumentException { 61 | new MovieCalendar().createPdf(RESULT); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/part1/chapter04/NestedTable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part1.chapter04; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import com.itextpdf.text.Document; 14 | import com.itextpdf.text.DocumentException; 15 | import com.itextpdf.text.pdf.PdfPCell; 16 | import com.itextpdf.text.pdf.PdfPTable; 17 | import com.itextpdf.text.pdf.PdfWriter; 18 | 19 | public class NestedTable { 20 | 21 | /** The resulting PDF file. */ 22 | public static final String RESULT 23 | = "results/part1/chapter04/nested_table.pdf"; 24 | 25 | /** 26 | * Main method. 27 | * @param args no arguments needed 28 | * @throws DocumentException 29 | * @throws IOException 30 | */ 31 | public static void main(String[] args) 32 | throws DocumentException, IOException { 33 | // step 1 34 | Document document = new Document(); 35 | // step 2 36 | PdfWriter.getInstance(document, new FileOutputStream(RESULT)); 37 | // step 3 38 | document.open(); 39 | // step 4 40 | PdfPTable table = new PdfPTable(4); 41 | PdfPTable nested1 = new PdfPTable(2); 42 | nested1.addCell("1.1"); 43 | nested1.addCell("1.2"); 44 | PdfPTable nested2 = new PdfPTable(1); 45 | nested2.addCell("12.1"); 46 | nested2.addCell("12.2"); 47 | for (int k = 0; k < 16; ++k) { 48 | if (k == 1) { 49 | table.addCell(nested1); 50 | } else if (k == 12) { 51 | table.addCell(new PdfPCell(nested2)); 52 | } else { 53 | table.addCell("cell " + k); 54 | } 55 | } 56 | document.add(table); 57 | // step 5 58 | document.close(); 59 | } 60 | } -------------------------------------------------------------------------------- /src/part1/chapter04/TableAlignment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part1.chapter04; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import com.itextpdf.text.Document; 14 | import com.itextpdf.text.DocumentException; 15 | import com.itextpdf.text.Element; 16 | import com.itextpdf.text.pdf.PdfPTable; 17 | import com.itextpdf.text.pdf.PdfWriter; 18 | 19 | public class TableAlignment extends MyFirstTable { 20 | 21 | /** The resulting PDF file. */ 22 | public static final String RESULT 23 | = "results/part1/chapter04/table_alignment.pdf"; 24 | 25 | /** 26 | * Creates a PDF with information about the movies 27 | * @param filename the name of the PDF file that will be created. 28 | * @throws DocumentException 29 | * @throws IOException 30 | */ 31 | public void createPdf(String filename) 32 | throws IOException, DocumentException { 33 | // step 1 34 | Document document = new Document(); 35 | // step 2 36 | PdfWriter.getInstance(document, new FileOutputStream(filename)); 37 | // step 3 38 | document.open(); 39 | // step 4 40 | PdfPTable table = createFirstTable(); 41 | table.setWidthPercentage(50); 42 | table.setHorizontalAlignment(Element.ALIGN_LEFT); 43 | document.add(table); 44 | table.setHorizontalAlignment(Element.ALIGN_CENTER); 45 | document.add(table); 46 | table.setHorizontalAlignment(Element.ALIGN_RIGHT); 47 | document.add(table); 48 | // step 5 49 | document.close(); 50 | } 51 | 52 | /** 53 | * Main method. 54 | * @param args no arguments needed 55 | * @throws DocumentException 56 | * @throws IOException 57 | */ 58 | public static void main(String[] args) 59 | throws IOException, DocumentException { 60 | new TableAlignment().createPdf(RESULT); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/part1/chapter05/Hero3.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part1.chapter05; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import com.itextpdf.text.Document; 14 | import com.itextpdf.text.DocumentException; 15 | import com.itextpdf.text.PageSize; 16 | import com.itextpdf.text.Rectangle; 17 | import com.itextpdf.text.pdf.PdfContentByte; 18 | import com.itextpdf.text.pdf.PdfTemplate; 19 | import com.itextpdf.text.pdf.PdfWriter; 20 | 21 | public class Hero3 extends Hero1 { 22 | 23 | /** The resulting PDF file. */ 24 | public static final String RESULT = "results/part1/chapter05/hero3.pdf"; 25 | 26 | /** 27 | * Creates a PDF document. 28 | * @param filename the path to the new PDF document 29 | * @throws DocumentException 30 | * @throws IOException 31 | */ 32 | public void createPdf(String filename) throws IOException, DocumentException { 33 | // step 1 34 | Document document = new Document(PageSize.A4); 35 | // step 2 36 | PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename)); 37 | Rectangle art = new Rectangle(50, 50, 545, 792); 38 | writer.setBoxSize("art", art); 39 | // step 3 40 | document.open(); 41 | // step 4 42 | PdfContentByte content = writer.getDirectContent(); 43 | PdfTemplate template = createTemplate(content, PageSize.A4, 1); 44 | content.addTemplate(template, 0, 0); 45 | // step 5 46 | document.close(); 47 | } 48 | 49 | /** 50 | * Main method. 51 | * @param args no arguments needed 52 | * @throws DocumentException 53 | * @throws IOException 54 | */ 55 | public static void main(String[] args) 56 | throws IOException, DocumentException { 57 | new Hero3().createPdf(RESULT); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/part1/chapter05/NewPage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part1.chapter05; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import com.itextpdf.text.Document; 14 | import com.itextpdf.text.DocumentException; 15 | import com.itextpdf.text.Paragraph; 16 | import com.itextpdf.text.pdf.PdfWriter; 17 | 18 | public class NewPage { 19 | 20 | /** Path to the resulting PDF file. */ 21 | public static final String RESULT 22 | = "results/part1/chapter05/new_page.pdf"; 23 | 24 | /** 25 | * Main method creating the PDF. 26 | * @param args no arguments needed 27 | * @throws IOException 28 | * @throws DocumentException 29 | */ 30 | public static void main(String[] args) throws IOException, DocumentException { 31 | // step 1 32 | Document document = new Document(); 33 | // step 2 34 | PdfWriter writer 35 | = PdfWriter.getInstance(document, new FileOutputStream(RESULT)); 36 | // step 3 37 | document.open(); 38 | // step 4 39 | document.add(new Paragraph("This page will NOT be followed by a blank page!")); 40 | document.newPage(); 41 | // we don't add anything to this page: newPage() will be ignored 42 | document.newPage(); 43 | document.add(new Paragraph("This page will be followed by a blank page!")); 44 | document.newPage(); 45 | writer.setPageEmpty(false); 46 | document.newPage(); 47 | document.add(new Paragraph("The previous page was a blank page!")); 48 | // step 5 49 | document.close(); 50 | 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/part2/chapter06/Burst.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part2.chapter06; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import part1.chapter03.MovieTemplates; 14 | 15 | import com.itextpdf.text.Document; 16 | import com.itextpdf.text.DocumentException; 17 | import com.itextpdf.text.pdf.PdfCopy; 18 | import com.itextpdf.text.pdf.PdfReader; 19 | 20 | public class Burst { 21 | 22 | /** Format of the resulting PDF files. */ 23 | public static final String RESULT 24 | = "results/part2/chapter06/timetable_p%d.pdf"; 25 | 26 | /** 27 | * Main method. 28 | * @param args no arguments needed 29 | * @throws DocumentException 30 | * @throws IOException 31 | */ 32 | public static void main(String[] args) 33 | throws IOException, DocumentException { 34 | // use one of the previous examples to create a PDF 35 | new MovieTemplates().createPdf(MovieTemplates.RESULT); 36 | // Create a reader 37 | PdfReader reader = new PdfReader(MovieTemplates.RESULT); 38 | // We'll create as many new PDFs as there are pages 39 | Document document; 40 | PdfCopy copy; 41 | // loop over all the pages in the original PDF 42 | int n = reader.getNumberOfPages(); 43 | for (int i = 0; i < n; ) { 44 | // step 1 45 | document = new Document(); 46 | // step 2 47 | copy = new PdfCopy(document, 48 | new FileOutputStream(String.format(RESULT, ++i))); 49 | // step 3 50 | document.open(); 51 | // step 4 52 | copy.addPage(copy.getImportedPage(reader, i)); 53 | // step 5 54 | document.close(); 55 | } 56 | reader.close(); 57 | } 58 | 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/part2/chapter06/Concatenate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part2.chapter06; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | import java.sql.SQLException; 13 | 14 | import com.itextpdf.text.Document; 15 | import com.itextpdf.text.DocumentException; 16 | import com.itextpdf.text.pdf.PdfCopy; 17 | import com.itextpdf.text.pdf.PdfReader; 18 | 19 | import part1.chapter02.MovieHistory; 20 | import part1.chapter02.MovieLinks1; 21 | 22 | public class Concatenate { 23 | 24 | /** The resulting PDF file. */ 25 | public static final String RESULT 26 | = "results/part2/chapter06/concatenated.pdf"; 27 | 28 | /** 29 | * Main method. 30 | * @param args no arguments needed 31 | * @throws DocumentException 32 | * @throws IOException 33 | * @throws SQLException 34 | */ 35 | public static void main(String[] args) 36 | throws IOException, DocumentException, SQLException { 37 | // using previous examples to create PDFs 38 | MovieLinks1.main(args); 39 | MovieHistory.main(args); 40 | String[] files = { MovieLinks1.RESULT, MovieHistory.RESULT }; 41 | // step 1 42 | Document document = new Document(); 43 | // step 2 44 | PdfCopy copy = new PdfCopy(document, new FileOutputStream(RESULT)); 45 | // step 3 46 | document.open(); 47 | // step 4 48 | PdfReader reader; 49 | int n; 50 | // loop over the documents you want to concatenate 51 | for (int i = 0; i < files.length; i++) { 52 | reader = new PdfReader(files[i]); 53 | // loop over the pages in that document 54 | n = reader.getNumberOfPages(); 55 | for (int page = 0; page < n; ) { 56 | copy.addPage(copy.getImportedPage(reader, ++page)); 57 | } 58 | copy.freeReader(reader); 59 | reader.close(); 60 | } 61 | // step 5 62 | document.close(); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/part2/chapter06/ConcatenateForms1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part2.chapter06; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import com.itextpdf.text.DocumentException; 14 | import com.itextpdf.text.pdf.PdfCopyFields; 15 | import com.itextpdf.text.pdf.PdfReader; 16 | 17 | public class ConcatenateForms1 { 18 | 19 | /** The original PDF file. */ 20 | public static final String DATASHEET 21 | = "resources/pdfs/datasheet.pdf"; 22 | /** The resulting PDF file. */ 23 | public static final String RESULT 24 | = "results/part2/chapter06/concatenated_forms1.pdf"; 25 | 26 | /** 27 | * Main method. 28 | * @param args no arguments needed 29 | * @throws DocumentException 30 | * @throws IOException 31 | */ 32 | public static void main(String[] args) 33 | throws IOException, DocumentException { 34 | // Create a PdfCopyFields object 35 | PdfCopyFields copy 36 | = new PdfCopyFields(new FileOutputStream(RESULT)); 37 | // add a document 38 | PdfReader reader1 = new PdfReader(DATASHEET); 39 | copy.addDocument(reader1); 40 | // add a document 41 | PdfReader reader2 = new PdfReader(DATASHEET); 42 | copy.addDocument(reader2); 43 | // close the PdfCopyFields object 44 | copy.close(); 45 | reader1.close(); 46 | reader2.close(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/part2/chapter06/DataSheets2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part2.chapter06; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | import java.sql.SQLException; 13 | 14 | import com.itextpdf.text.Document; 15 | import com.itextpdf.text.DocumentException; 16 | import com.itextpdf.text.pdf.PdfSmartCopy; 17 | 18 | public class DataSheets2 extends DataSheets1 { 19 | 20 | /** The resulting PDF file. */ 21 | public static final String RESULT 22 | = "results/part2/chapter06/datasheets2.pdf"; 23 | 24 | /** 25 | * Main method. 26 | * @param args no arguments needed 27 | * @throws DocumentException 28 | * @throws IOException 29 | * @throws SQLException 30 | */ 31 | public static void main(String[] args) 32 | throws IOException, SQLException, DocumentException { 33 | new DataSheets2().createPdf(RESULT); 34 | } 35 | 36 | /** 37 | * Creates a PDF document. 38 | * @param filename the path to the new PDF document 39 | * @throws DocumentException 40 | * @throws IOException 41 | * @throws SQLException 42 | */ 43 | public void createPdf(String filename) 44 | throws IOException, DocumentException, SQLException { 45 | // step 1 46 | Document document = new Document(); 47 | // step 2 48 | PdfSmartCopy copy 49 | = new PdfSmartCopy(document, new FileOutputStream(filename)); 50 | // step 3 51 | document.open(); 52 | // step 4 53 | addDataSheets(copy); 54 | // step 5 55 | document.close(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/part2/chapter06/ImportingPages1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part2.chapter06; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import part1.chapter03.MovieTemplates; 14 | 15 | import com.itextpdf.text.Document; 16 | import com.itextpdf.text.DocumentException; 17 | import com.itextpdf.text.Image; 18 | import com.itextpdf.text.pdf.PdfImportedPage; 19 | import com.itextpdf.text.pdf.PdfPTable; 20 | import com.itextpdf.text.pdf.PdfReader; 21 | import com.itextpdf.text.pdf.PdfWriter; 22 | 23 | public class ImportingPages1 { 24 | 25 | /** The resulting PDF file. */ 26 | public static final String RESULT 27 | = "results/part2/chapter06/time_table_imported1.pdf"; 28 | 29 | /** 30 | * Main method. 31 | * @param args no arguments needed 32 | * @throws DocumentException 33 | * @throws IOException 34 | */ 35 | public static void main(String[] args) 36 | throws IOException, DocumentException { 37 | // Use old example to create PDF 38 | new MovieTemplates().createPdf(MovieTemplates.RESULT); 39 | // step 1 40 | Document document = new Document(); 41 | // step 2 42 | PdfWriter writer 43 | = PdfWriter.getInstance(document, new FileOutputStream(RESULT)); 44 | // step 3 45 | document.open(); 46 | // step 4 47 | PdfPTable table = new PdfPTable(2); 48 | PdfReader reader = new PdfReader(MovieTemplates.RESULT); 49 | int n = reader.getNumberOfPages(); 50 | PdfImportedPage page; 51 | for (int i = 1; i <= n; i++) { 52 | page = writer.getImportedPage(reader, i); 53 | table.addCell(Image.getInstance(page)); 54 | } 55 | document.add(table); 56 | // step 5 57 | document.close(); 58 | reader.close(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/part2/chapter06/ImportingPages2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part2.chapter06; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import part1.chapter03.MovieTemplates; 14 | 15 | import com.itextpdf.text.Document; 16 | import com.itextpdf.text.DocumentException; 17 | import com.itextpdf.text.Image; 18 | import com.itextpdf.text.pdf.PdfImportedPage; 19 | import com.itextpdf.text.pdf.PdfPTable; 20 | import com.itextpdf.text.pdf.PdfReader; 21 | import com.itextpdf.text.pdf.PdfWriter; 22 | 23 | public class ImportingPages2 { 24 | 25 | /** The resulting PDF file. */ 26 | public static final String RESULT 27 | = "results/part2/chapter06/time_table_imported2.pdf"; 28 | 29 | /** 30 | * Main method. 31 | * @param args no arguments needed 32 | * @throws DocumentException 33 | * @throws IOException 34 | */ 35 | public static void main(String[] args) 36 | throws IOException, DocumentException { 37 | // use old example to create PDF 38 | new MovieTemplates().createPdf(MovieTemplates.RESULT); 39 | // step 1 40 | Document document = new Document(); 41 | // step 2 42 | PdfWriter writer 43 | = PdfWriter.getInstance(document, new FileOutputStream(RESULT)); 44 | // step 3 45 | document.open(); 46 | // step 4 47 | PdfReader reader = new PdfReader(MovieTemplates.RESULT); 48 | int n = reader.getNumberOfPages(); 49 | PdfImportedPage page; 50 | PdfPTable table = new PdfPTable(2); 51 | for (int i = 1; i <= n; i++) { 52 | page = writer.getImportedPage(reader, i); 53 | table.getDefaultCell().setRotation(-page.getRotation()); 54 | table.addCell(Image.getInstance(page)); 55 | } 56 | document.add(table); 57 | // step 5 58 | document.close(); 59 | reader.close(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/part2/chapter07/AddVersionChecker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part2.chapter07; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | import java.sql.SQLException; 13 | 14 | import part1.chapter01.HelloWorld; 15 | 16 | import com.itextpdf.text.DocumentException; 17 | import com.itextpdf.text.Utilities; 18 | import com.itextpdf.text.pdf.PdfReader; 19 | import com.itextpdf.text.pdf.PdfStamper; 20 | 21 | public class AddVersionChecker { 22 | 23 | /** The resulting PDF file. */ 24 | public static final String RESULT 25 | = "results/part2/chapter07/version_checker.pdf"; 26 | /** Path to a resource. */ 27 | public static final String RESOURCE 28 | = "resources/js/viewer_version.js"; 29 | 30 | /** 31 | * Main method. 32 | * 33 | * @param args no arguments needed 34 | * @throws DocumentException 35 | * @throws IOException 36 | * @throws SQLException 37 | */ 38 | public static void main(String[] args) 39 | throws IOException, DocumentException, SQLException { 40 | // Use a previous example to create a PDF 41 | HelloWorld.main(args); 42 | // Create a reader 43 | PdfReader reader = new PdfReader(HelloWorld.RESULT); 44 | // Create a stamper 45 | PdfStamper stamper 46 | = new PdfStamper(reader, new FileOutputStream(RESULT)); 47 | // Add some javascript 48 | stamper.addJavaScript(Utilities.readFileToString(RESOURCE)); 49 | // Close the stamper 50 | stamper.close(); 51 | reader.close(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/part2/chapter07/LaunchAction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part2.chapter07; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import com.itextpdf.text.Chunk; 14 | import com.itextpdf.text.Document; 15 | import com.itextpdf.text.DocumentException; 16 | import com.itextpdf.text.Paragraph; 17 | import com.itextpdf.text.pdf.PdfAction; 18 | import com.itextpdf.text.pdf.PdfWriter; 19 | 20 | public class LaunchAction { 21 | /** The resulting PDF file. */ 22 | public static final String RESULT 23 | = "results/part2/chapter07/launch_action.pdf"; 24 | 25 | /** 26 | * Creates a PDF document. 27 | * @param filename the path to the new PDF document 28 | * @throws DocumentException 29 | * @throws IOException 30 | */ 31 | public void createPdf(String filename) 32 | throws IOException, DocumentException { 33 | // step 1 34 | Document document = new Document(); 35 | // step 2 36 | PdfWriter.getInstance(document, new FileOutputStream(filename)); 37 | // step 3 38 | document.open(); 39 | // step 4 40 | Paragraph p = new Paragraph(new Chunk( 41 | "Click to open test.txt in Notepad.") 42 | .setAction(new PdfAction("c:/windows/notepad.exe", 43 | "test.txt", "open", "C:\\itext-core\\book\\resources\\txt"))); 44 | document.add(p); 45 | // step 5 46 | document.close(); 47 | } 48 | 49 | /** 50 | * Main method. 51 | * @param args no arguments needed 52 | * @throws DocumentException 53 | * @throws IOException 54 | */ 55 | public static void main(String[] args) 56 | throws IOException, DocumentException { 57 | new LaunchAction().createPdf(RESULT); 58 | } 59 | } -------------------------------------------------------------------------------- /src/part2/chapter08/ChildFieldEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part2.chapter08; 9 | 10 | import com.itextpdf.text.ExceptionConverter; 11 | import com.itextpdf.text.Rectangle; 12 | import com.itextpdf.text.pdf.PdfAnnotation; 13 | import com.itextpdf.text.pdf.PdfContentByte; 14 | import com.itextpdf.text.pdf.PdfFormField; 15 | import com.itextpdf.text.pdf.PdfPCell; 16 | import com.itextpdf.text.pdf.PdfPCellEvent; 17 | 18 | public class ChildFieldEvent implements PdfPCellEvent { 19 | 20 | /** A parent field to which a child field has to be added. */ 21 | protected PdfFormField parent; 22 | /** The child field that has to be added */ 23 | protected PdfFormField kid; 24 | /** The padding of the field inside the cell */ 25 | protected float padding; 26 | 27 | /** 28 | * Creates a ChildFieldEvent. 29 | * @param parent the parent field 30 | * @param kid the child field 31 | * @param padding a padding 32 | */ 33 | public ChildFieldEvent(PdfFormField parent, PdfFormField kid, float padding) { 34 | this.parent = parent; 35 | this.kid = kid; 36 | this.padding = padding; 37 | } 38 | 39 | /** 40 | * Add the child field to the parent, and sets the coordinates of the child field. 41 | * @see com.lowagie.text.pdf.PdfPCellEvent#cellLayout(com.lowagie.text.pdf.PdfPCell, 42 | * com.lowagie.text.Rectangle, com.lowagie.text.pdf.PdfContentByte[]) 43 | */ 44 | public void cellLayout(PdfPCell cell, Rectangle rect, PdfContentByte[] cb) { 45 | try { 46 | parent.addKid(kid); 47 | kid.setWidget(new Rectangle(rect.getLeft(padding), rect.getBottom(padding), 48 | rect.getRight(padding), rect.getTop(padding)), 49 | PdfAnnotation.HIGHLIGHT_INVERT); 50 | } catch (Exception e) { 51 | throw new ExceptionConverter(e); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/part2/chapter08/ReplaceIcon.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part2.chapter08; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | import java.sql.SQLException; 13 | 14 | import com.itextpdf.text.DocumentException; 15 | import com.itextpdf.text.Image; 16 | import com.itextpdf.text.pdf.AcroFields; 17 | import com.itextpdf.text.pdf.PdfReader; 18 | import com.itextpdf.text.pdf.PdfStamper; 19 | import com.itextpdf.text.pdf.PushbuttonField; 20 | 21 | import part2.chapter07.Advertisement; 22 | 23 | public class ReplaceIcon { 24 | 25 | /** Image that will be used as an icon. */ 26 | public static final String RESOURCE = "resources/img/iia2.jpg"; 27 | /** The resulting PDF. */ 28 | public static final String RESULT = "results/part2/chapter08/advertisement2.pdf"; 29 | 30 | /** 31 | * Manipulates a PDF file src with the file dest as result 32 | * @param src the original PDF 33 | * @param dest the resulting PDF 34 | * @throws IOException 35 | * @throws DocumentException 36 | */ 37 | public void manipulatePdf(String src, String dest) throws IOException, DocumentException { 38 | PdfReader reader = new PdfReader(src); 39 | PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest)); 40 | AcroFields form = stamper.getAcroFields(); 41 | PushbuttonField ad = form.getNewPushbuttonFromField("advertisement"); 42 | ad.setLayout(PushbuttonField.LAYOUT_ICON_ONLY); 43 | ad.setProportionalIcon(true); 44 | ad.setImage(Image.getInstance(RESOURCE)); 45 | form.replacePushbuttonField("advertisement", ad.getField()); 46 | stamper.close(); 47 | reader.close(); 48 | } 49 | 50 | /** 51 | * Main method 52 | * @param args no arguments needed 53 | * @throws SQLException 54 | * @throws DocumentException 55 | * @throws IOException 56 | */ 57 | public static void main(String[] args) throws SQLException, DocumentException, IOException { 58 | Advertisement.main(args); 59 | new ReplaceIcon().manipulatePdf(Advertisement.RESULT, RESULT); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/part3/chapter09/CreateFDF.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part3.chapter09; 9 | 10 | import java.io.IOException; 11 | import javax.servlet.ServletException; 12 | import javax.servlet.http.HttpServlet; 13 | import javax.servlet.http.HttpServletRequest; 14 | import javax.servlet.http.HttpServletResponse; 15 | 16 | import com.itextpdf.text.pdf.FdfWriter; 17 | 18 | public class CreateFDF extends HttpServlet { 19 | 20 | /** 21 | * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response) 22 | */ 23 | protected void service(HttpServletRequest request, HttpServletResponse response) 24 | throws ServletException, IOException { 25 | response.setContentType("application/vnd.adobe.fdf"); 26 | response.setHeader("Content-Disposition", 27 | "attachment; filename=\"subscribe.fdf\""); 28 | FdfWriter fdf = new FdfWriter(); 29 | fdf.setFieldAsString("personal.name", request.getParameter("name")); 30 | fdf.setFieldAsString("personal.loginname", request.getParameter("loginname")); 31 | fdf.setFieldAsString("personal.password", request.getParameter("password")); 32 | fdf.setFieldAsString("personal.reason", request.getParameter("reason")); 33 | fdf.setFile("subscribe.pdf"); 34 | fdf.writeTo(response.getOutputStream()); 35 | } 36 | 37 | /** 38 | * Serial version UID 39 | */ 40 | private static final long serialVersionUID = 4841218549441233308L; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/part3/chapter09/Hello.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part3.chapter09; 9 | 10 | import java.io.IOException; 11 | import java.util.Date; 12 | 13 | import javax.servlet.ServletException; 14 | import javax.servlet.http.HttpServlet; 15 | import javax.servlet.http.HttpServletRequest; 16 | import javax.servlet.http.HttpServletResponse; 17 | 18 | import com.itextpdf.text.Document; 19 | import com.itextpdf.text.DocumentException; 20 | import com.itextpdf.text.Paragraph; 21 | import com.itextpdf.text.pdf.PdfWriter; 22 | 23 | public class Hello extends HttpServlet { 24 | 25 | /** 26 | * A simple Hello World Servlet. 27 | * @see HttpServlet#doGet( 28 | * HttpServletRequest request, HttpServletResponse response) 29 | */ 30 | protected void doGet(HttpServletRequest request, HttpServletResponse response) 31 | throws ServletException, IOException { 32 | response.setContentType("application/pdf"); 33 | try { 34 | // step 1 35 | Document document = new Document(); 36 | // step 2 37 | PdfWriter.getInstance(document, response.getOutputStream()); 38 | // step 3 39 | document.open(); 40 | // step 4 41 | document.add(new Paragraph("Hello World")); 42 | document.add(new Paragraph(new Date().toString())); 43 | // step 5 44 | document.close(); 45 | } catch (DocumentException de) { 46 | throw new IOException(de.getMessage()); 47 | } 48 | } 49 | 50 | /** 51 | * A serial version uid 52 | */ 53 | private static final long serialVersionUID = 4262544639420765610L; 54 | } 55 | -------------------------------------------------------------------------------- /src/part3/chapter09/MovieServlet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part3.chapter09; 9 | 10 | import java.io.IOException; 11 | import java.io.InputStream; 12 | 13 | import javax.servlet.ServletException; 14 | import javax.servlet.http.HttpServlet; 15 | import javax.servlet.http.HttpServletRequest; 16 | import javax.servlet.http.HttpServletResponse; 17 | import javax.xml.parsers.ParserConfigurationException; 18 | import javax.xml.parsers.SAXParser; 19 | import javax.xml.parsers.SAXParserFactory; 20 | 21 | import org.xml.sax.InputSource; 22 | import org.xml.sax.SAXException; 23 | 24 | import com.itextpdf.text.Document; 25 | import com.itextpdf.text.DocumentException; 26 | import com.itextpdf.text.pdf.PdfWriter; 27 | 28 | public class MovieServlet extends HttpServlet { 29 | 30 | /** 31 | * Reads an XML file and serves it as PDF to the browser. 32 | * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) 33 | */ 34 | protected void doGet(HttpServletRequest request, HttpServletResponse response) 35 | throws ServletException, IOException { 36 | try { 37 | // step 1 38 | Document document = new Document(); 39 | // step 2 40 | PdfWriter.getInstance(document, response.getOutputStream()); 41 | // step 3 42 | document.open(); 43 | // step 4 44 | InputStream is 45 | = getServletContext().getResourceAsStream("/movies.xml"); 46 | SAXParser parser = SAXParserFactory.newInstance().newSAXParser(); 47 | parser.parse(new InputSource(is), new XmlHandler(document)); 48 | // step 5 49 | document.close(); 50 | } catch (DocumentException e) { 51 | throw new IOException(e.getMessage()); 52 | } catch (ParserConfigurationException e) { 53 | throw new IOException(e.getMessage()); 54 | } catch (SAXException e) { 55 | throw new IOException(e.getMessage()); 56 | } 57 | } 58 | 59 | /** 60 | * Serial version UID 61 | */ 62 | private static final long serialVersionUID = -6015985931115167175L; 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/part3/chapter10/ClippingPath.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part3.chapter10; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import com.itextpdf.text.Document; 14 | import com.itextpdf.text.DocumentException; 15 | import com.itextpdf.text.Image; 16 | import com.itextpdf.text.pdf.PdfTemplate; 17 | import com.itextpdf.text.pdf.PdfWriter; 18 | 19 | public class ClippingPath { 20 | 21 | /** The resulting PDF file. */ 22 | public static final String RESULT 23 | = "results/part3/chapter10/clipping_path.pdf"; 24 | /** One of the resources. */ 25 | public static final String RESOURCE 26 | = "resources/img/bruno_ingeborg.jpg"; 27 | 28 | /** 29 | * Creates a PDF document. 30 | * @param filename the path to the new PDF document 31 | * @throws DocumentException 32 | * @throws IOException 33 | */ 34 | public void createPdf(String filename) throws IOException, DocumentException { 35 | // step 1 36 | Document document = new Document(); 37 | // step 2 38 | PdfWriter writer 39 | = PdfWriter.getInstance(document, new FileOutputStream(filename)); 40 | // step 3 41 | document.open(); 42 | // step 4 43 | Image img = Image.getInstance(RESOURCE); 44 | float w = img.getScaledWidth(); 45 | float h = img.getScaledHeight(); 46 | PdfTemplate t = writer.getDirectContent().createTemplate(850, 600); 47 | t.ellipse(0, 0, 850, 600); 48 | t.clip(); 49 | t.newPath(); 50 | t.addImage(img, w, 0, 0, h, 0, -600); 51 | Image clipped = Image.getInstance(t); 52 | clipped.scalePercent(50); 53 | document.add(clipped); 54 | // step 5 55 | document.close(); 56 | } 57 | 58 | /** 59 | * Main method. 60 | * 61 | * @param args no arguments needed 62 | * @throws DocumentException 63 | * @throws IOException 64 | * @throws DocumentException 65 | * @throws IOException 66 | */ 67 | public static void main(String[] args) throws IOException, DocumentException { 68 | new ClippingPath().createPdf(RESULT); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/part3/chapter10/CompressImage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part3.chapter10; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import com.itextpdf.text.Document; 14 | import com.itextpdf.text.DocumentException; 15 | import com.itextpdf.text.Image; 16 | import com.itextpdf.text.pdf.PdfWriter; 17 | 18 | public class CompressImage { 19 | 20 | /** The resulting PDF file. */ 21 | public static final String RESULT1 22 | = "results/part3/chapter10/uncompressed.pdf"; 23 | /** The resulting PDF file. */ 24 | public static final String RESULT2 25 | = "results/part3/chapter10/compressed.pdf"; 26 | /** One of the resources. */ 27 | public static final String RESOURCE 28 | = "resources/img/butterfly.bmp"; 29 | 30 | /** 31 | * Creates a PDF document. 32 | * @param filename the path to the new PDF document 33 | * @throws DocumentException 34 | * @throws IOException 35 | */ 36 | public void createPdf(String filename, boolean compress) throws IOException, DocumentException { 37 | // step 1 38 | Document document = new Document(); 39 | // step 2 40 | PdfWriter.getInstance(document, new FileOutputStream(filename)); 41 | // step 3 42 | document.open(); 43 | // step 4 44 | Image img = Image.getInstance(RESOURCE); 45 | if (compress) 46 | img.setCompressionLevel(9); 47 | document.add(img); 48 | // step 5 49 | document.close(); 50 | } 51 | 52 | /** 53 | * Main method. 54 | * 55 | * @param args no arguments needed 56 | * @throws DocumentException 57 | * @throws IOException 58 | * @throws DocumentException 59 | * @throws IOException 60 | */ 61 | public static void main(String[] args) throws IOException, DocumentException { 62 | new CompressImage().createPdf(RESULT1, false); 63 | new CompressImage().createPdf(RESULT2, true); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/part3/chapter10/TemplateClip.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part3.chapter10; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import com.itextpdf.text.Document; 14 | import com.itextpdf.text.DocumentException; 15 | import com.itextpdf.text.Image; 16 | import com.itextpdf.text.pdf.PdfTemplate; 17 | import com.itextpdf.text.pdf.PdfWriter; 18 | 19 | public class TemplateClip { 20 | 21 | /** The resulting PDF file. */ 22 | public static final String RESULT 23 | = "results/part3/chapter10/template_clip.pdf"; 24 | /** One of the resources. */ 25 | public static final String RESOURCE 26 | = "resources/img/bruno_ingeborg.jpg"; 27 | 28 | /** 29 | * Creates a PDF document. 30 | * @param filename the path to the new PDF document 31 | * @throws DocumentException 32 | * @throws IOException 33 | */ 34 | public void createPdf(String filename) throws IOException, DocumentException { 35 | // step 1 36 | Document document = new Document(); 37 | // step 2 38 | PdfWriter writer 39 | = PdfWriter.getInstance(document, new FileOutputStream(filename)); 40 | // step 3 41 | document.open(); 42 | // step 4 43 | Image img = Image.getInstance(RESOURCE); 44 | float w = img.getScaledWidth(); 45 | float h = img.getScaledHeight(); 46 | PdfTemplate t = writer.getDirectContent().createTemplate(850, 600); 47 | t.addImage(img, w, 0, 0, h, 0, -600); 48 | Image clipped = Image.getInstance(t); 49 | clipped.scalePercent(50); 50 | document.add(clipped); 51 | // step 5 52 | document.close(); 53 | } 54 | 55 | /** 56 | * Main method. 57 | * 58 | * @param args no arguments needed 59 | * @throws DocumentException 60 | * @throws IOException 61 | * @throws DocumentException 62 | * @throws IOException 63 | */ 64 | public static void main(String[] args) throws IOException, DocumentException { 65 | new TemplateClip().createPdf(RESULT); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/part3/chapter12/SignWithBC.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | package part3.chapter12; 8 | 9 | public class SignWithBC { 10 | 11 | /** 12 | * Main method. 13 | * 14 | * @param args no arguments needed 15 | */ 16 | public static void main(String[] args) { 17 | System.out.println("This example is no longer relevant."); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/part4/chapter13/AppendMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part4.chapter13; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import part1.chapter01.HelloWorld; 14 | 15 | import com.itextpdf.text.DocumentException; 16 | import com.itextpdf.text.Element; 17 | import com.itextpdf.text.pdf.BaseFont; 18 | import com.itextpdf.text.pdf.PdfContentByte; 19 | import com.itextpdf.text.pdf.PdfReader; 20 | import com.itextpdf.text.pdf.PdfStamper; 21 | 22 | public class AppendMode { 23 | /** The resulting PDF. */ 24 | public static final String RESULT 25 | = "results/part4/chapter13/appended.pdf"; 26 | 27 | /** 28 | * Manipulates a PDF file src with the file dest as result 29 | * @param src the original PDF 30 | * @param dest the resulting PDF 31 | * @throws IOException 32 | * @throws DocumentException 33 | */ 34 | public void manipulatePdf(String src, String dest) throws IOException, DocumentException { 35 | PdfReader reader = new PdfReader(src); 36 | PdfStamper stamper = 37 | new PdfStamper(reader, new FileOutputStream(dest), '\0', true); 38 | PdfContentByte cb = stamper.getUnderContent(1); 39 | cb.beginText(); 40 | cb.setFontAndSize(BaseFont.createFont(), 12); 41 | cb.showTextAligned(Element.ALIGN_LEFT, "Hello People!", 36, 770, 0); 42 | cb.endText(); 43 | stamper.close(); 44 | reader.close(); 45 | } 46 | 47 | /** 48 | * Main method. 49 | * 50 | * @param args no arguments needed 51 | * @throws DocumentException 52 | * @throws IOException 53 | */ 54 | public static void main(String[] args) throws IOException, DocumentException { 55 | new HelloWorld().createPdf(HelloWorld.RESULT); 56 | new AppendMode().manipulatePdf(HelloWorld.RESULT, RESULT); 57 | } 58 | } -------------------------------------------------------------------------------- /src/part4/chapter13/CropPages.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part4.chapter13; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import part1.chapter03.MovieTemplates; 14 | 15 | import com.itextpdf.text.DocumentException; 16 | import com.itextpdf.text.pdf.PdfDictionary; 17 | import com.itextpdf.text.pdf.PdfName; 18 | import com.itextpdf.text.pdf.PdfReader; 19 | import com.itextpdf.text.pdf.PdfRectangle; 20 | import com.itextpdf.text.pdf.PdfStamper; 21 | 22 | public class CropPages { 23 | 24 | /** The resulting PDF. */ 25 | public static final String RESULT 26 | = "results/part4/chapter13/timetable_cropped.pdf"; 27 | 28 | /** 29 | * Manipulates a PDF file src with the file dest as result 30 | * @param src the original PDF 31 | * @param dest the resulting PDF 32 | * @throws IOException 33 | * @throws DocumentException 34 | */ 35 | public void manipulatePdf(String src, String dest) 36 | throws IOException, DocumentException { 37 | PdfReader reader = new PdfReader(src); 38 | int n = reader.getNumberOfPages(); 39 | PdfDictionary pageDict; 40 | PdfRectangle rect = new PdfRectangle(55, 76, 560, 816); 41 | for (int i = 1; i <= n; i++) { 42 | pageDict = reader.getPageN(i); 43 | pageDict.put(PdfName.CROPBOX, rect); 44 | } 45 | PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest)); 46 | stamper.close(); 47 | reader.close(); 48 | } 49 | 50 | /** 51 | * Main method. 52 | * 53 | * @param args no arguments needed 54 | * @throws DocumentException 55 | * @throws IOException 56 | */ 57 | public static void main(String[] args) throws IOException, DocumentException { 58 | new MovieTemplates().createPdf(MovieTemplates.RESULT); 59 | new CropPages().manipulatePdf(MovieTemplates.RESULT, RESULT); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/part4/chapter13/PrintPreferencesExample.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | package part4.chapter13; 8 | 9 | import java.io.FileOutputStream; 10 | import java.io.IOException; 11 | 12 | import com.itextpdf.text.Document; 13 | import com.itextpdf.text.DocumentException; 14 | import com.itextpdf.text.Paragraph; 15 | import com.itextpdf.text.pdf.PdfBoolean; 16 | import com.itextpdf.text.pdf.PdfName; 17 | import com.itextpdf.text.pdf.PdfNumber; 18 | import com.itextpdf.text.pdf.PdfWriter; 19 | 20 | public class PrintPreferencesExample { 21 | 22 | /** The resulting PDF file. */ 23 | public static final String RESULT 24 | = "results/part4/chapter13/printpreferences.pdf"; 25 | 26 | /** 27 | * Creates a PDF with information about the movies 28 | * @param filename the name of the PDF file that will be created. 29 | * @param pagelayout the value for the viewerpreferences 30 | * @throws DocumentException 31 | * @throws IOException 32 | */ 33 | public void createPdf(String filename) 34 | throws IOException, DocumentException { 35 | // step 1 36 | Document document = new Document(); 37 | // step 2 38 | PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename)); 39 | writer.setPdfVersion(PdfWriter.VERSION_1_5); 40 | writer.addViewerPreference(PdfName.PRINTSCALING, PdfName.NONE); 41 | writer.addViewerPreference(PdfName.NUMCOPIES, new PdfNumber(3)); 42 | writer.addViewerPreference(PdfName.PICKTRAYBYPDFSIZE, PdfBoolean.PDFTRUE); 43 | // step 3 44 | document.open(); 45 | // step 4 46 | document.add(new Paragraph("Hello World")); 47 | // step 5 48 | document.close(); 49 | } 50 | /** 51 | * Main method. 52 | * 53 | * @param args no arguments needed 54 | * @throws DocumentException 55 | * @throws IOException 56 | */ 57 | public static void main(String[] args) 58 | throws IOException, DocumentException { 59 | new PrintPreferencesExample().createPdf(RESULT); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/part4/chapter13/RotatePages.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part4.chapter13; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import part1.chapter03.MovieTemplates; 14 | 15 | import com.itextpdf.text.DocumentException; 16 | import com.itextpdf.text.pdf.PdfDictionary; 17 | import com.itextpdf.text.pdf.PdfName; 18 | import com.itextpdf.text.pdf.PdfNumber; 19 | import com.itextpdf.text.pdf.PdfReader; 20 | import com.itextpdf.text.pdf.PdfStamper; 21 | 22 | public class RotatePages { 23 | 24 | /** The resulting PDF. */ 25 | public static final String RESULT 26 | = "results/part4/chapter13/timetable_rotated.pdf"; 27 | 28 | /** 29 | * Manipulates a PDF file src with the file dest as result 30 | * @param src the original PDF 31 | * @param dest the resulting PDF 32 | * @throws IOException 33 | * @throws DocumentException 34 | */ 35 | public void manipulatePdf(String src, String dest) 36 | throws IOException, DocumentException { 37 | PdfReader reader = new PdfReader(MovieTemplates.RESULT); 38 | int n = reader.getNumberOfPages(); 39 | int rot; 40 | PdfDictionary pageDict; 41 | for (int i = 1; i <= n; i++) { 42 | rot = reader.getPageRotation(i); 43 | pageDict = reader.getPageN(i); 44 | pageDict.put(PdfName.ROTATE, new PdfNumber(rot + 90)); 45 | } 46 | PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(RESULT)); 47 | stamper.close(); 48 | reader.close(); 49 | } 50 | 51 | /** 52 | * Main method creating the PDF. 53 | * @param args no arguments needed 54 | * @throws DocumentException 55 | * @throws IOException 56 | */ 57 | public static void main(String[] args) 58 | throws IOException, DocumentException { 59 | new MovieTemplates().createPdf(MovieTemplates.RESULT); 60 | new RotatePages().manipulatePdf(MovieTemplates.RESULT, RESULT); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/part4/chapter14/GetContentStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part4.chapter14; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import part1.chapter01.HelloWorld; 14 | import part1.chapter05.Hero1; 15 | 16 | import com.itextpdf.text.DocumentException; 17 | import com.itextpdf.text.pdf.PdfReader; 18 | 19 | public class GetContentStream { 20 | /** The content stream of a first PDF. */ 21 | public static final String RESULT1 22 | = "results/part4/chapter14/contentstream1.txt"; 23 | /** The content stream of a second PDF. */ 24 | public static final String RESULT2 25 | = "results/part4/chapter14/contentstream2.txt"; 26 | 27 | /** 28 | * Reads the content stream of the first page of a PDF into a text file. 29 | * @param src the path to a PDF file 30 | * @param result the path to the resulting text file 31 | * @throws IOException 32 | */ 33 | public void readContent(String src, String result) throws IOException { 34 | PdfReader reader = new PdfReader(src); 35 | FileOutputStream out = new FileOutputStream(result); 36 | out.write(reader.getPageContent(1)); 37 | out.flush(); 38 | out.close(); 39 | reader.close(); 40 | } 41 | 42 | /** 43 | * Main method. 44 | * 45 | * @param args no arguments needed 46 | * @throws DocumentException 47 | * @throws IOException 48 | */ 49 | public static void main(String[] args) throws IOException, DocumentException { 50 | new HelloWorld().createPdf(HelloWorld.RESULT); 51 | new Hero1().createPdf(Hero1.RESULT); 52 | GetContentStream example = new GetContentStream(); 53 | example.readContent(HelloWorld.RESULT, RESULT1); 54 | example.readContent(Hero1.RESULT, RESULT2); 55 | } 56 | } -------------------------------------------------------------------------------- /src/part4/chapter14/PearToPdf.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | package part4.chapter14; 8 | 9 | import java.awt.Graphics2D; 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import com.itextpdf.awt.PdfGraphics2D; 14 | import com.itextpdf.text.Document; 15 | import com.itextpdf.text.DocumentException; 16 | import com.itextpdf.text.Rectangle; 17 | import com.itextpdf.text.pdf.PdfContentByte; 18 | import com.itextpdf.text.pdf.PdfWriter; 19 | 20 | public class PearToPdf { 21 | 22 | /** The resulting PDF. */ 23 | public static final String RESULT = "results/part4/chapter14/pear.pdf"; 24 | 25 | /** 26 | * Creates a PDF document. 27 | * @param filename the path to the new PDF document 28 | * @throws DocumentException 29 | * @throws IOException 30 | */ 31 | public void createPdf(String filename) throws IOException, DocumentException { 32 | // step 1 33 | Document document = new Document(new Rectangle(150, 150)); 34 | // step 2 35 | PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename)); 36 | // step 3 37 | document.open(); 38 | // step 4 39 | PdfContentByte canvas = writer.getDirectContent(); 40 | Graphics2D g2 = new PdfGraphics2D(canvas, 150, 150); 41 | PearExample pear = new PearExample(); 42 | pear.paint(g2); 43 | g2.dispose(); 44 | // step 5 45 | document.close(); 46 | } 47 | 48 | /** 49 | * Main method. 50 | * 51 | * @param args no arguments needed 52 | * @throws DocumentException 53 | * @throws IOException 54 | */ 55 | public static void main(String[] args) throws IOException, DocumentException { 56 | new PearToPdf().createPdf(RESULT); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/part4/chapter14/Text2ToPdf2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | package part4.chapter14; 8 | 9 | import java.awt.Dimension; 10 | import java.awt.Graphics2D; 11 | import java.io.FileOutputStream; 12 | import java.io.IOException; 13 | 14 | import com.itextpdf.awt.AsianFontMapper; 15 | import com.itextpdf.awt.PdfGraphics2D; 16 | import com.itextpdf.text.Document; 17 | import com.itextpdf.text.DocumentException; 18 | import com.itextpdf.text.Rectangle; 19 | import com.itextpdf.text.pdf.PdfContentByte; 20 | import com.itextpdf.text.pdf.PdfWriter; 21 | 22 | public class Text2ToPdf2 { 23 | /** The resulting PDF. */ 24 | public static final String RESULT = "results/part4/chapter14/text22.pdf"; 25 | 26 | /** 27 | * Creates a PDF document. 28 | * @param filename the path to the new PDF document 29 | * @throws DocumentException 30 | * @throws IOException 31 | */ 32 | public void createPdf(String filename) throws IOException, DocumentException { 33 | // step 1 34 | Document document = new Document(new Rectangle(300, 150)); 35 | // step 2 36 | PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename)); 37 | // step 3 38 | document.open(); 39 | // step 4 40 | PdfContentByte canvas = writer.getDirectContent(); 41 | Graphics2D g2 = new PdfGraphics2D(canvas, 300, 150, new AsianFontMapper( 42 | AsianFontMapper.JapaneseFont_Min, AsianFontMapper.JapaneseEncoding_H)); 43 | TextExample2 text = new TextExample2(); 44 | text.setSize(new Dimension(300, 150)); 45 | text.paint(g2); 46 | g2.dispose(); 47 | // step 5 48 | document.close(); 49 | } 50 | /** 51 | * Main method. 52 | * 53 | * @param args no arguments needed 54 | * @throws DocumentException 55 | * @throws IOException 56 | */ 57 | public static void main(String[] args) throws IOException, DocumentException { 58 | new Text2ToPdf2().createPdf(RESULT); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/part4/chapter14/Text2ToPdf3.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | package part4.chapter14; 8 | 9 | import java.awt.Dimension; 10 | import java.awt.Graphics2D; 11 | import java.io.FileOutputStream; 12 | import java.io.IOException; 13 | 14 | import com.itextpdf.awt.PdfGraphics2D; 15 | import com.itextpdf.text.Document; 16 | import com.itextpdf.text.DocumentException; 17 | import com.itextpdf.text.Rectangle; 18 | import com.itextpdf.text.pdf.PdfContentByte; 19 | import com.itextpdf.text.pdf.PdfWriter; 20 | 21 | public class Text2ToPdf3 { 22 | /** The resulting PDF. */ 23 | public static final String RESULT = "results/part4/chapter14/text23.pdf"; 24 | 25 | /** 26 | * Creates a PDF document. 27 | * @param filename the path to the new PDF document 28 | * @throws DocumentException 29 | * @throws IOException 30 | */ 31 | public void createPdf(String filename) throws IOException, DocumentException { 32 | // step 1 33 | Document document = new Document(new Rectangle(300, 150)); 34 | // step 2 35 | PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename)); 36 | // step 3 37 | document.open(); 38 | // step 4 39 | PdfContentByte canvas = writer.getDirectContent(); 40 | Graphics2D g2 = new PdfGraphics2D(canvas, 300, 150, true); 41 | TextExample2 text = new TextExample2(); 42 | text.setSize(new Dimension(300, 150)); 43 | text.paint(g2); 44 | g2.dispose(); 45 | // step 5 46 | document.close(); 47 | } 48 | /** 49 | * Main method. 50 | * 51 | * @param args no arguments needed 52 | * @throws DocumentException 53 | * @throws IOException 54 | */ 55 | public static void main(String[] args) throws IOException, DocumentException { 56 | new Text2ToPdf3().createPdf(RESULT); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/part4/chapter14/Text3ToPdf.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | package part4.chapter14; 8 | 9 | import java.awt.Dimension; 10 | import java.awt.Graphics2D; 11 | import java.io.FileOutputStream; 12 | import java.io.IOException; 13 | 14 | import com.itextpdf.awt.PdfGraphics2D; 15 | import com.itextpdf.text.Document; 16 | import com.itextpdf.text.DocumentException; 17 | import com.itextpdf.text.Rectangle; 18 | import com.itextpdf.text.pdf.PdfContentByte; 19 | import com.itextpdf.text.pdf.PdfWriter; 20 | 21 | public class Text3ToPdf { 22 | /** The resulting PDF. */ 23 | public static final String RESULT = "results/part4/chapter14/text3.pdf"; 24 | 25 | /** 26 | * Creates a PDF document. 27 | * @param filename the path to the new PDF document 28 | * @throws DocumentException 29 | * @throws IOException 30 | */ 31 | public void createPdf(String filename) throws IOException, DocumentException { 32 | // step 1 33 | Document document = new Document(new Rectangle(300, 150)); 34 | // step 2 35 | PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename)); 36 | // step 3 37 | document.open(); 38 | // step 4 39 | PdfContentByte canvas = writer.getDirectContent(); 40 | Graphics2D g2 = new PdfGraphics2D(canvas, 300, 150); 41 | TextExample3 text = new TextExample3(); 42 | text.setSize(new Dimension(300, 150)); 43 | text.paint(g2); 44 | g2.dispose(); 45 | // step 5 46 | document.close(); 47 | } 48 | /** 49 | * Main method. 50 | * 51 | * @param args no arguments needed 52 | * @throws DocumentException 53 | * @throws IOException 54 | */ 55 | public static void main(String[] args) throws IOException, DocumentException { 56 | new Text3ToPdf().createPdf(RESULT); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/part4/chapter15/ExtractImages.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part4.chapter15; 9 | 10 | import java.io.IOException; 11 | 12 | import part3.chapter10.ImageTypes; 13 | 14 | import com.itextpdf.text.DocumentException; 15 | import com.itextpdf.text.pdf.PdfReader; 16 | import com.itextpdf.text.pdf.parser.PdfReaderContentParser; 17 | 18 | /** 19 | * Extracts images from a PDF file. 20 | */ 21 | public class ExtractImages { 22 | 23 | /** The new document to which we've added a border rectangle. */ 24 | public static final String RESULT = "results/part4/chapter15/Img%s.%s"; 25 | 26 | /** 27 | * Parses a PDF and extracts all the images. 28 | * @param src the source PDF 29 | * @param dest the resulting PDF 30 | */ 31 | public void extractImages(String filename) 32 | throws IOException, DocumentException { 33 | PdfReader reader = new PdfReader(filename); 34 | PdfReaderContentParser parser = new PdfReaderContentParser(reader); 35 | MyImageRenderListener listener = new MyImageRenderListener(RESULT); 36 | for (int i = 1; i <= reader.getNumberOfPages(); i++) { 37 | parser.processContent(i, listener); 38 | } 39 | reader.close(); 40 | } 41 | 42 | /** 43 | * Main method. 44 | * @param args no arguments needed 45 | * @throws DocumentException 46 | * @throws IOException 47 | */ 48 | public static void main(String[] args) throws IOException, DocumentException { 49 | new ImageTypes().createPdf(ImageTypes.RESULT); 50 | new ExtractImages().extractImages(ImageTypes.RESULT); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/part4/chapter15/ExtractPageContent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part4.chapter15; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | import java.io.PrintWriter; 13 | 14 | import com.itextpdf.text.pdf.PdfReader; 15 | import com.itextpdf.text.pdf.parser.PdfReaderContentParser; 16 | import com.itextpdf.text.pdf.parser.SimpleTextExtractionStrategy; 17 | import com.itextpdf.text.pdf.parser.TextExtractionStrategy; 18 | 19 | public class ExtractPageContent { 20 | 21 | /** The original PDF that will be parsed. */ 22 | public static final String PREFACE = "resources/pdfs/preface.pdf"; 23 | /** The resulting text file. */ 24 | public static final String RESULT = "results/part4/chapter15/preface.txt"; 25 | 26 | /** 27 | * Parses a PDF to a plain text file. 28 | * @param pdf the original PDF 29 | * @param txt the resulting text 30 | * @throws IOException 31 | */ 32 | public void parsePdf(String pdf, String txt) throws IOException { 33 | PdfReader reader = new PdfReader(pdf); 34 | PdfReaderContentParser parser = new PdfReaderContentParser(reader); 35 | PrintWriter out = new PrintWriter(new FileOutputStream(txt)); 36 | TextExtractionStrategy strategy; 37 | for (int i = 1; i <= reader.getNumberOfPages(); i++) { 38 | strategy = parser.processContent(i, new SimpleTextExtractionStrategy()); 39 | out.println(strategy.getResultantText()); 40 | } 41 | out.flush(); 42 | out.close(); 43 | reader.close(); 44 | } 45 | 46 | /** 47 | * Main method. 48 | * @param args no arguments needed 49 | * @throws IOException 50 | */ 51 | public static void main(String[] args) throws IOException { 52 | new ExtractPageContent().parsePdf(PREFACE, RESULT); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/part4/chapter15/ExtractPageContentSorted1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part4.chapter15; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | import java.io.PrintWriter; 13 | 14 | import com.itextpdf.text.pdf.PdfReader; 15 | import com.itextpdf.text.pdf.parser.LocationTextExtractionStrategy; 16 | import com.itextpdf.text.pdf.parser.PdfReaderContentParser; 17 | import com.itextpdf.text.pdf.parser.TextExtractionStrategy; 18 | 19 | public class ExtractPageContentSorted1 { 20 | 21 | /** The original PDF that will be parsed. */ 22 | public static final String PREFACE = "resources/pdfs/preface.pdf"; 23 | /** The resulting text file. */ 24 | public static final String RESULT = "results/part4/chapter15/preface_sorted1.txt"; 25 | 26 | /** 27 | * Parses a PDF to a plain text file. 28 | * @param pdf the original PDF 29 | * @param txt the resulting text 30 | * @throws IOException 31 | */ 32 | public void parsePdf(String pdf, String txt) throws IOException { 33 | PdfReader reader = new PdfReader(pdf); 34 | PdfReaderContentParser parser = new PdfReaderContentParser(reader); 35 | PrintWriter out = new PrintWriter(new FileOutputStream(txt)); 36 | TextExtractionStrategy strategy; 37 | for (int i = 1; i <= reader.getNumberOfPages(); i++) { 38 | strategy = parser.processContent(i, new LocationTextExtractionStrategy()); 39 | out.println(strategy.getResultantText()); 40 | } 41 | out.flush(); 42 | out.close(); 43 | reader.close(); 44 | } 45 | 46 | /** 47 | * Main method. 48 | * @param args no arguments needed 49 | * @throws IOException 50 | */ 51 | public static void main(String[] args) throws IOException { 52 | new ExtractPageContentSorted1().parsePdf(PREFACE, RESULT); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/part4/chapter15/ExtractPageContentSorted2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part4.chapter15; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | import java.io.PrintWriter; 13 | 14 | import com.itextpdf.text.DocumentException; 15 | import com.itextpdf.text.pdf.PdfReader; 16 | import com.itextpdf.text.pdf.parser.PdfTextExtractor; 17 | 18 | public class ExtractPageContentSorted2 { 19 | 20 | /** The original PDF that will be parsed. */ 21 | public static final String PREFACE = "resources/pdfs/preface.pdf"; 22 | /** The resulting text file. */ 23 | public static final String RESULT = "results/part4/chapter15/preface_sorted2.txt"; 24 | 25 | /** 26 | * Parses a specific area of a PDF to a plain text file. 27 | * @param pdf the original PDF 28 | * @param txt the resulting text 29 | * @throws IOException 30 | */ 31 | public void parsePdf(String pdf, String txt) throws IOException { 32 | PdfReader reader = new PdfReader(pdf); 33 | PrintWriter out = new PrintWriter(new FileOutputStream(txt)); 34 | for (int i = 1; i <= reader.getNumberOfPages(); i++) { 35 | out.println(PdfTextExtractor.getTextFromPage(reader, i)); 36 | } 37 | out.flush(); 38 | out.close(); 39 | reader.close(); 40 | } 41 | 42 | /** 43 | * Main method. 44 | * @param args no arguments needed 45 | * @throws DocumentException 46 | * @throws IOException 47 | */ 48 | public static void main(String[] args) throws IOException, DocumentException { 49 | new ExtractPageContentSorted2().parsePdf(PREFACE, RESULT); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/part4/chapter15/InspectPageContent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part4.chapter15; 9 | 10 | import java.io.File; 11 | import java.io.FileOutputStream; 12 | import java.io.IOException; 13 | import java.io.PrintWriter; 14 | 15 | import part1.chapter03.MovieTemplates; 16 | 17 | import com.itextpdf.text.DocumentException; 18 | import com.itextpdf.text.pdf.parser.PdfContentReaderTool; 19 | 20 | public class InspectPageContent { 21 | 22 | /** Text file containing information about a PDF file. */ 23 | public static final String RESULT = "results/part4/chapter15/calendar_info.txt"; 24 | 25 | /** 26 | * Parses object and content information of a PDF into a text file. 27 | * @param pdf the original PDF 28 | * @param txt the resulting text 29 | * @throws IOException 30 | */ 31 | public void inspectPdf(String pdf, String txt) throws IOException { 32 | PrintWriter out = new PrintWriter(new FileOutputStream(txt)); 33 | PdfContentReaderTool.listContentStream(new File(pdf), out); 34 | out.flush(); 35 | out.close(); 36 | } 37 | 38 | /** 39 | * Main method. 40 | * @param args no arguments needed 41 | * @throws DocumentException 42 | * @throws IOException 43 | */ 44 | public static void main(String[] args) throws IOException, DocumentException { 45 | new MovieTemplates().createPdf(MovieTemplates.RESULT); 46 | new InspectPageContent().inspectPdf(MovieTemplates.RESULT, RESULT); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/part4/chapter15/MyImageRenderListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part4.chapter15; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import com.itextpdf.text.pdf.parser.ImageRenderInfo; 14 | import com.itextpdf.text.pdf.parser.PdfImageObject; 15 | import com.itextpdf.text.pdf.parser.RenderListener; 16 | import com.itextpdf.text.pdf.parser.TextRenderInfo; 17 | 18 | public class MyImageRenderListener implements RenderListener { 19 | 20 | /** The new document to which we've added a border rectangle. */ 21 | protected String path = ""; 22 | 23 | /** 24 | * Creates a RenderListener that will look for images. 25 | */ 26 | public MyImageRenderListener(String path) { 27 | this.path = path; 28 | } 29 | 30 | /** 31 | * @see com.itextpdf.text.pdf.parser.RenderListener#beginTextBlock() 32 | */ 33 | public void beginTextBlock() { 34 | } 35 | 36 | /** 37 | * @see com.itextpdf.text.pdf.parser.RenderListener#endTextBlock() 38 | */ 39 | public void endTextBlock() { 40 | } 41 | 42 | /** 43 | * @see com.itextpdf.text.pdf.parser.RenderListener#renderImage( 44 | * com.itextpdf.text.pdf.parser.ImageRenderInfo) 45 | */ 46 | public void renderImage(ImageRenderInfo renderInfo) { 47 | try { 48 | String filename; 49 | FileOutputStream os; 50 | PdfImageObject image = renderInfo.getImage(); 51 | if (image == null) return; 52 | filename = String.format(path, renderInfo.getRef().getNumber(), image.getFileType()); 53 | os = new FileOutputStream(filename); 54 | os.write(image.getImageAsBytes()); 55 | os.flush(); 56 | os.close(); 57 | } catch (IOException e) { 58 | System.out.println(e.getMessage()); 59 | } 60 | } 61 | 62 | /** 63 | * @see com.itextpdf.text.pdf.parser.RenderListener#renderText( 64 | * com.itextpdf.text.pdf.parser.TextRenderInfo) 65 | */ 66 | public void renderText(TextRenderInfo renderInfo) { 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/part4/chapter15/MyTextRenderListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | package part4.chapter15; 8 | 9 | import java.io.PrintWriter; 10 | 11 | import com.itextpdf.text.pdf.parser.ImageRenderInfo; 12 | import com.itextpdf.text.pdf.parser.RenderListener; 13 | import com.itextpdf.text.pdf.parser.TextRenderInfo; 14 | 15 | public class MyTextRenderListener implements RenderListener { 16 | 17 | /** The print writer to which the information will be written. */ 18 | protected PrintWriter out; 19 | 20 | /** 21 | * Creates a RenderListener that will look for text. 22 | */ 23 | public MyTextRenderListener(PrintWriter out) { 24 | this.out = out; 25 | } 26 | 27 | /** 28 | * @see com.itextpdf.text.pdf.parser.RenderListener#beginTextBlock() 29 | */ 30 | public void beginTextBlock() { 31 | out.print("<"); 32 | } 33 | 34 | /** 35 | * @see com.itextpdf.text.pdf.parser.RenderListener#endTextBlock() 36 | */ 37 | public void endTextBlock() { 38 | out.println(">"); 39 | } 40 | 41 | /** 42 | * @see com.itextpdf.text.pdf.parser.RenderListener#renderImage( 43 | * com.itextpdf.text.pdf.parser.ImageRenderInfo) 44 | */ 45 | public void renderImage(ImageRenderInfo renderInfo) { 46 | } 47 | 48 | /** 49 | * @see com.itextpdf.text.pdf.parser.RenderListener#renderText( 50 | * com.itextpdf.text.pdf.parser.TextRenderInfo) 51 | */ 52 | public void renderText(TextRenderInfo renderInfo) { 53 | out.print("<"); 54 | out.print(renderInfo.getText()); 55 | out.print(">"); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/part4/chapter15/ParseTaggedPdf.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part4.chapter15; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import javax.xml.parsers.ParserConfigurationException; 14 | 15 | import org.xml.sax.SAXException; 16 | 17 | import com.itextpdf.text.DocumentException; 18 | import com.itextpdf.text.pdf.PdfReader; 19 | import com.itextpdf.text.pdf.parser.TaggedPdfReaderTool; 20 | 21 | public class ParseTaggedPdf { 22 | 23 | /** The resulting XML file. */ 24 | public static final String RESULT 25 | = "results/part4/chapter15/moby_extracted.xml"; 26 | 27 | /** 28 | * Creates a PDF file using a previous example, 29 | * then parses the document. 30 | * @param args no arguments needed 31 | */ 32 | public static void main(String[] args) 33 | throws IOException, DocumentException, SAXException, ParserConfigurationException { 34 | StructuredContent.main(args); 35 | TaggedPdfReaderTool readertool = new TaggedPdfReaderTool(); 36 | PdfReader reader = new PdfReader(StructuredContent.RESULT); 37 | readertool.convertToXml(reader, new FileOutputStream(RESULT)); 38 | reader.close(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/part4/chapter15/ShowTextMargins.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part4.chapter15; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import com.itextpdf.text.DocumentException; 14 | import com.itextpdf.text.pdf.PdfContentByte; 15 | import com.itextpdf.text.pdf.PdfReader; 16 | import com.itextpdf.text.pdf.PdfStamper; 17 | import com.itextpdf.text.pdf.parser.PdfReaderContentParser; 18 | import com.itextpdf.text.pdf.parser.TextMarginFinder; 19 | 20 | public class ShowTextMargins { 21 | 22 | /** The original document. */ 23 | public static final String PREFACE = "resources/pdfs/preface.pdf"; 24 | /** The new document to which we've added a border rectangle. */ 25 | public static final String RESULT = "results/part4/chapter15/margins.pdf"; 26 | 27 | /** 28 | * Parses a PDF and ads a rectangle showing the text margin. 29 | * @param src the source PDF 30 | * @param dest the resulting PDF 31 | */ 32 | public void addMarginRectangle(String src, String dest) 33 | throws IOException, DocumentException { 34 | PdfReader reader = new PdfReader(src); 35 | PdfReaderContentParser parser = new PdfReaderContentParser(reader); 36 | PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(RESULT)); 37 | TextMarginFinder finder; 38 | for (int i = 1; i <= reader.getNumberOfPages(); i++) { 39 | finder = parser.processContent(i, new TextMarginFinder()); 40 | PdfContentByte cb = stamper.getOverContent(i); 41 | cb.rectangle(finder.getLlx(), finder.getLly(), 42 | finder.getWidth(), finder.getHeight()); 43 | cb.stroke(); 44 | } 45 | stamper.close(); 46 | reader.close(); 47 | } 48 | 49 | /** 50 | * Main method. 51 | * @param args no arguments needed 52 | * @throws DocumentException 53 | * @throws IOException 54 | */ 55 | public static void main(String[] args) throws IOException, DocumentException { 56 | new ShowTextMargins().addMarginRectangle(PREFACE, RESULT); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/part4/chapter15/StructureParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part4.chapter15; 9 | import java.util.List; 10 | 11 | import org.xml.sax.Attributes; 12 | import org.xml.sax.SAXException; 13 | import org.xml.sax.helpers.DefaultHandler; 14 | 15 | import com.itextpdf.text.pdf.PdfName; 16 | import com.itextpdf.text.pdf.PdfStructureElement; 17 | 18 | public class StructureParser extends DefaultHandler { 19 | 20 | /** The top element in the PDF structure */ 21 | protected PdfStructureElement top; 22 | /** The list of structure elements */ 23 | protected List elements; 24 | 25 | /** Creates a parser that will parse an XML file into a structure tree. */ 26 | public StructureParser(PdfStructureElement top, List elements) { 27 | this.top = top; 28 | this.elements = elements; 29 | } 30 | 31 | /** 32 | * @see org.xml.sax.ContentHandler#startElement(java.lang.String, 33 | * java.lang.String, java.lang.String, org.xml.sax.Attributes) 34 | */ 35 | public void startElement(String uri, String localName, String qName, 36 | Attributes attributes) throws SAXException { 37 | if ("chapter".equals(qName)) return; 38 | elements.add(new PdfStructureElement(top, new PdfName(qName))); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/part4/chapter16/LocalDestinationEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part4.chapter16; 9 | 10 | import com.itextpdf.text.Rectangle; 11 | import com.itextpdf.text.pdf.PdfContentByte; 12 | import com.itextpdf.text.pdf.PdfDestination; 13 | import com.itextpdf.text.pdf.PdfPCell; 14 | import com.itextpdf.text.pdf.PdfPCellEvent; 15 | import com.itextpdf.text.pdf.PdfWriter; 16 | 17 | public class LocalDestinationEvent implements PdfPCellEvent { 18 | 19 | /** The writer to which the local destination will be added. */ 20 | protected PdfWriter writer; 21 | /** The name of the local destination. */ 22 | protected String name; 23 | 24 | /** Constructs a local destination event. */ 25 | public LocalDestinationEvent(PdfWriter writer, String name) { 26 | this.writer = writer; 27 | this.name = name; 28 | } 29 | 30 | /** Implementation of the cellLayout method. */ 31 | public void cellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases) { 32 | writer.getDirectContent().localDestination(name, 33 | new PdfDestination(PdfDestination.FITH, position.getTop())); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/part4/chapter16/MovieAnnotation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | 8 | package part4.chapter16; 9 | 10 | import java.io.FileOutputStream; 11 | import java.io.IOException; 12 | 13 | import com.itextpdf.text.Document; 14 | import com.itextpdf.text.DocumentException; 15 | import com.itextpdf.text.Rectangle; 16 | import com.itextpdf.text.pdf.PdfAnnotation; 17 | import com.itextpdf.text.pdf.PdfFileSpecification; 18 | import com.itextpdf.text.pdf.PdfWriter; 19 | 20 | public class MovieAnnotation { 21 | 22 | /** The resulting PDF file. */ 23 | public static final String RESULT 24 | = "results/part4/chapter16/movie.pdf"; 25 | /** One of the resources. */ 26 | public static final String RESOURCE 27 | = "resources/img/foxdog.mpg"; 28 | 29 | /** 30 | * Creates a PDF document. 31 | * @param filename the path to the new PDF document 32 | * @throws DocumentException 33 | * @throws IOException 34 | */ 35 | public void createPdf(String filename) throws IOException, DocumentException { 36 | // step 1 37 | Document document = new Document(); 38 | // step 2 39 | PdfWriter writer 40 | = PdfWriter.getInstance(document, new FileOutputStream(filename)); 41 | // step 3 42 | document.open(); 43 | // step 4 44 | PdfFileSpecification fs = PdfFileSpecification.fileEmbedded(writer, 45 | RESOURCE, "foxdog.mpg", null); 46 | writer.addAnnotation(PdfAnnotation.createScreen(writer, 47 | new Rectangle(200f, 700f, 400f, 800f), "Fox and Dog", fs, 48 | "video/mpeg", true)); 49 | // step 5 50 | document.close(); 51 | } 52 | 53 | /** 54 | * Main method. 55 | * 56 | * @param args no arguments needed 57 | * @throws DocumentException 58 | * @throws IOException 59 | * @throws DocumentException 60 | * @throws IOException 61 | */ 62 | public static void main(String[] args) throws IOException, DocumentException { 63 | new MovieAnnotation().createPdf(RESULT); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/part4/chapter16/PdfActionEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | package part4.chapter16; 8 | 9 | import com.itextpdf.text.Rectangle; 10 | import com.itextpdf.text.pdf.PdfAction; 11 | import com.itextpdf.text.pdf.PdfAnnotation; 12 | import com.itextpdf.text.pdf.PdfContentByte; 13 | import com.itextpdf.text.pdf.PdfPCell; 14 | import com.itextpdf.text.pdf.PdfPCellEvent; 15 | import com.itextpdf.text.pdf.PdfWriter; 16 | 17 | public class PdfActionEvent implements PdfPCellEvent { 18 | 19 | /** The writer to which we are going to add the action. */ 20 | protected PdfWriter writer; 21 | /** The action we're going to add. */ 22 | protected PdfAction action; 23 | 24 | /** Creates a new Action event. */ 25 | public PdfActionEvent(PdfWriter writer, PdfAction action) { 26 | this.writer = writer; 27 | this.action = action; 28 | } 29 | 30 | /** Implementation of the cellLayout method. */ 31 | public void cellLayout(PdfPCell cell, Rectangle position, PdfContentByte[] canvases) { 32 | writer.addAnnotation(new PdfAnnotation(writer, 33 | position.getLeft(), position.getBottom(), position.getRight(), position.getTop(), 34 | action)); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/part4/chapter16/SpecialId.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This class is part of the book "iText in Action - 2nd Edition" 3 | * written by Bruno Lowagie (ISBN: 9781935182610) 4 | * For more info, go to: http://itextpdf.com/examples/ 5 | * This example only works with the AGPL version of iText. 6 | */ 7 | package part4.chapter16; 8 | 9 | import java.io.FileOutputStream; 10 | import java.io.IOException; 11 | 12 | import com.itextpdf.text.Document; 13 | import com.itextpdf.text.DocumentException; 14 | import com.itextpdf.text.Image; 15 | import com.itextpdf.text.Rectangle; 16 | import com.itextpdf.text.pdf.PdfImage; 17 | import com.itextpdf.text.pdf.PdfIndirectObject; 18 | import com.itextpdf.text.pdf.PdfName; 19 | import com.itextpdf.text.pdf.PdfWriter; 20 | 21 | public class SpecialId { 22 | 23 | /** The resulting PDF file. */ 24 | public static String RESULT = "results/part4/chapter16/special_id.pdf"; 25 | /** An image file. */ 26 | public static String RESOURCE = "resources/img/bruno.jpg"; 27 | 28 | /** 29 | * Creates a PDF document. 30 | * @param filename the path to the new PDF document 31 | * @throws DocumentException 32 | * @throws IOException 33 | */ 34 | public void createPdf(String filename) throws IOException, DocumentException { 35 | Document document = new Document(new Rectangle(400, 300)); 36 | PdfWriter writer = PdfWriter.getInstance(document, 37 | new FileOutputStream(filename)); 38 | document.open(); 39 | Image img = Image.getInstance(RESOURCE); 40 | img.scaleAbsolute(400, 300); 41 | img.setAbsolutePosition(0, 0); 42 | PdfImage stream = new PdfImage(img, "", null); 43 | stream.put(new PdfName("ITXT_SpecialId"), new PdfName("123456789")); 44 | PdfIndirectObject ref = writer.addToBody(stream); 45 | img.setDirectReference(ref.getIndirectReference()); 46 | document.add(img); 47 | document.close(); 48 | } 49 | 50 | /** 51 | * Main method. 52 | * 53 | * @param args no arguments needed 54 | * @throws DocumentException 55 | * @throws IOException 56 | */ 57 | public static void main(String[] args) throws IOException, DocumentException { 58 | new SpecialId().createPdf(RESULT); 59 | } 60 | } 61 | --------------------------------------------------------------------------------