Showing posts with label file. Show all posts
Showing posts with label file. Show all posts

How to shrink PDF file size using Microsoft Print to PDF






The "Microsoft Print to PDF" functionality is often used when you don't have a license of Adobe and still would like to print your PDF as another PDF, e.g., print PDF to get rid of all security/password related restrictions of the original document.

While the functionality is awesome and free, one limitation might be the output file size sometimes is less optimized, which results in oversized file to upload to some websites. For example, the Original Doc in the following is 1,852KB only while using the "Microsoft Print to PDF" default settings results in 19,390KB. I cannot upload the file to a website with an upload limit of 10MB for instance.




Microsoft Print to PDF default setting


As an alternative, I found that enabling the "Print As Image" option in the "Advanced" option reduces the file output size to some extent, as shown in the first figure above. As we can notice from the figure, with this setting, the output file size is reduced to 5,166KB compared to 19,390KB. Now I can submit this file to the website with an upload limit of 10MB.

Microsoft Print to PDF enable "Print As Image"




How to change the size of swapfile in Linux



A swap file is a file that contains data retrieved from system memory, or RAM. By transferring data from RAM to a secondary storage device in the form of a swap file, a computer is able to free up memory for other programs [1]. 

Sometimes, a large swap file can help when your RAM size is limited, e.g., training a large Deep Learning model on your laptop (although it is not a good idea...)

In Linux, we can follow the several steps in the following to change the swap size.

1. disable the current swap file

$ sudo swapoff /swapfile

2. increase (or decrease) the size of swap file (e.g., 8G as below)

$ sudo dd if=/dev/zero of=/swapfile bs=1G count=8

3. Setup the file as our swap file

$ sudo mkswap /swapfile

4. enable swaping

$ sudo swapon /swapfile

5. check the current swap size

$ grep SwapTotal /proc/meminfo


References

How to use password in scp?

We can use sshpass to give the password when using scp to transferring files from server to local.

sshpass -p [yourpassword] scp -r [username]@[address]:[pathinserver] [localpath]

How to read .mat file without using matlab (using Scipy library in Python)

import scipy.io as sio
# read a .mat file
animal = sio.loadmat("animals.mat")

# sample output
{'__header__': b'MATLAB 5.0 MAT-file, Platform: GLNX86, ...
 '__version__': '1.0',
 '__globals__': [],
 'names': 
 'features': a
}
This simple line of code can be used reading .mat file without MATLAB installed in your computer.

how to wget from google drive

wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=FILEID' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=FILEID" -O FILENAME && rm -rf /tmp/cookies.txt

[source]: https://gist.github.com/iamtekeste/3cdfd0366ebfd2c0d805

How To Read File In Java – BufferedReader

JDK 7, read file in Java and automatically close the file.

1:        BufferedReader br = new BufferedReader(new FileReader(file_path));  
2:        String text="";  
3:        String currentLine;  
4:        while ((currentLine = br.readLine())!=null){  
5:          text = text+currentLine;  
6:        }  

How to manage PDF files between laptops and iPAD?

If you'd like to manage(sync) files between different devices like laptops, iPAD, smart phones, there are several cloud service options available for you like Dropbox with 2GB free space and Onedrive from Microsoft with 10GB free and so forth. There's no difference among these solutions if you only want to use file synchronization function, and there's no doubt about that the larger space, the better the service is in this case. 

I'd like to show manage files between laptops and iPAD and including modifying files within the flow.

1.Dropbox

If you registered Dropbox and installed it in your computer, the icon will be shown in under your favorite automatically. You could save any files you want to save in the Dropbox cloud service and use it in another devices. The reason why I choose Dropbox over Onedrive is because PDF note (which is the iPAD app can manage PDF files efficiently) only support to sync with Dropbox and Google Drive.


2.PDF notes (iPAD application for managing PDF)

It is free to download and can manage PDF files importing from Dropbox, Google Drive and can mark sentences and modify PDF while reading. After you mark on whatever parts you'd like to, you could also save the modified file and upload the modified version to Dropbox. Then you could read the version from your desktop or laptop and other devices as well.