170 likes | 282 Views
Orthos. Topos. ockys109geoPdfs. ockys109BatchPDFs. Map assembler and PDF re-layering script. Assembled maps. Florin Alexandrescu SAIC Contractor in support of USGS falex@usgs.gov 3/11/2009. ockys109AssembledMaps. Demo.
E N D
Orthos Topos \\rockys109\geoPdfs\ \\rockys109\BatchPDFs Map assembler and PDF re-layering script Assembled maps Florin Alexandrescu SAIC Contractor in support of USGS falex@usgs.gov 3/11/2009 \\rockys109\AssembledMaps
Demo Remote into IGSKBTHIWS558 as user IGSKBTHI-mapassemble Have a topo available that has not been assembled Run the Perl script
Tools used • WinSpy ++ • PDFTron CosEdit Demo • Perl + modules Win32::OLE, Win32::GuiTest v. 1.50.5, File::Stat, Compress::Raw::Zlib, LWP::Simple • Adobe Acrobat Professional • TerraGo MapAssembler • Windows scheduler
Steps • Select files • Get list of PDF files in the ortho, topo, assembled folders • Open each topo, if there is a matching ortho, and no assembled map • Combine files • Perform mouse and keyboard movements necessary to use MapAssembler • Relayer • Make updates to PDF file using incremental updates. • Rewrite objects containing the PDF catalog, the layering (OCG, OCMD) order, the layer names, stream with OCG and visual objects associations • Metadata • Use stored information from the jobs queue to generate metadata file and attach it to PDF • Save • Open modified file in Acrobat and save it
3F1 = 1009 54D = 1357 54F = 1359 001 = 1
PDF Structure xref 0 5 0000000000 65535 f 0000000016 00000 n 0000014054 00000 n 0000014840 00000 n 0000014936 00000 n
Important PDF objects • OCG = Layer • OCMD (used to assign orthoimage to its own folder) • Catalog/Root (register new OCGs with it, update opening conditions, associate embedded XML metadata file with the document) • OCG order object (assign all free elements to the map collar) • XREF (update it with the new objects added)
Object 6 (Catalog) <</PageMode/UseNone/Names<</JavaScript<</Names[(MAP2PDF)<</S/JavaScript/JS 2 0 R>>]>>>>/Metadata 3 0 R/Pages 1 0 R/OCProperties<</D<</RBGroups[]/ON[7 0 R 8 0 R 9 0 R 10 0 R 11 0 R 12 0 R 13 0 R 14 0 R 15 0 R 16 0 R 17 0 R 18 0 R 19 0 R 20 0 R 21 0 R 22 0 R 23 0 R 24 0 R 25 0 R 26 0 R 27 0 R 28 0 R 29 0 R 30 0 R 31 0 R 32 0 R 33 0 R 34 0 R 35 0 R 36 0 R 37 0 R 38 0 R 39 0 R 40 0 R 41 0 R 42 0 R 43 0 R]/BaseState/ON/Order 44 0 R>>/OCGs[7 0 R 8 0 R 9 0 R 10 0 R 11 0 R 12 0 R 13 0 R 14 0 R 15 0 R 16 0 R 17 0 R 18 0 R 19 0 R 20 0 R 21 0 R 22 0 R 23 0 R 24 0 R 25 0 R 26 0 R 27 0 R 28 0 R 29 0 R 30 0 R 31 0 R 32 0 R 33 0 R 34 0 R 35 0 R 36 0 R 37 0 R 38 0 R 39 0 R 40 0 R 41 0 R 42 0 R 43 0 R]>>/Type/Catalog>> <</PageMode/UseNone/Names<</EmbeddedFiles 661 0 R/ JavaScript<</Names[(MAP2PDF)<</S/JavaScript/JS 2 0 R>>]>>>>/Metadata 3 0 R/Pages 1 0 R/OCProperties<</D<</RBGroups[]/ON[7 0 R 8 0 R 9 0 R 10 0 R 11 0 R 12 0 R 13 0 R 14 0 R 15 0 R 16 0 R 17 0 R 18 0 R 19 0 R 20 0 R 21 0 R 22 0 R 23 0 R 24 0 R 25 0 R 26 0 R 27 0 R 28 0 R 29 0 R 30 0 R 31 0 R 32 0 R 33 0 R 34 0 R 35 0 R 36 0 R 37 0 R 38 0 R 39 0 R 40 0 R 41 0 R 42 0 R 43 0 R]/BaseState/ON/Order 44 0 R>>/OCGs[7 0 R 8 0 R 9 0 R 10 0 R 11 0 R 12 0 R 13 0 R 14 0 R 15 0 R 16 0 R 17 0 R 18 0 R 19 0 R 20 0 R 21 0 R 22 0 R 23 0 R 24 0 R 25 0 R 26 0 R 27 0 R 28 0 R 29 0 R 30 0 R 31 0 R 32 0 R 33 0 R 34 0 R 35 0 R 36 0 R 37 0 R 38 0 R 39 0 R 40 0 R 41 0 R 42 0 R 43 0 R 656 0 R 657 0 R 658 0 R 659 0 R 660 0 R]>>/PageMode/UseOC/Type/Catalog>>
44 0 obj [42 0 R[[(Quadrangle Location)7 0 R[8 0 R 9 0 R]][(UTM Grid and Projection)10 0 R[11 0 R[12 0 R 13 0 R[14 0 R 15 0 R]16 0 R 17 0 R]]][(Adjoining Quadrangles Diagram)18 0 R[19 0 R 20 0 R]][(Map Layers)21 0 R[22 0 R[23 0 R]24 0 R[25 0 R[26 0 R 27 0 R]]28 0 R[29 0 R[30 0 R 31 0 R]32 0 R[33 0 R 34 0 R 35 0 R 36 0 R]]]37 0 R[38 0 R 39 0 R 40 0 R 41 0 R]]]43 0 R] endobj 44 0 obj %modify object 44 to reorder the layers [656 0 R [657 0 R] 658 0 R[11 0 R[ 12 0 R 13 0 R 16 0 R 17 0 R]24 0 R[25 0 R]22 0 R[23 0 R] 28 0 R[32 0 R 29 0 R]] 660 0 R[43 0 R]] endobj Map collar folder Map elements Map frame folder Image folder
Object 46 46 0 obj <</XObject<</TGOB29E 50 0 R/TGOB2A1.tmp 57 0 R/TGOB245 59 0 R/TGOB249 62 0 R/TGOB24A 65 0 R/TGOB24B 68 0 R/TGOB24C 71 0 R/TGOB24D 74 0 R/TGOB24E 77 0 R/TGOB24F 80 0 R/TGOB2A1 83 0 R/TGOB250 90 0 R/TGOB251 95 0 R/TGOB2A3 98 0 R/TGOB252 105 0 R/TGOB2A4 59 0 R/TGOB253 110 0 R/TGOB2A5 115 0 R/TGOB254 122 0 R/TGOB2A6 130 0 R/TGOB255 135 0 R/TGOB2A7 148 0 R/TGOB256 153 0 R/TGOB2A8 160 0 R/TGOB257 165 0 R/TGOB2A9 59 0 R/TGOB258 170 0 R/TGOB259 175 0 R/TGOB2AA 178 0 R/TGOB2AB 59 0 R/TGOB25A 181 0 R/TGOB2AC 184 0 R/TGOB25B 187 0 R/TGOB25C 190 0 R/TGOB25D 193 0 R/TGOB25E 198 0 R/TGOB25F 201 0 R/TGOB292.tmp 206 0 R/TGOB260 213 0 R/TGOB261 216 0 R/TGOB262 221 0 R/TGOB263 228 0 R/TGOB264 231 0 R/TGOB265 236 0 R/TGOB266 241 0 R/TGOB267 246 0 R/TGOB268 251 0 R/TGOB269 256 0 R/XO1 425 0 R/TGOB26A 430 0 R/TGOB26B 435 0 R/TGOB26C 440 0 R/TGOB26D 445 0 R/TGOB26E 450 0 R/TGOB26F 455 0 R/TGOB270 460 0 R/TGOB271 465 0 R/TGOB272 470 0 R/TGOB273 475 0 R/TGOB274 480 0 R/TGOB275 59 0 R/TGOB276 59 0 R/TGOB277 485 0 R/TGOB278 490 0 R/TGOB279 495 0 R/TGOB27A 500 0 R/TGOB27B 505 0 R/TGOB27C 510 0 R/TGOB27D 515 0 R/TGOB27E 518 0 R/TGOB27F 521 0 R/TGOB280 526 0 R/TGOB281 531 0 R/TGOB282 536 0 R/TGOB283 541 0 R/TGOB284 546 0 R/TGOB285 551 0 R/TGOB286 559 0 R/TGOB287 564 0 R/TGOB288 569 0 R/TGOB289 572 0 R/TGOB28A 575 0 R/TGOB28B 580 0 R/TGOB28C 585 0 R/TGOB28D 588 0 R/TGOB28E 591 0 R/TGOB28F 596 0 R/TGOB290 601 0 R/TGOB291 59 0 R/TGOB292 604 0 R/TGOB294 607 0 R/TGOB295 614 0 R/TGOB296 59 0 R/TGOB297 619 0 R/TGOB298 624 0 R/TGOB299 629 0 R/TGOB29A 640 0 R/TGOB29B 643 0 R/TGOB29C 59 0 R/TGOB29D 646 0 R>>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]/Properties<</map3group8 28 0 R/map3group9 29 0 R/map3surround0 38 0 R/map3surround1 39 0 R/map3surround2 40 0 R/map3surround3 41 0 R/map1layer3 12 0 R/map1layer5 14 0 R/map1layer6 15 0 R/map1layer7 16 0 R/map1layer8 17 0 R/map3layer10 30 0 R/map3layer11 31 0 R/map3layer13 33 0 R/map3layer14 34 0 R/map3layer15 35 0 R/map3layer16 36 0 R/map2layer1 20 0 R/map3group12 32 0 R/map3surrounds 37 0 R/map3layer3 23 0 R/map3layer6 26 0 R/map3layer7 27 0 R/map0labels1 8 0 R/map2labels1 19 0 R/map0layer1 9 0 R/map1group1 10 0 R/map1group2 11 0 R/map1group4 13 0 R/OC1 647 0 R/OC2 648 0 R/map0annogroup1 7 0 R/map2annogroup1 18 0 R/map3group1 21 0 R/map3group2 22 0 R/map3group4 24 0 R/map3group5 25 0 R>>/ExtGState<</GS0 649 0 R/GS1 650 0 R>>>> endobj
Object 46 46 0 obj <</XObject<</TGOB29E 50 0 R/TGOB2A1.tmp 57 0 R/TGOB245 59 0 R/TGOB249 62 0 R/TGOB24A 65 0 R/TGOB24B 68 0 R/TGOB24C 71 0 R/TGOB24D 74 0 R/TGOB24E 77 0 R/TGOB24F 80 0 R/TGOB2A1 83 0 R/TGOB250 90 0 R/TGOB251 95 0 R/TGOB2A3 98 0 R/TGOB252 105 0 R/TGOB2A4 59 0 R/TGOB253 110 0 R/TGOB2A5 115 0 R/TGOB254 122 0 R/TGOB2A6 130 0 R/TGOB255 135 0 R/TGOB2A7 148 0 R/TGOB256 153 0 R/TGOB2A8 160 0 R/TGOB257 165 0 R/TGOB2A9 59 0 R/TGOB258 170 0 R/TGOB259 175 0 R/TGOB2AA 178 0 R/TGOB2AB 59 0 R/TGOB25A 181 0 R/TGOB2AC 184 0 R/TGOB25B 187 0 R/TGOB25C 190 0 R/TGOB25D 193 0 R/TGOB25E 198 0 R/TGOB25F 201 0 R/TGOB292.tmp 206 0 R/TGOB260 213 0 R/TGOB261 216 0 R/TGOB262 221 0 R/TGOB263 228 0 R/TGOB264 231 0 R/TGOB265 236 0 R/TGOB266 241 0 R/TGOB267 246 0 R/TGOB268 251 0 R/TGOB269 256 0 R/XO1 425 0 R/TGOB26A 430 0 R/TGOB26B 435 0 R/TGOB26C 440 0 R/TGOB26D 445 0 R/TGOB26E 450 0 R/TGOB26F 455 0 R/TGOB270 460 0 R/TGOB271 465 0 R/TGOB272 470 0 R/TGOB273 475 0 R/TGOB274 480 0 R/TGOB275 59 0 R/TGOB276 59 0 R/TGOB277 485 0 R/TGOB278 490 0 R/TGOB279 495 0 R/TGOB27A 500 0 R/TGOB27B 505 0 R/TGOB27C 510 0 R/TGOB27D 515 0 R/TGOB27E 518 0 R/TGOB27F 521 0 R/TGOB280 526 0 R/TGOB281 531 0 R/TGOB282 536 0 R/TGOB283 541 0 R/TGOB284 546 0 R/TGOB285 551 0 R/TGOB286 559 0 R/TGOB287 564 0 R/TGOB288 569 0 R/TGOB289 572 0 R/TGOB28A 575 0 R/TGOB28B 580 0 R/TGOB28C 585 0 R/TGOB28D 588 0 R/TGOB28E 591 0 R/TGOB28F 596 0 R/TGOB290 601 0 R/TGOB291 59 0 R/TGOB292 604 0 R/TGOB294 607 0 R/TGOB295 614 0 R/TGOB296 59 0 R/TGOB297 619 0 R/TGOB298 624 0 R/TGOB299 629 0 R/TGOB29A 640 0 R/TGOB29B 643 0 R/TGOB29C 59 0 R/TGOB29D 646 0 R>>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]/Properties<</map3group8 28 0 R/map3group9 29 0 R/map3surround0 657 0 R/map3surround1 657 0 R/map3surround2 657 0 R/map3surround3 657 0 R/map1layer3 12 0 R/map1layer5 14 0 R/map1layer6 15 0 R/map1layer7 16 0 R/map1layer8 17 0 R/map3layer10 30 0 R/map3layer11 31 0 R/map3layer13 33 0 R/map3layer14 34 0 R/map3layer15 35 0 R/map3layer16 36 0 R/map2layer1 657 0 R/map3group12 32 0 R/map3surrounds 656 0 R/map3layer3 23 0 R/map3layer6 26 0 R/map3layer7 27 0 R/map0labels1 657 0 R/map2labels1 657 0 R/map0layer1 657 0 R/map1group1 658 0 R/map1group2 11 0 R/map1group4 13 0 R/OC1 647 0 R/OC2 648 0 R/map0annogroup1 656 0 R/map2annogroup1 656 0 R/map3group1 658 0 R/map3group2 22 0 R/map3group4 24 0 R/map3group5 25 0 R>>/ExtGState<</GS0 649 0 R/GS1 650 0 R>>>> endobj
OCMD %new folder for the image. this will become a member of the image OCMD. When this turns off, the image will turn off also 660 0 obj <</Type/OCG/Name (Images)>> endobj 648 0 obj <<% Redefine image content membership dictionary (the last OCMD) to work with new image folder /Type /OCMD /OCGs [43 0 R 660 0 R] /P /AllOn >> endobj
OCG Order object / Special Object 47 … /OC /map3group1 BDC /OC /map3group8 BDC /OC /map3group12 BDC /OC /map3layer16 BDC Q 1 0 0 1 0 0 cm /TGO9AD2 Do Q EMC EMC EMC EMC …
… /OC /map2annogroup1 BDC /OC /map2layer1 BDC q 1 0 0 1 0 0 cm /TGO92C0 Do Q EMC EMC /OC /map0annogroup1 BDC /OC /map0layer1 BDC q 1 0 0 1 0 0 cm /TGO92C2 Do Q EMC EMC /OC /map1group1 BDC /OC /map1group2 BDC /OC /map1layer8 BDC q 1 0 0 1 0 0 cm /TGO92BD Do Q EMC EMC EMC … … /OC /map2annogroup1 BDC /OC /map2layer1 BDC q 1 0 0 1 0 0 cm /TGO92C0 Do Q EMC EMC q 1 0 0 1 0 0 cm /TGO92C2 Do Q /OC /map1group1 BDC /OC /map1group2 BDC /OC /map1layer8 BDC q 1 0 0 1 0 0 cm /TGO92BD Do Q EMC EMC EMC …
my $x = new Compress::Raw::Zlib::Inflate; my $stream47; if(my ($stream) = $obj{47} =~ m/>>stream\s+(.*)endstream/s){ my $status = $x->inflate($stream, $stream47); } #replace EMC \n q with EMC /map0annogroup1 BDC \n /OC /map0layer1 BDC \n q $stream47 =~ s/EMC\s+q/EMC\n\n\/OC \/map0annogroup1 BDC\n\/OC \/map0layer1 BDC\nq/gs; #put the closing EMC tags on too $stream47 =~ s/Q\s+\/OC/Q\nEMC\nEMC\n\n\/OC/gs;
Room for improvement • Problems • IGSKBTHI-mapassemble needs to be logged in all the time, making it very fragile • To speed up the script • Permissions issues on files • Solutions • Rewrite Map Assembler as a command line utility. Either wait for TerraGo, or do this in-house • Use Image Server layer if file sizes and quality are acceptable