  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Tomcat - JSP/Servlet container | | Struts - A MVC web framework | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | JSP - A mailing list about Java Server Pages specification and reference | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | |
Struts & Hibernate
|
|
|
  | | | -none- | -none- 2007-10-04 - By Mark Storer
Back No bueno.
Each of those slides is made up of a collection of resources & drawing commands. To determine where one ends and the other starts (and which one is which), you'd need to parse the page's content stream.
!trivial.
iText includes a basic content tokenizer, but beyond that you're in for a medium-large amount of research and work to pull this off.
I'll talk you through this particular page's contents to let you know what you're in for:
q // push the current graphic state onto the state stack 0.1 0 0 0.1 0 0 cm // Concatenate Matrix to 1/10th scale (from the default 1 0 0 1 0 0) /R7 gs // use an extended graphic state q // push 0.101562 0 6119.8 7920 re W n // clip to the given REctangle 1 1 1 rg // set the rgb foreground color to white 0.101562 0 6119.8 7920 re // rect f // fill 0.199951 0.199951 0.199951 rg // new fill color 387.102 4136.9 4201.8 8.20312 re // rect f // fill 387.102 4136.9 7.79688 3155.2 re //yada yada f // blah blah 387.102 7283.9 4201.8 8.20312 re f 4581.1 4136.9 7.79688 3155.2 re f Q // pop the graphic state q // push 395.102 7284.1 m //move to 395.102 4144.9 l // line to 4580.9 4144.9 l //line 4580.9 7284.1 l //line h // close the path W n // create a new clipping region 1 1 1 rg // white fill 395.102 4144.9 4185.8 3139.2 re f q // push 4186 0 0 3139.5 394.5 4144.5 cm // big numbers due to prior 1/10th matrix /R8 Do // draw the R8 resource Q //pop Q //pop q //push 419.102 7260.1 m // move, line line line, close, clip 419.102 4290.9 l 2397.9 4290.9 l 2397.9 7260.1 l h W n q//push 1979.5 0 0 2969 418.5 4291 cm // we'd popped back to the 1/10th again /R9 Do // draw R9 Q // pop Q //pop q //push
// lots more of the same till we get down to some text operators // I'll leave in the intervening content to let you know what // you're up against. 2333.1 7147.1 m 2333.1 5712.9 l 3927.9 5712.9 l 3927.9 7147.1 l h W n q 1595.5 0 0 1434.5 2332.5 5712.5 cm /R10 Do Q Q q 1862.1 5769.1 m 1862.1 4303.9 l 3858.9 4303.9 l 3858.9 5769.1 l h W n q 1997 0 0 1465 1861.5 4304 cm /R11 Do Q Q q 0.101562 0 6119.8 7920 re W n 0.199951 0.199951 0.199951 rg 387.102 336.898 4201.8 8.20312 re f 387.102 336.898 7.79688 3156.2 re f 387.102 3484.9 4201.8 8.20312 re f 4581.1 336.898 7.79688 3156.2 re f Q q 395.102 3485.1 m 395.102 344.898 l 4580.9 344.898 l 4580.9 3485.1 l h W n 1 1 1 rg 395.102 344.898 4185.8 3140.2 re f q 4186 0 0 3139.5 394.5 345 cm /R12 Do Q Q q 419.102 3461.1 m 419.102 1101.9 l 1678.9 1101.9 l 1678.9 3461.1 l h W n q 1260 0 0 2358.5 418.5 1102 cm /R13 Do Q Q q 395.102 3485.1 m 395.102 344.898 l 4580.9 344.898 l 4580.9 3485.1 l h W n 1 1 1 RG // sets the foreground color to white 1 1 1 rg
// ******** And here comes the text ******** q 10 0 0 10 0 0 cm // 1/10th * 10. An odd way to go about things BT // begin a text object /R14 17 Tf // set the current font 1 0 0 1 242.9 249.85 Tm // set the Text Matrix // my content editor turns odd binary values into {hex hex} // so bear with me: ({01}{02}{03}{04}{03}{04}{05}{03}{06}{07}{08} \n{0b}{0c})Tj // draw some characters -41.45 -20.8 Td // (\r{03}{0b}{0e}{07}{0f}{03}{0b}{07}\n{08}{07}\n{0b}{07}{08} {03}{07}{10}\n{08}{08}{10}{03}{07} {11}{08}{03}{10}{07}\n{12})Tj 84.4 -20.8 Td // move the start of the next line ({13}{14}{05}{15}\n{16})Tj // draw more text ET // end text object
// and then we're back to more of the same Q Q q 419.102 344.898 4161.8 779.203 re W n q 4186 0 0 802 418.5 321.5 cm /R16 Do Q Q Q
-- ---- ---- ---- ---- ----
So given all that STUFF, you need to parse it, interpret it, and figure out which resource is used where. You can then determine the resource names of things used outside the page's media box (or whichever page pox you're altering), and remove them from the page's resource dictionary... then do the whole removeUnusedObjects() thing.
Have fun. :\
-- --Mark Storer Professional Geek
No bueno.<br><br>Each of those slides is made up of a collection of resources & drawing commands. To determine where one ends and the other starts (and which one is which), you'd need to parse the page's content stream. <br><br>!trivial.<br><br>iText includes a basic content tokenizer, but beyond that you're in for a medium-large amount of research and work to pull this off.<br><br>I'll talk you through this particular page's contents to let you know what you're in for: <br><br>q // push the current graphic state onto the state stack<br>0.1 0 0 0.1 0 0 cm // Concatenate Matrix to 1/10th scale (from the default 1 0 0 1 0 0)<br> /R7 gs // use an extended graphic state<br>q // push<br>0.101562 0 6119.8 7920 re W n // clip to the given REctangle<br>1 1 1 rg // set the rgb foreground color to white<br>0.101562 0 6119.8 7920 re // rect<br>f // fill<br>0.199951 0.199951 0.199951 rg // new fill color<br>387.102 4136.9 4201.8 8.20312 re // rect<br>f // fill<br>387.102 4136.9 7.79688 3155.2 re / /yada yada<br>f // blah blah<br>387.102 7283.9 4201.8 8.20312 re<br>f<br>4581.1 4136.9 7.79688 3155.2 re<br>f<br>Q // pop the graphic state<br>q // push <br>395.102 7284.1 m //move to<br>395.102 4144.9 l // line to<br>4580.9 4144.9 l //line<br>4580.9 7284.1 l //line<br>h // close the path<br>W n // create a new clipping region<br>1 1 1 rg // white fill<br>395.102 4144.9 4185.8 3139.2 re<br>f<br>q // push<br> 4186 0 0 3139.5 394.5 4144.5 cm // big numbers due to prior 1/10th matrix<br>/R8 Do // draw the R8 resource<br>Q //pop <br>Q //pop<br>q //push<br>419.102 7260.1 m // move, line line line, close, clip <br>419.102 4290.9 l<br>2397.9 4290.9 l<br>2397.9 7260.1 l<br>h<br>W n<br>q/ /push<br>1979.5 0 0 2969 418.5 4291 cm // we'd popped back to the 1/10th again<br>/R9 Do // draw R9<br>Q // pop<br>Q //pop<br>q //push<br><br> // lots more of the same till we get down to some text operators<br>// I'll leave in the intervening content to let you know what<br>// you're up against.<br>2333.1 7147.1 m<br>2333.1 5712.9 l<br>3927.9 5712.9 l<br> 3927.9 7147.1 l<br>h<br>W n<br>q 1595.5 0 0 1434.5 2332.5 5712.5 cm<br>/R10 Do <br>Q<br>Q<br>q<br>1862.1 5769.1 m<br>1862.1 4303.9 l<br>3858.9 4303.9 l<br>3858 .9 5769.1 l<br>h<br>W n<br>q 1997 0 0 1465 1861.5 4304 cm<br>/R11 Do <br>Q<br>Q<br>q<br>0.101562 0 6119.8 7920 re W n<br>0.199951 0.199951 0.199951 rg<br>387.102 336.898 4201.8 8.20312 re<br>f<br>387.102 336.898 7.79688 3156.2 re<br>f<br>387.102 3484.9 4201.8 8.20312 re<br>f<br>4581.1 336.898 7.79688 3156.2 re<br>f<br>Q<br>q<br>395.102 3485.1 m<br>395.102 344.898 l<br >4580.9 344.898 l<br>4580.9 3485.1 l<br>h<br>W n<br>1 1 1 rg<br>395.102 344.898 4185.8 3140.2 re<br>f<br>q 4186 0 0 3139.5 394.5 345 cm<br>/R12 Do <br>Q<br>Q<br>q<br>419.102 3461.1 m<br>419.102 1101.9 l<br>1678.9 1101.9 l<br >1678.9 3461.1 l<br>h<br>W n<br>q 1260 0 0 2358.5 418.5 1102 cm<br>/R13 Do<br>Q <br>Q<br>q<br>395.102 3485.1 m<br>395.102 344.898 l<br>4580.9 344.898 l<br>4580.9 3485.1 l<br>h<br>W n<br>1 1 1 RG // sets the foreground color to white<br>1 1 1 rg<br><br>// ******** And here comes the text ********<br >q<br>10 0 0 10 0 0 cm // 1/10th * 10. An odd way to go about things<br> BT // begin a text object<br>/R14 17 Tf // set the current font<br>1 0 0 1 242.9 249.85 Tm // set the Text Matrix<br>// my content editor turns odd binary values into {hex hex}<br>// so bear with me:<br>({01}{02}{03}{04}{03}{04 }{05}{03}{06}{07}{08} \n{0b}{0c})Tj // draw some characters <br>-41.45 -20.8 Td // <br>(\r{03}{0b}{0e}{07}{0f}{03}{0b}{07}\n{08}{07}\n{0b} {07}{08} {03}{07}{10}\n{08}{08}{10}{03}{07} {11}{08}{03}{10}{07}\n{12})Tj<br>84.4 -20.8 Td // move the start of the next line<br>({13}{14}{05}{15}\n{16})Tj // draw more text <br>ET // end text object<br><br>// and then we're back to more of the same <br>Q<br>Q<br>q<br>419.102 344.898 4161.8 779.203 re W n<br>q 4186 0 0 802 418.5 321.5 cm<br>/R16 Do<br>Q<br>Q<br>Q<br><br>-- ---- ---- ---- ---- ---- <br><br>So given all that STUFF, you need to parse it, interpret it, and figure out which resource is used where. You can then determine the resource names of things used outside the page's media box (or whichever page pox you're altering), and remove them from the page's resource dictionary.. . then do the whole removeUnusedObjects() thing. <br><br>Have fun. :\<br><br><br>-- <br>--Mark Storer<br>Professional Geek
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ __ ____ ____ ____ ____ ____ ____ ____ ____ ____ iText-questions mailing list iText-questions@(protected) https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/
|
|
 |