» Archive for July, 2007

Fixing PDF margins

Tuesday, July 31st, 2007 by rubypdf

LSAC, the Law School Admission Council, distributes PDF files with busted margins.
Instead of half inch margins all around the page,
they have a one inch margin at the top and no margin at the bottom
(i.e., text runs flush with the bottom of the page).

After spending a few hours trying different poorly documented CUPS command invokations,
I finally found the pdfcrop command.
It was such a frustrating experience,
I have decided to document the solution in hopes of preventing at least one other person from the same hell.

So first I ran pdfinfo on the file to get the page size:

$ pdfinfo recommend.pdf
Title:
Author:         DZS
Creator:        Toolkit http://www.activepdf.com
Producer:       Toolkit http://www.activepdf.com
CreationDate:   Mon Oct 16 03:22:47 2006
ModDate:        Mon Oct 16 03:22:47 2006
Tagged:         no
Pages:          1
Encrypted:      no
Page size:      612 x 792 pts (letter)
File size:      122713 bytes
Optimized:      no
PDF version:    1.5

So the page is 612 by 792.
Next we run pdfcrop to produce a file without any margins:

$ pdfcrop recommend.pdf recommend-cropped.pdf
PDFCROP 1.5, 2004/06/24 - Copyright (c) 2002, 2004 by Heiko Oberdiek.
==> 1 pages written on `recommend-cropped.pdf'.

Now run pdfinfo on the resulting file:

$ pdfinfo recommend-cropped.pdf
Creator:        TeX
Producer:       pdfeTeX-1.21a
CreationDate:   Tue Oct 17 00:50:47 2006
Tagged:         no
Pages:          1
Encrypted:      no
Page size:      551 x 716 pts
File size:      110258 bytes
Optimized:      no
PDF version:    1.4

Notice that the page size has shrunk from 612 by 792 to 551 by 716.
So 612 - 551 = 61 pts narrower,
and 792 - 716 = 76 pts shorter.
We can now use this knowledge along with pdfcrop’s --margins option
to recenter the resulting document:

$ pdfcrop --margins "31 38 30 38" recommend.pdf recommend-fixed.pdf
PDFCROP 1.5, 2004/06/24 - Copyright (c) 2002, 2004 by Heiko Oberdiek.
==> 1 pages written on `recommend-fixed.pdf'.

Voila.
You have successfully compensated for the incompetence of the institution that holds complete control over who can practice US law.

From: Fixing PDF margins

PPTtoSWF or PPT2SWF-Convert PowerPoint to Flash just using free softwares

Monday, July 30th, 2007 by rubypdf

There are more than one way to convert PowerPoint (ppt) to Flash (swf), I will introduce two frees .

1. OpenOffice Impress supports flash export, it is very easy, open ppt in OpenOffice.org(ooo) and save as (or export) it as flash.

2. using the following three software, you can easily print ppt to PDF or images first, then use PDF2SWF, JPEG2SWF, PNG2SWF to get Flash. the steps are:

  • download pptview, PdfCreator, SWFTools and install them.
  • use “pptview /p abc.ppt” command you can print PowerPoint freely.
  • select PdfCreator(virtual printer) and print PowerPoint to PDF.
  • use PDF2SWF, convert PDF to Flash.

PowerPoint 2003 Viewer (pptview) has some command line switches:

  • /L — Read a playlist of files contained within a text file (see below). Example: \pptview.exe /L “Playlist.txt”
  • /S — Start without splash screen.
  • /P — Print the presentation. Example: \pptview.exe /P “Presentation.ppt”
  • /D — Prompt the Open dialog box to appear when slide show ends.
  • /N# — Open presentation at a specified slide number “#”. Example: /pptview.exe /n5 “presentation.ppt” would open at slide 5.

PdfCreator supports easily print the documents to PDF, PS, EPS, Images(bmp, jpeg, png, tiff, pcx).

SWF Tools is a collection of SWF manipulation and
creation utilities written by Rainer Böhme and Matthias Kramm.
It is released under the GPL.
Included are:

  • PDF2SWF
    A PDF to SWF Converter. Generates one frame per page. Enables you to
    have fully formatted text, including tables, formulas etc. inside your
    Flash Movie. It’s based on the xpdf PDF
    parser from Derek B. Noonburg.
  • SWFCombine
    A tool for inserting SWFs into Wrapper SWFs. (Templates)
    E.g. for including the pdf2swf SWFs in some sort of Browsing-SWF.
  • SWFStrings
    Scans SWFs for text data.
  • SWFDump
    Prints out various informations about SWFs.
  • JPEG2SWF
    Takes one or more JPEG pictures and generates a SWF slideshow.
  • PNG2SWF
    Like JPEG2SWF, only for PNGs.
  • GIF2SWF
    Converts GIFs to SWF. Also able to handle animated gifs.
  • WAV2SWF
    Converts WAV audio files to SWFs, using the
    L.A.M.E. MP3 encoder library.
  • AVI2SWF
    Converts AVI animation files to SWF.
    It supports Flash MX H.263 compression.
    Some examples can be found at examples.html.
  • Font2SWF
    Converts font files (TTF, Type1) to SWF.
  • SWFBBox
    Allows to readjust SWF bounding boxes.
  • SWFC
    A tool for creating SWF files from simple script files.

  • SWFExtract
    Allows to extract Movieclips, Sounds, Images etc. from SWF files.
  • RFXSWF Library
    A fully featured library which can be used for standalone SWF generation.
    Includes support for Bitmaps, Buttons, Shapes, Text, Fonts, Sound etc.
    It also has support for ActionScript using the
    Ming ActionCompiler.

SWFTools has been reported to work on Solaris, Linux, FreeBSD, OpenBSD, HP-UX, MacOS X and Windows 98/ME/2000/XP.

Compare the two methods, they are both free, and the first one supports multi-platform, such as windows, linux, Mac OS X, but the OpenOffice is some bigger, the second one just support windows, and has some difficult to implement.

Activate Commenting in Adobe Reader 8 OLE Object or browsers

Monday, July 30th, 2007 by rubypdf

If the document has been “Comment Enabled for Reader”, how to let “commenting & Markup” toolbar avaliable when open the PDF document with the browsers, such as IE, Firefox and so on? Or when I’m using a Adobe Reader 8 OLE object within a Windows Form, when I open a PDF document, how can let “commenting & Markup” toolbar avaliable?

the answer is documented in the Acrobat SDKs “JavaScript Scripting Guide” Use “Collab.showAnnotToolsWhenNoCollab = true;” and embed this in the document or call it in your desktop application using either AFExecuteThisScript or ExecuteThisJavaScript depending on which API set you are using.