[
https://issues.apache.org/jira/browse/PDFBOX-2340?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14200689#comment-14200689
]
Tilman Hausherr commented on PDFBOX-2340:
-----------------------------------------
I'd like to have a segment on rendering in the cookbook. Here's an example that
I hope is good for beginners:
{code}
String filename = "YOURFILENAMEHERE.pdf";
// open the document
PDDocument doc = PDDocument.loadNonSeq(new File(filename), null);
// old parser
// PDDocument doc = PDDocument.load(new File(filename));
// if (doc.isEncrypted())
// {
// // some files are encrypted with the empty password
// StandardDecryptionMaterial sdm = new
StandardDecryptionMaterial("");
// doc.openProtection(sdm);
// }
boolean b;
List<PDPage> pages = doc.getDocumentCatalog().getAllPages();
for (int p = 0; p < pages.size(); ++p)
{
// RGB image with 300 dpi
BufferedImage bim =
pages.get(p).convertToImage(BufferedImage.TYPE_INT_RGB, 300);
// save as PNG with default metadata
b = ImageIO.write(bim, "png", new File("rgbpage" + (p+1) + ".png"));
if (!b)
{
// error handling
}
// B/W image with 300 dpi
bim = pages.get(p).convertToImage(BufferedImage.TYPE_BYTE_BINARY,
300);
// save as TIF with dpi in the metadata
// PDFBox will choose the best compression for you - here: CCITT G4
// you need to add jai_imageio.jar to your classpath for this to
work
b = ImageIOUtil.writeImage(bim, "bwpage-" + (p+1) + ".tif", 300);
if (!b)
{
// error handling
}
}
doc.close();
{code}
> Overhaul PDFBox Documentation
> -----------------------------
>
> Key: PDFBOX-2340
> URL: https://issues.apache.org/jira/browse/PDFBOX-2340
> Project: PDFBox
> Issue Type: Improvement
> Components: Documentation
> Affects Versions: 2.0.0
> Reporter: Maruan Sahyoun
> Assignee: Maruan Sahyoun
> Priority: Critical
> Fix For: 2.0.0
>
> Attachments: Mockup-20140912.png, Mockup_Documentation.png
>
>
> In oder to make it easier for users of PDFBox to work with the library there
> shall be an enhanced documentation consisting of an introduction, API
> references and more well documented examples and code snippets (Cookbook).
> In order to make it easier to contribute the Cookbook shall be build
> automatically from the examples/snippet ‚repository‘.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)