mirror of
				https://github.com/johnwhitington/cpdf-source.git
				synced 2025-06-05 22:09:39 +02:00 
			
		
		
		
	Add XFA detection
This commit is contained in:
		
							
								
								
									
										1
									
								
								Changes
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								Changes
									
									
									
									
									
								
							| @@ -13,6 +13,7 @@ o Add @b<n>@ for trimming bookmark text to given length | |||||||
| o Allow bold, italic, colours for JSON bookmarks | o Allow bold, italic, colours for JSON bookmarks | ||||||
| o Show OpenAction in -info | o Show OpenAction in -info | ||||||
| o Show more form information in -info | o Show more form information in -info | ||||||
|  | o Show XFA in -info | ||||||
|  |  | ||||||
| Fixes: | Fixes: | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										
											BIN
										
									
								
								cpdfmanual.pdf
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								cpdfmanual.pdf
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							| @@ -3257,6 +3257,7 @@ CenterWindow: | |||||||
| DisplayDocTitle: True | DisplayDocTitle: True | ||||||
| NonFullScreenPageMode:  | NonFullScreenPageMode:  | ||||||
| AcroForm: False | AcroForm: False | ||||||
|  | XFA: False | ||||||
| Marked: False | Marked: False | ||||||
| UserProperties: False | UserProperties: False | ||||||
| Suspects: False | Suspects: False | ||||||
| @@ -3312,6 +3313,7 @@ The \texttt{-info-json} operation prints the information in JSON format instead. | |||||||
|   "DisplayDocTitle": true, |   "DisplayDocTitle": true, | ||||||
|   "NonFullPageScreenMode": null, |   "NonFullPageScreenMode": null, | ||||||
|   "AcroForm": false, |   "AcroForm": false, | ||||||
|  |   "XFA": false, | ||||||
|   "Marked": false, |   "Marked": false, | ||||||
|   "UserProperties": false, |   "UserProperties": false, | ||||||
|   "Suspects": false, |   "Suspects": false, | ||||||
|   | |||||||
| @@ -239,6 +239,9 @@ let get_open_action_string pdf = | |||||||
|   | `Null -> "" |   | `Null -> "" | ||||||
|   | j -> Pdfwrite.string_of_pdf (Cpdfjson.object_of_json j) |   | j -> Pdfwrite.string_of_pdf (Cpdfjson.object_of_json j) | ||||||
|  |  | ||||||
|  | let is_xfa pdf = | ||||||
|  |   Pdf.lookup_chain pdf pdf.Pdf.trailerdict ["/Root"; "/AcroForm"; "/XFA"] <> None | ||||||
|  |  | ||||||
| let output_info ?(json=ref [("none", `Null)]) encoding pdf = | let output_info ?(json=ref [("none", `Null)]) encoding pdf = | ||||||
|   let notjson = !json = [("none", `Null)] in |   let notjson = !json = [("none", `Null)] in | ||||||
|   let getstring = getstring encoding pdf in |   let getstring = getstring encoding pdf in | ||||||
| @@ -292,6 +295,8 @@ let output_info ?(json=ref [("none", `Null)]) encoding pdf = | |||||||
|     json =| ("NonFullPageScreenMode", match (get_viewer_pref_item "/NonFullPageScreenMode" pdf) with "" -> `Null | x -> `String x); |     json =| ("NonFullPageScreenMode", match (get_viewer_pref_item "/NonFullPageScreenMode" pdf) with "" -> `Null | x -> `String x); | ||||||
|     if notjson then Printf.printf "AcroForm: %s\n" (match get_catalog_item "/AcroForm" pdf with "" -> "False" | x -> x); |     if notjson then Printf.printf "AcroForm: %s\n" (match get_catalog_item "/AcroForm" pdf with "" -> "False" | x -> x); | ||||||
|     json =| ("AcroForm", match (get_catalog_item "/AcroForm" pdf) with "" -> `Bool false | x -> `Bool true); |     json =| ("AcroForm", match (get_catalog_item "/AcroForm" pdf) with "" -> `Bool false | x -> `Bool true); | ||||||
|  |     if notjson then Printf.printf "XFA: %s\n" (if is_xfa pdf then "True" else "False"); | ||||||
|  |     json =| ("XFA", `Bool (is_xfa pdf)); | ||||||
|     if notjson then Printf.printf "Marked: %s\n" (match get_markinfo_item "/Marked" pdf with true -> "True" | _ -> "False"); |     if notjson then Printf.printf "Marked: %s\n" (match get_markinfo_item "/Marked" pdf with true -> "True" | _ -> "False"); | ||||||
|     json =| ("Marked", `Bool (get_markinfo_item "/Marked" pdf)); |     json =| ("Marked", `Bool (get_markinfo_item "/Marked" pdf)); | ||||||
|     if notjson then Printf.printf "UserProperties: %s\n" (match get_markinfo_item "/UserProperties" pdf with true -> "True" | _ -> "False"); |     if notjson then Printf.printf "UserProperties: %s\n" (match get_markinfo_item "/UserProperties" pdf with true -> "True" | _ -> "False"); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user