Techfee

Some Octopress Tips

| Comments

1. Add Local Image

About how to add local images on blog copy your image in Octopress/source/images. PS: Octopress(whatever you named it) directory is a repository directory for your blog. then you can use img tag as

{ % img left /images/terminal.png 350 350 ‘image’ ‘images’ % }

like

images

About Pdfs With Only Owner’s Password Deciphere by Using Pdfbox

| Comments

Some pdfs have owner password to prevent user from copying, extracting or printing … etc …

By using pdf box, you can easily deciphere this kind of open and read only pdfs.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
     PDDocument document = PDDocument.load(filePath, true);

      if (document.isEncrypted()) {
          try {
              document.decrypt("");
              document.setAllSecurityToBeRemoved(true);
          } catch (Exception e) {
              throw new UnableToDeciphereException("The document is encrypted, and we can't decrypt it.", e);
          }
      }

      ByteArrayOutputStream outStream = new ByteArrayOutputStream();

      document.save(outStream);
      
      document.close();

      byte[] decipheredBytes = outStream.toByteArray();

or you can use a FileOutputStream to save it into a file. Actually, document.save() has a parameter filepath, so you can , for example : document.save(“/Users/User/Desktop/abc.pdf”) .

Hello Java World :)

| Comments

HelloWorld
1
2
3
4
5
public class HelloWorld {
  public static void main (String [] args){
      System.out.println("Hello Java World!");
}
}