本文整理汇总了Java中org.sejda.model.pdf.PdfMetadataKey类的典型用法代码示例。如果您正苦于以下问题:Java PdfMetadataKey类的具体用法?Java PdfMetadataKey怎么用?Java PdfMetadataKey使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PdfMetadataKey类属于org.sejda.model.pdf包,在下文中一共展示了PdfMetadataKey类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: load
import org.sejda.model.pdf.PdfMetadataKey; //导入依赖的package包/类
@Test
public void load() throws IOException, InterruptedException, TimeoutException {
File testFile = folder.newFile("PDFsamTest.pdf");
FileUtils.copyInputStreamToFile(getClass().getResourceAsStream("/test_pdfsam.pdf"), testFile);
PdfDocumentDescriptor descriptor = PdfDocumentDescriptor.newDescriptorNoPassword(testFile);
List<PdfDocumentDescriptor> toLoad = Arrays.asList(new PdfDocumentDescriptor[] { descriptor });
assertEquals(PdfDescriptorLoadingStatus.INITIAL, descriptor.loadingStatus().getValue());
descriptor.moveStatusTo(PdfDescriptorLoadingStatus.REQUESTED);
victim.load(toLoad, RequiredPdfData.DEFAULT);
assertEquals(1, toLoad.size());
PdfDocumentDescriptor item = toLoad.get(0);
assertNotNull(item);
waitOrTimeout(() -> PdfDescriptorLoadingStatus.LOADED == descriptor.loadingStatus().getValue(),
timeout(seconds(2)));
assertEquals(2, item.pages().getValue().intValue());
assertEquals("Me", item.getInformation(PdfMetadataKey.AUTHOR.getKey()));
assertEquals("test", item.getInformation(PdfMetadataKey.KEYWORDS.getKey()));
}
示例2: setMetadata
import org.sejda.model.pdf.PdfMetadataKey; //导入依赖的package包/类
/**
* Adds the input set of metadata to the info dictionary that will be written by the {@link PdfStamper}
*
* @param meta
*/
public void setMetadata(Set<Entry<PdfMetadataKey, String>> meta) {
Map<String, String> info = stamper.getMoreInfo();
for (Entry<PdfMetadataKey, String> current : meta) {
LOG.trace("'{}' -> '{}'", current.getKey().getKey(), current.getValue());
info.put(current.getKey().getKey(), current.getValue());
}
}
示例3: setUp
import org.sejda.model.pdf.PdfMetadataKey; //导入依赖的package包/类
@Before
public void setUp() throws IOException {
TestUtils.setProperty(victim, "context", context);
parameters.setCompress(false);
parameters.setOutputName("outName.pdf");
parameters.setVersion(PdfVersion.VERSION_1_6);
parameters.put(PdfMetadataKey.AUTHOR, "test_author");
parameters.put(PdfMetadataKey.KEYWORDS, "test_keywords");
parameters.put(PdfMetadataKey.SUBJECT, "test_subject");
parameters.put(PdfMetadataKey.TITLE, "test_title");
parameters.setOverwrite(true);
parameters.setOutput(getOutputFile());
}
示例4: doExecute
import org.sejda.model.pdf.PdfMetadataKey; //导入依赖的package包/类
private void doExecute() throws TaskException, IOException {
when(context.getTask(parameters)).thenReturn((Task) victimTask);
victim.execute(parameters);
PdfReader reader = getReaderFromResultFile();
assertCreator(reader);
assertEquals(PdfVersion.VERSION_1_6.getVersionAsCharacter(), reader.getPdfVersion());
Map<String, String> meta = reader.getInfo();
assertEquals("test_author", meta.get(PdfMetadataKey.AUTHOR.getKey()));
assertEquals("test_keywords", meta.get(PdfMetadataKey.KEYWORDS.getKey()));
assertEquals("test_subject", meta.get(PdfMetadataKey.SUBJECT.getKey()));
assertEquals("test_title", meta.get(PdfMetadataKey.TITLE.getKey()));
reader.close();
}
示例5: setPdfProperties
import org.sejda.model.pdf.PdfMetadataKey; //导入依赖的package包/类
private void setPdfProperties() {
version.setText(current.getVersionString());
pages.setText(Integer.toString(current.pages().getValue()));
created.setText(current.getInformation("FormattedCreationDate"));
title.setText(current.getInformation(PdfMetadataKey.TITLE.getKey()));
author.setText(current.getInformation(PdfMetadataKey.AUTHOR.getKey()));
creator.setText(current.getInformation(PdfMetadataKey.CREATOR.getKey()));
subject.setText(current.getInformation(PdfMetadataKey.SUBJECT.getKey()));
producer.setText(current.getInformation("Producer"));
}
示例6: requestShow
import org.sejda.model.pdf.PdfMetadataKey; //导入依赖的package包/类
@EventListener
void requestShow(ShowPdfDescriptorRequest event) {
if (current != event.getDescriptor()) {
current = event.getDescriptor();
current.loadingStatus().addListener(new WeakChangeListener<>(this));
}
keywords.setText(event.getDescriptor().getInformation(PdfMetadataKey.KEYWORDS.getKey()));
}
示例7: changed
import org.sejda.model.pdf.PdfMetadataKey; //导入依赖的package包/类
@Override
public void changed(ObservableValue<? extends PdfDescriptorLoadingStatus> observable,
PdfDescriptorLoadingStatus oldValue, PdfDescriptorLoadingStatus newValue) {
if (newValue == PdfDescriptorLoadingStatus.LOADED) {
LOG.trace("Descriptor loaded, updating keywords tab");
Platform.runLater(() -> keywords.setText(current.getInformation(PdfMetadataKey.KEYWORDS.getKey())));
}
}
示例8: fillDescriptor
import org.sejda.model.pdf.PdfMetadataKey; //导入依赖的package包/类
private void fillDescriptor(PdfDocumentDescriptor descriptor) {
descriptor.putInformation(PdfMetadataKey.TITLE.getKey(), "test.title");
descriptor.putInformation(PdfMetadataKey.AUTHOR.getKey(), "test.author");
descriptor.putInformation(PdfMetadataKey.CREATOR.getKey(), "test.creator");
descriptor.putInformation(PdfMetadataKey.SUBJECT.getKey(), "test.subject");
descriptor.putInformation("Producer", "test.producer");
descriptor.putInformation("FormattedCreationDate", "test.creationDate");
descriptor.pages(2);
descriptor.setVersion(PdfVersion.VERSION_1_5);
}
示例9: showRequest
import org.sejda.model.pdf.PdfMetadataKey; //导入依赖的package包/类
@Test
public void showRequest() throws Exception {
KeywordsTab victim = new KeywordsTab();
Labeled keywords = (Labeled) ((ScrollPane) victim.getContent()).getContent().lookup(".info-property-value");
assertNotNull(keywords);
ChangeListener<? super String> listener = mock(ChangeListener.class);
keywords.textProperty().addListener(listener);
PdfDocumentDescriptor descriptor = PdfDocumentDescriptor.newDescriptorNoPassword(mock(File.class));
descriptor.putInformation(PdfMetadataKey.KEYWORDS.getKey(), "test");
FXTestUtils.invokeAndWait(() -> victim.requestShow(new ShowPdfDescriptorRequest(descriptor)), 1);
verify(listener, timeout(2000).times(1)).changed(any(ObservableValue.class), anyString(), eq("test"));
}
示例10: onLoad
import org.sejda.model.pdf.PdfMetadataKey; //导入依赖的package包/类
@Test
public void onLoad() throws Exception {
KeywordsTab victim = new KeywordsTab();
Labeled keywords = (Labeled) ((ScrollPane) victim.getContent()).getContent().lookup(".info-property-value");
assertNotNull(keywords);
ChangeListener<? super String> listener = mock(ChangeListener.class);
keywords.textProperty().addListener(listener);
PdfDocumentDescriptor descriptor = PdfDocumentDescriptor.newDescriptorNoPassword(mock(File.class));
FXTestUtils.invokeAndWait(() -> victim.requestShow(new ShowPdfDescriptorRequest(descriptor)), 1);
descriptor.putInformation(PdfMetadataKey.KEYWORDS.getKey(), "test");
descriptor.moveStatusTo(PdfDescriptorLoadingStatus.REQUESTED);
descriptor.moveStatusTo(PdfDescriptorLoadingStatus.LOADING);
descriptor.moveStatusTo(PdfDescriptorLoadingStatus.LOADED);
verify(listener, timeout(2000).times(1)).changed(any(ObservableValue.class), anyString(), eq("test"));
}
示例11: getRootNode
import org.sejda.model.pdf.PdfMetadataKey; //导入依赖的package包/类
@Override
protected Parent getRootNode() {
injector = Injector.start(new Config());
Button button = new Button("show");
PdfDocumentDescriptor descriptor = PdfDocumentDescriptor.newDescriptorNoPassword(mock(File.class));
descriptor.putInformation(PdfMetadataKey.KEYWORDS.getKey(), "test");
button.setOnAction(e -> eventStudio().broadcast(new ShowPdfDescriptorRequest(descriptor)));
return button;
}
示例12: accept
import org.sejda.model.pdf.PdfMetadataKey; //导入依赖的package包/类
@Override
public void accept(PDDocument document, PdfDocumentDescriptor descriptor) {
descriptor.pages(document.getNumberOfPages());
descriptor.setVersion(getVersion(document.getVersion()));
PDDocumentInformation info = document.getDocumentInformation();
descriptor.putInformation(PdfMetadataKey.TITLE.getKey(), info.getTitle());
descriptor.putInformation(PdfMetadataKey.AUTHOR.getKey(), info.getAuthor());
descriptor.putInformation(PdfMetadataKey.CREATOR.getKey(), info.getCreator());
descriptor.putInformation(PdfMetadataKey.SUBJECT.getKey(), info.getSubject());
descriptor.putInformation(PdfMetadataKey.KEYWORDS.getKey(), info.getKeywords());
descriptor.putInformation("Producer", info.getProducer());
Optional.ofNullable(info.getCreationDate()).map(FORMATTER::format)
.ifPresent(c -> descriptor.putInformation("FormattedCreationDate", c));
}
示例13: accept
import org.sejda.model.pdf.PdfMetadataKey; //导入依赖的package包/类
@Test
public void accept() {
new DefaultSAMBoxLoader().accept(document, descriptor);
assertEquals(2, descriptor.pages().getValue().intValue());
assertEquals(PdfVersion.VERSION_1_4, descriptor.getVersion());
assertEquals("Chuck Norris", descriptor.getInformation(PdfMetadataKey.AUTHOR.getKey()));
assertEquals("Roundhause", descriptor.getInformation(PdfMetadataKey.SUBJECT.getKey()));
assertNotNull(descriptor.getInformation("FormattedCreationDate"));
assertTrue(isEmpty(descriptor.getInformation(PdfMetadataKey.KEYWORDS.getKey())));
assertTrue(isEmpty(descriptor.getInformation(PdfMetadataKey.CREATOR.getKey())));
assertTrue(isEmpty(descriptor.getInformation(PdfMetadataKey.TITLE.getKey())));
}
示例14: testEquals
import org.sejda.model.pdf.PdfMetadataKey; //导入依赖的package包/类
@Test
public void testEquals() {
SetMetadataParameters eq1 = new SetMetadataParameters();
eq1.put(PdfMetadataKey.AUTHOR, "author");
SetMetadataParameters eq2 = new SetMetadataParameters();
eq2.put(PdfMetadataKey.AUTHOR, "author");
SetMetadataParameters eq3 = new SetMetadataParameters();
eq3.put(PdfMetadataKey.AUTHOR, "author");
SetMetadataParameters diff = new SetMetadataParameters();
diff.put(PdfMetadataKey.AUTHOR, "author");
diff.put(PdfMetadataKey.CREATOR, "creator");
TestUtils.testEqualsAndHashCodes(eq1, eq2, eq3, diff);
}
示例15: testPut
import org.sejda.model.pdf.PdfMetadataKey; //导入依赖的package包/类
@Test
public void testPut() {
SetMetadataParameters victim = new SetMetadataParameters();
victim.put(PdfMetadataKey.AUTHOR, "author");
victim.put(PdfMetadataKey.CREATOR, "creator");
Set<PdfMetadataKey> keys = victim.keySet();
assertEquals(2, keys.size());
assertTrue(keys.contains(PdfMetadataKey.AUTHOR));
assertTrue(keys.contains(PdfMetadataKey.CREATOR));
assertFalse(keys.contains(PdfMetadataKey.KEYWORDS));
}