mirror of
				https://github.com/johnwhitington/cpdf-source.git
				synced 2025-06-05 22:09:39 +02:00 
			
		
		
		
	Adds -shift-boxes
This commit is contained in:
		
							
								
								
									
										1
									
								
								Changes
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								Changes
									
									
									
									
									
								
							| @@ -20,6 +20,7 @@ o Build PDF files from JBIG2 streams, including globals | ||||
| o Reprocess images within PDFs to further compress them | ||||
| o Extract streams to disk | ||||
| o Explore PDFs by printing objects | ||||
| o Shift page boxes with -shift-boxes | ||||
|  | ||||
| Extended features: | ||||
|  | ||||
|   | ||||
| @@ -118,6 +118,7 @@ type op = | ||||
|   | PadMultiple of int | ||||
|   | PadMultipleBefore of int | ||||
|   | Shift | ||||
|   | ShiftBoxes | ||||
|   | Scale | ||||
|   | ScaleToFit | ||||
|   | ScaleContents of float | ||||
| @@ -260,6 +261,7 @@ let string_of_op = function | ||||
|   | PadMultiple _ -> "PadMultiple" | ||||
|   | PadMultipleBefore _ -> "PadMultipleBefore" | ||||
|   | Shift -> "Shift" | ||||
|   | ShiftBoxes -> "ShiftBoxes" | ||||
|   | Scale -> "Scale" | ||||
|   | ScaleToFit -> "ScaleToFit" | ||||
|   | ScaleContents _ -> "ScaleContents" | ||||
| @@ -907,7 +909,7 @@ let banned banlist = function | ||||
|   | Rotateby _ | Upright | VFlip | HFlip | Impose _ | Chop _ -> | ||||
|       mem Pdfcrypt.NoAssemble banlist | ||||
|   | TwoUp|TwoUpStack|RemoveBookmarks|AddRectangle|RemoveText| | ||||
|     Draft|Shift|Scale|ScaleToFit|RemoveAttachedFiles| | ||||
|     Draft|Shift|ShiftBoxes | Scale|ScaleToFit|RemoveAttachedFiles| | ||||
|     RemoveAnnotations|RemoveFonts|Crop|RemoveCrop|Trim|RemoveTrim|Bleed|RemoveBleed|Art|RemoveArt| | ||||
|     CopyBox|MediaBox|HardBox _|SetTrapped|SetUntrapped|Presentation| | ||||
|     BlackText|BlackLines|BlackFills|CopyFont _|StampOn _|StampUnder _|StampAsXObject _| | ||||
| @@ -1201,6 +1203,10 @@ let setshift s = | ||||
|   setop Shift (); | ||||
|   args.coord <- s | ||||
|  | ||||
| let setshiftboxes s = | ||||
|   setop ShiftBoxes (); | ||||
|   args.coord <- s | ||||
|  | ||||
| let setscale s = | ||||
|   setop Scale (); | ||||
|   args.coord <- s | ||||
| @@ -2171,6 +2177,9 @@ and specs = | ||||
|    ("-shift", | ||||
|       Arg.String setshift, | ||||
|       " -shift \"dx dy\" shifts the chosen pages"); | ||||
|    ("-shift-boxes", | ||||
|       Arg.String setshiftboxes, | ||||
|       " -shift \"dx dy\" shifts the chosen pages"); | ||||
|    ("-rotate", | ||||
|        Arg.Int setrotate, | ||||
|        " Set rotation of pages to 0, 90, 180, 270"); | ||||
| @@ -4183,6 +4192,15 @@ let go () = | ||||
|         let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in | ||||
|           let dxdylist = Cpdfcoord.parse_coordinates pdf args.coord in | ||||
|             write_pdf false (Cpdfpage.shift_pdf ~fast:args.fast dxdylist pdf range) | ||||
|   | Some ShiftBoxes -> | ||||
|       let pdf = get_single_pdf args.op false in | ||||
|       let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in | ||||
|       let dxdylist = Cpdfcoord.parse_coordinates pdf args.coord in | ||||
|       let dx, dy = match dxdylist with (a, b)::_ -> a, b | _ -> 0.0, 0.0 in | ||||
|       Printf.printf "dx = %f, dy = %f\n" dx dy; | ||||
|       let f (xmin, xmax, ymin, ymax) = (xmin +. dx, xmax +. dx, ymin +. dy, ymax +. dy) in | ||||
|       let fpage _ p = Cpdfpage.change_boxes f pdf p in | ||||
|         write_pdf false (Cpdfpage.process_pages (Pdfpage.ppstub fpage) pdf range) | ||||
|   | Some Scale -> | ||||
|       let pdf = get_single_pdf args.op false in | ||||
|         let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in | ||||
|   | ||||
| @@ -16,6 +16,7 @@ | ||||
| %Document -extract-stream - check enc | ||||
| %Document -obj - check enc | ||||
| %Document -merge-no-struct-trees in merge and collate | ||||
| %Document -shift-boxes | ||||
| \documentclass{book} | ||||
| % Edit here to produce cpdfmanual.pdf, cpdflibmanual.pdf, pycpdfmanual.pdf, | ||||
| % dotnetcpdflibmanual.pdf, jcpdflibmanual.pdf jscpdflibmanual.pdf etc. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user