当前位置: 首页>>代码示例>>Java>>正文


Java RectangleReadOnly类代码示例

本文整理汇总了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();
        }
    }
}
 
开发者ID:mkl-public,项目名称:testarea-itext5,代码行数:33,代码来源:VeryDenseMerging.java

示例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;
}
 
开发者ID:qaprosoft,项目名称:carina,代码行数:41,代码来源:AbstractPage.java

示例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();
	}
}
 
开发者ID:mkl-public,项目名称:testarea-itext5,代码行数:15,代码来源:StampHeader.java


注:本文中的com.itextpdf.text.RectangleReadOnly类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。