use of com.tom_roush.pdfbox.pdmodel.PDDocument in project PdfBox-Android by TomRoush.
the class TestRendering method render.
public void render(File file) throws IOException {
PDDocument document = PDDocument.load(file);
render(document, file.getName());
}
use of com.tom_roush.pdfbox.pdmodel.PDDocument in project PdfBox-Android by TomRoush.
the class TestRendering method render.
public void render(String fileName) throws IOException {
PDDocument document = PDDocument.load(testContext.getAssets().open(fileName));
render(document, fileName.substring(fileName.lastIndexOf("/") + 1));
}
use of com.tom_roush.pdfbox.pdmodel.PDDocument in project PdfBox-Android by TomRoush.
the class PDVisibleSigBuilder method createTemplate.
/**
* Creates a PDDocument and adds the page parameter to it and keeps this as a template in the
* PDF template Structure.
*
* @param page
* @throws IOException
*/
@Override
public void createTemplate(PDPage page) throws IOException {
PDDocument template = new PDDocument();
template.addPage(page);
pdfStructure.setTemplate(template);
}
use of com.tom_roush.pdfbox.pdmodel.PDDocument in project PdfBox-Android by TomRoush.
the class PDVisibleSignDesigner method calculatePageSizeFromStream.
private void calculatePageSizeFromStream(InputStream documentStream, int page) throws IOException {
// create PD document
PDDocument document = PDDocument.load(documentStream);
// calculate height and width of document page
calculatePageSize(document, page);
document.close();
}
use of com.tom_roush.pdfbox.pdmodel.PDDocument in project PdfBox-Android by TomRoush.
the class TestLayerUtility method testLayerImport.
/**
* Tests layer import.
*
* @throws Exception if an error occurs
*/
public void testLayerImport() throws Exception {
File mainPDF = createMainPDF();
File overlay1 = createOverlay1();
File targetFile = new File(testResultsDir, "text-with-form-overlay.pdf");
PDDocument targetDoc = PDDocument.load(mainPDF);
PDDocument overlay1Doc = PDDocument.load(overlay1);
try {
LayerUtility layerUtil = new LayerUtility(targetDoc);
PDFormXObject form = layerUtil.importPageAsForm(overlay1Doc, 0);
PDPage targetPage = targetDoc.getPage(0);
layerUtil.wrapInSaveRestore(targetPage);
AffineTransform at = new AffineTransform();
layerUtil.appendFormAsLayer(targetPage, form, at, "overlay");
targetDoc.save(targetFile.getAbsolutePath());
} finally {
targetDoc.close();
overlay1Doc.close();
}
PDDocument doc = PDDocument.load(targetFile);
try {
PDDocumentCatalog catalog = doc.getDocumentCatalog();
// OCGs require PDF 1.5 or later
assertEquals(1.5f, doc.getVersion());
PDPage page = doc.getPage(0);
PDOptionalContentGroup ocg = (PDOptionalContentGroup) page.getResources().getProperties(COSName.getPDFName("oc1"));
assertNotNull(ocg);
assertEquals("overlay", ocg.getName());
PDOptionalContentProperties ocgs = catalog.getOCProperties();
PDOptionalContentGroup overlay = ocgs.getGroup("overlay");
assertEquals(ocg.getName(), overlay.getName());
} finally {
doc.close();
}
}
Aggregations