@@ -5023,6 +5023,63 @@ describe("annotation", function () {
50235023 "endobj\n"
50245024 ) ;
50255025 } ) ;
5026+
5027+ it ( "should update an existing Highlight annotation in removing its popup" , async function ( ) {
5028+ const popupRef = Ref . get ( 111 , 0 ) ;
5029+ const highlightDict = new Dict ( ) ;
5030+ highlightDict . set ( "Type" , Name . get ( "Annot" ) ) ;
5031+ highlightDict . set ( "Subtype" , Name . get ( "Highlight" ) ) ;
5032+ highlightDict . set ( "Rotate" , 0 ) ;
5033+ highlightDict . set ( "CreationDate" , "D:20190423" ) ;
5034+ highlightDict . set ( "Contents" , "Hello PDF.js World !" ) ;
5035+ highlightDict . set ( "Popup" , popupRef ) ;
5036+ const highlightRef = Ref . get ( 143 , 0 ) ;
5037+
5038+ const highlightPopupDict = new Dict ( ) ;
5039+ highlightPopupDict . set ( "Type" , Name . get ( "Annot" ) ) ;
5040+ highlightPopupDict . set ( "Subtype" , Name . get ( "Popup" ) ) ;
5041+ highlightPopupDict . set ( "Open" , false ) ;
5042+ highlightPopupDict . set ( "Rect" , [ 1 , 2 , 3 , 4 ] ) ;
5043+ highlightPopupDict . set ( "Parent" , highlightRef ) ;
5044+
5045+ const xref = ( partialEvaluator . xref = new XRefMock ( [
5046+ { ref : highlightRef , data : highlightDict } ,
5047+ { ref : popupRef , data : highlightPopupDict } ,
5048+ ] ) ) ;
5049+ const changes = new RefSetCache ( ) ;
5050+
5051+ const task = new WorkerTask ( "test Highlight update" ) ;
5052+ await AnnotationFactory . saveNewAnnotations (
5053+ partialEvaluator ,
5054+ task ,
5055+ [
5056+ {
5057+ annotationType : AnnotationEditorType . HIGHLIGHT ,
5058+ rotation : 90 ,
5059+ popup : {
5060+ contents : "" ,
5061+ deleted : true ,
5062+ rect : [ 1 , 2 , 3 , 4 ] ,
5063+ } ,
5064+ id : "143R" ,
5065+ ref : highlightRef ,
5066+ oldAnnotation : highlightDict ,
5067+ popupRef,
5068+ } ,
5069+ ] ,
5070+ null ,
5071+ changes
5072+ ) ;
5073+
5074+ const data = await writeChanges ( changes , xref ) ;
5075+ const base = data [ 0 ] . data . replaceAll ( / \( D : \d + \) / g, "(date)" ) ;
5076+ expect ( base ) . toEqual (
5077+ "143 0 obj\n" +
5078+ "<< /Type /Annot /Subtype /Highlight /Rotate 90 /CreationDate (date) /M (date) " +
5079+ "/F 4>>\n" +
5080+ "endobj\n"
5081+ ) ;
5082+ } ) ;
50265083 } ) ;
50275084
50285085 describe ( "UnderlineAnnotation" , function ( ) {
0 commit comments