File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -230,6 +230,16 @@ impl Pdf {
230230 }
231231 }
232232
233+ /// Set the binary marker in the header of the PDF.
234+ ///
235+ /// This can be useful if you want to ensure that your PDF consists of only
236+ /// ASCII characters, as this is not the case by default.
237+ ///
238+ /// _Default value_: \x80\x80\x80\x80
239+ pub fn set_binary_marker ( & mut self , marker : & [ u8 ; 4 ] ) {
240+ self . chunk . buf [ 10 ..14 ] . copy_from_slice ( marker) ;
241+ }
242+
233243 /// Set the PDF version.
234244 ///
235245 /// The version is not semantically important to the crate, but must be
@@ -485,4 +495,17 @@ mod tests {
485495 w. indirect ( Ref :: new ( 6 ) ) . primitive ( 2 ) ;
486496 w. finish ( ) ;
487497 }
498+
499+ #[ test]
500+ fn test_binary_marker ( ) {
501+ let mut w = Pdf :: new ( ) ;
502+ w. set_binary_marker ( & [ b'A' , b'B' , b'C' , b'D' ] ) ;
503+ test ! (
504+ w. finish( ) ,
505+ b"%PDF-1.7\n %ABCD\n " ,
506+ b"xref\n 0 1\n 0000000000 65535 f\r " ,
507+ b"trailer\n <<\n /Size 1\n >>" ,
508+ b"startxref\n 16\n %%EOF" ,
509+ ) ;
510+ }
488511}
You can’t perform that action at this time.
0 commit comments