本文整理汇总了Java中com.itextpdf.text.RectangleReadOnly类的典型用法代码示例。如果您正苦于以下问题:Java RectangleReadOnly类的具体用法?Java RectangleReadOnly怎么用?Java RectangleReadOnly使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RectangleReadOnly类属于com.itextpdf.text包,在下文中一共展示了RectangleReadOnly类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testMergeGrandizerFilesA5
import com.itextpdf.text.RectangleReadOnly; //导入依赖的package包/类
/**
* <a href="http://stackoverflow.com/questions/28991291/how-to-remove-whitespace-on-merge">
* How To Remove Whitespace on Merge
* </a>
* <p>
* Testing {@link PdfVeryDenseMergeTool} using the OP's files on a even smaller page.
* </p>
*/
@Test
public void testMergeGrandizerFilesA5() throws DocumentException, IOException
{
try ( InputStream docA = getClass().getResourceAsStream("Header.pdf");
InputStream docB = getClass().getResourceAsStream("Body.pdf");
InputStream docC = getClass().getResourceAsStream("Footer.pdf"); )
{
PdfVeryDenseMergeTool tool = new PdfVeryDenseMergeTool(new RectangleReadOnly(595,421), 18, 18, 5);
PdfReader readerA = new PdfReader(docA);
PdfReader readerB = new PdfReader(docB);
PdfReader readerC = new PdfReader(docC);
try (FileOutputStream fos = new FileOutputStream(new File(RESULT_FOLDER, "GrandizerMerge-veryDense-A5.pdf")))
{
List<PdfReader> inputs = Arrays.asList(readerA, readerB, readerC);
tool.merge(fos, inputs);
}
finally
{
readerA.close();
readerB.close();
readerC.close();
}
}
}
示例2: savePageAsPdf
import com.itextpdf.text.RectangleReadOnly; //导入依赖的package包/类
public String savePageAsPdf(boolean scaled) throws IOException, DocumentException
{
String pdfName = "";
// Define test screenshot root
String test = "";
if (TestNamingUtil.isTestNameRegistered()) {
test = TestNamingUtil.getTestNameByThread();
} else {
test = "undefined";
}
File testRootDir = ReportContext.getTestDir();
File artifactsFolder = ReportContext.getArtifactsFolder();
String fileID = test.replaceAll("\\W+", "_") + "-" + System.currentTimeMillis();
pdfName = fileID + ".pdf";
String fullPdfPath = artifactsFolder.getAbsolutePath() + "/" + pdfName;
// TODO: test this implementation and change back to capture if necessary
Image image = Image.getInstance(testRootDir.getAbsolutePath() + "/" + Screenshot.captureFailure(driver, ""));
Document document = null;
if (scaled)
{
document = new Document(PageSize.A4, 10, 10, 10, 10);
if (image.getHeight() > (document.getPageSize().getHeight() - 20)
|| image.getScaledWidth() > (document.getPageSize().getWidth() - 20))
{
image.scaleToFit(document.getPageSize().getWidth() - 20, document.getPageSize().getHeight() - 20);
}
} else
{
document = new Document(new RectangleReadOnly(image.getScaledWidth(), image.getScaledHeight()));
}
PdfWriter.getInstance(document, new FileOutputStream(fullPdfPath));
document.open();
document.add(image);
document.close();
return fullPdfPath;
}
示例3: createSampleDocument
import com.itextpdf.text.RectangleReadOnly; //导入依赖的package包/类
byte[] createSampleDocument() throws IOException, DocumentException
{
try ( ByteArrayOutputStream baos = new ByteArrayOutputStream() )
{
Document doc = new Document(new RectangleReadOnly(842,595));
PdfWriter.getInstance(doc, baos);
doc.open();
doc.add(new Paragraph("Test Page 1"));
doc.newPage();
doc.add(new Paragraph("Test Page 2"));
doc.close();
return baos.toByteArray();
}
}