diff --git a/README.md b/README.md index 9081eb8..ce21fdd 100644 --- a/README.md +++ b/README.md @@ -35,10 +35,11 @@ See [examples/](examples) for more advanced examples. Following annotations are implemented so far: - Square, Circle -- Highlight, Underline, StrikeOut, Squiggly +- TextMarkup (Highlight, Underline, Squiggly, StrikeOut) - Text, FreeText - Link - Line +- FileAttachment ## Requirements Flare is designed for LuaTeX. Other TeX engines are not supported. diff --git a/test/pdf/fileattachment-01.pdf b/test/pdf/fileattachment-01.pdf new file mode 100644 index 0000000..5ba2378 Binary files /dev/null and b/test/pdf/fileattachment-01.pdf differ diff --git a/test/pdf/fileattachment-02.pdf b/test/pdf/fileattachment-02.pdf new file mode 100644 index 0000000..86f4800 Binary files /dev/null and b/test/pdf/fileattachment-02.pdf differ diff --git a/test/pdf/fileattachment.txt b/test/pdf/fileattachment.txt new file mode 100644 index 0000000..5aa2117 --- /dev/null +++ b/test/pdf/fileattachment.txt @@ -0,0 +1 @@ +This file is referenced from fileattachment-01.pdf. diff --git a/test/test-flare-annot3.lua b/test/test-flare-annot3.lua index 2aae829..93641d4 100644 --- a/test/test-flare-annot3.lua +++ b/test/test-flare-annot3.lua @@ -281,4 +281,67 @@ test('Page:getAnnotLine()', end) +test('Page:getAnnotFileAttachment() #ok', + function() + + -- + -- pdf/fileattachment-01.pdf + -- + local pdf_fn = createTestFile( + 'fileattachment-01', + '\\includegraphics[scale=0.5]{pdf/fileattachment-01.pdf}') + + local d = Doc:new() + local p = Page:new(d) + local pagenum = 1 + p:setGinKV('filename', pdf_fn) + p:setGinKV('page', pagenum) + p:openFile() + local pdf = pdfe.open(pdf_fn) + local annot = pdfe.getpage(pdf, 1).Annots[1] + local page_objnum = p:getPageObjNum(pagenum) + + assert.same('Annot', annot.Type) + assert.same('FileAttachment', annot.Subtype) + assert.same(page_objnum, luatex.getreference(annot, 'P')) + assert.same('PushPin', annot.Name) + + assert.same('Filespec', annot.FS.Type) + assert.same('fileattachment.txt', annot.FS.F) + + + -- + -- pdf/fileattachment-02.pdf + -- + local pdf_fn = createTestFile( + 'fileattachment-02', + '\\includegraphics[scale=0.5]{pdf/fileattachment-02.pdf}') + + local d = Doc:new() + local p = Page:new(d) + local pagenum = 1 + p:setGinKV('filename', pdf_fn) + p:setGinKV('page', pagenum) + p:openFile() + local pdf = pdfe.open(pdf_fn) + local annot = pdfe.getpage(pdf, 1).Annots[1] + local page_objnum = p:getPageObjNum(pagenum) + + assert.same('Annot', annot.Type) + assert.same('FileAttachment', annot.Subtype) + assert.same(page_objnum, luatex.getreference(annot, 'P')) + assert.same('PushPin', annot.Name) + + assert.same('Filespec', annot.FS.Type) + assert.same('foo.txt', annot.FS.F) + + local stream, len = pdfe.readwholestream(annot.FS.EF.F) + assert.same('This is an embedded file.\n' .. + 'Just testing.\n\n', + stream) + assert.same(41, len) + +end) + + end) -- describe