Showing posts with label pdf. Show all posts
Showing posts with label pdf. Show all posts

Thursday, December 10, 2020

Some important commands on using "pdftk"

pdftk is a powerful tool. It can be used to cut, merge, and edit pdf file. Even I have PDF Studio Pro, in several cases (merging copyrighted pdf) it failed, but pdftk works. Here some important pdftk commands to work with pdf files.

# Collate scanned pages

    pdftk A=even.pdf B=odd.pdf shuffle A B output collated.pdf

   # or if odd.pdf is in reverse order:

    pdftk A=even.pdf B=odd.pdf shuffle A Bend-1 output collated.pdf

# Decrypt a PDF

    pdftk secured.pdf input_pw foopass output unsecured.pdf

# Encrypt a PDF using 128-bit strength (the default), withhold all permissions (the default)

    pdftk 1.pdf output 1.128.pdf owner_pw foopass

# Same as above, except password baz must also be used to open output PDF

    pdftk 1.pdf output 1.128.pdf owner_pw foo user_pw baz

# Same as above, except printing is allowed (once the PDF is open)

    pdftk 1.pdf output 1.128.pdf owner_pw foo user_pw baz allow printing

# Join in1.pdf and in2.pdf into a new PDF, out1.pdf

    pdftk in1.pdf in2.pdf cat output out1.pdf

   # or (using handles):

    pdftk A=in1.pdf B=in2.pdf cat A B output out1.pdf

   # or (using wildcards alphabetically):

    pdftk *.pdf cat output combined.pdf

# Remove page 13 from in1.pdf to create out1.pdf

    pdftk in.pdf cat 1-12 14-end output out1.pdf

   # or:

    pdftk A=in1.pdf cat A1-12 A14-end output out1.pdf

# When using the Windows command-prompt, it helps to use drag-and-drop from the file manager: drag the input PDF file from the file manager onto the command-prompt, and its full pathname will appear at the prompt.

# Apply 40-bit encryption to output, revoking all permissions (the default). Set the owner PW to foopass.

    pdftk 1.pdf 2.pdf cat output 3.pdf encrypt_40bit owner_pw foopass

# Join two files, one of which requires the password foopass. The output is not encrypted.

    pdftk A=secured.pdf 2.pdf input_pw A=foopass cat output 3.pdf

# Uncompress PDF page streams for editing the PDF in a text editor (e.g., vim, emacs)

    pdftk doc.pdf output doc.unc.pdf uncompress

# Repair a PDF’s corrupted XREF table and stream lengths, if possible

    pdftk broken.pdf output fixed.pdf

# Burst a single PDF document into pages and dump its data to doc_data.txt

    pdftk in.pdf burst

# Burst a single PDF document into encrypted pages. Allow low-quality printing

    pdftk in.pdf burst owner_pw foopass allow DegradedPrinting

# Write a report on PDF document metadata and bookmarks to report.txt

    pdftk in.pdf dump_data output report.txt

# Rotate the first PDF page to 90 degrees clockwise

    pdftk in.pdf cat 1east 2-end output out.pdf

# Rotate an entire PDF document to 180 degrees

    pdftk in.pdf cat 1-endsouth output out.pdf
    
# Inverse the page order from 1-end to end-1.

    pdftk in.pdf cat end-1 output output.pdf

Monday, November 30, 2020

Memotong (autocrop) file pdf secara otomatis

Teknik sederhana berikut akan memotong file pdf dengan batas sepanjang apa yang ada dalam file pdf tersebut. Artinya, gambar atau objek di dalam file pdf akan ditampilkan secara maksimal dari sisi ukurannya.
$ pdfcrop input.pdf
Luarannya adalah file dengan nama `input-crop.pdf`. Bisa saja file luarannya diberi nama saat memerintahkan memotong file pdf, bisa juga ukuran yang dipotong ditentukan secara manual. Namun, kenapa harus menambah kerjaan jika semuanya bisa dilakukan secara outomatis seperti perintah diatas? Berikut hasil perintah di atas.

Sebelum: input.pdf

Sesudah: input-crop.pdf

Thursday, November 26, 2020

Konversi resolusi tinggi pdf ke eps

Hanya dua format (ekstensi file) yang diperkenankan pada publikasi saintifik: tif dan eps. Untuk tif saya tidak pernah memakainya, program yang saya gunakan (python, draw, inkscape, dll) tidak pernah saya gunakan untuk memproduksi file tipe tif tersebut, dan, sulit dipakai di Latex. Solusinya hanya eps, dan latex juga mendukung ekstensi file tersebut.

Masalahnya, saya sangat menyukai tipe file pdf. Banyak alasannya, diantaranya:

1. Zoom-able

2. Searchable (teks di dalam gambar, misal aksis grafik)

3. Bisa dibuka dimana saja, laptop, hape, dll.

Mau tidak mau, file pdf yang serba bermafaat tersebut harus dikonversi ke eps. Setidaknya dua cara telah saya coba. Awalnya, saya memakai perintah `convert` dan berhasil. Kekurangannya, resolusinya menjadi kecil. Setelah sekian lama, saya menemukan `pstopdf` yang juga mendukung eps file dengan argumen `eps`. Dengan perintah kedua ini resolusi yang dihasilkan cukup tinggi. Perintah lainnya adalah dengan inkscape (asumsi sudah terinstall).

Jadi, begini caranya.

$ pdftops -eps input.pdf
$ inkscape input.pdf --export-eps=output.eps

Perintah terakhir di atas juga bisa digunakan untuk merubah file tipe lain, misalnya svg ke pdf (selain dengan cara yang disebutkan disini).
$ inkscape input.svg --export-pdf=output.pdf
Referensi:
  1. https://stackoverflow.com/questions/44736917/high-quality-pdf-to-eps

Saturday, June 20, 2020

Konversi file svg ke pdf via terminal

Ekstensi pdf sangat fleksibel, baik digunakan secara independen maupun ketika di "embedd" ke dalam file lain, misalnya Latex. Gambar yang baik (resolusinya) kebanyakan bukan dalam format pdf, tapi (contohnya) SVG. Konversi yang cepat (dalam hitungan detik) dibutuhkan agar kita tidak perlu membuka program berbasis grafis (seperti InkScape atau Adobe Illustration) untuk konversi dari SVG ke PDF. Berikut solusinya.

# install program jika belum terinstall
$ sudo apt-get install librsvg2-bin
$ rsvg-convert -f pdf -o output.pdf input.svg

Cara ini menghemat waktu sekitar 10 menit dari cara konvensional (berbasis grafis). Selain itu, aplikasi berbasis grafis sering "mend-distract" kita untuk mengerjakan sesuatu yang lain di aplikasi tersebut.

Saturday, October 12, 2013

Free Mathematics Differential Equations Books For Downloads

These items are available as free downloads:

ELEMENTARY DIFFERENTIAL EQUATIONS
http://ramanujan.math.trinity.edu/wtrench/texts/TRENCH_FREE_DIFFEQ_I.PDF,
previously published by Brooks/Cole Thomson Learning, 2000.

ELEMENTARY DIFFERENTIAL EQUATIONS WITH BOUNDARY VALUE PROBLEMS,
http://ramanujan.math.trinity.edu/wtrench/texts/TRENCH_FREE_DIFFEQ_II.PDF,
previously published by Brooks/Cole Thomson Learning, 2000.

STUDENT SOLUTIONS MANUAL FOR ELEMENTARY DIFFERENTIAL EQUATIONS AND ELEMENTARY DIFFERENTIAL EQUATIONS WITH BOUNDARY VALUE PROBLEMS,
http://ramanujan.math.trinity.edu/wtrench/texts/TRENCH_DE_STUDENT_MANUAL.PDF
previously published by Brooks/Cole Thomson Learning, 2000.

INTRODUCTION TO REAL ANALYSIS
http://ramanujan.math.trinity.edu/wtrench/texts/TRENCH_REAL_ANALYSIS.PDF,
previously published by Pearson Education, 2003.

Supplements to INTRODUCTION TO REAL ANALYSIS: FUNCTIONS DEFINED BY IMPROPER INTEGRALS
http://ramanujan.math.trinity.edu/wtrench/texts/TRENCH_IMPROPER_FUNCTIONS.PDF,
previously published by Harper & Row, 1978.

THE METHOD OF LAGRANGE MULTIPLIERS,
http://ramanujan.math.trinity.edu/wtrench/texts/TRENCH_LAGRANGE_METHOD.PDF,
 previously published by Harper & Row, 1978.

Instructor solutions manuals are available request, subject to verification of faculty status. I would appreciate it if you would pass this along to colleagues and students who may be interested.

William F. Trench