Cropping white space from PDF file

400 views
Skip to first unread message

DanYamins

unread,
Sep 15, 2009, 9:57:36 PM9/15/09
to Pisa XHTML2PDF Support
Hi all:

I'm using xhtml2pdf to produce pdf images of a small (10 row) html
table. The image produced by xhtml2pdf is a whole page, with most
of the page blank below the table. I want to embed this image in
another (LaTeX) document, so I need to crop out the white space that
makes up most of the page.

I know I can do this cropping easily by hand (e.g. in Adobe acrobat).
but I want to make the process part of an automated production chain
so that when the table data changes, the resulting final document is
automatically produced.

So my question is: is there a way to force the output of xhtml2pdf
NOT to be a whole page, most of which is blank, but instead to be
sized flush to my actual image? E.g. are there any ways of producing
pdfs with xhtmlpdf that do not contain single full page? Or is there
some simple command-line tool that would allow me to properly
manipulate the full-page pdf that IS produced from xhtml2pdf?

Thanks,
Dan

David Bolton

unread,
Sep 16, 2009, 3:21:45 PM9/16/09
to xhtm...@googlegroups.com
Dan,

I'm not sure I understand your question. Are you trying to crop an
image that is too big? Or are you saying that xhtml2pdf adds
whitespace around the image that you don't want? It would be helpful
to attach a copy of the files you are working with.

David

Dan Yamins

unread,
Sep 16, 2009, 3:28:02 PM9/16/09
to xhtm...@googlegroups.com
Or are you saying that xhtml2pdf adds
whitespace around the image that you don't want?

Yes, I'm saying that the image i have does not take up a whole page.  I want the resulting pdf to be cropped properly around the image and not have extra whitespace.   I've attached an example.

Thanks,
Dan



 
test1.pdf

David Bolton

unread,
Sep 17, 2009, 12:21:27 AM9/17/09
to xhtm...@googlegroups.com
Dan Yamins wrote:
>
>
> Or are you saying that xhtml2pdf adds
> whitespace around the image that you don't want?
>
>
> Yes, I'm saying that the image i have does not take up a whole page.
> I want the resulting pdf to be cropped properly around the image and
> not have extra whitespace. I've attached an example.
>

Dan,

It is best to think of PDF as the electronic equivalent of paper. You
created a table at the top of the page but the rest of the page is blank
because you do not have anything else on the page.

If you want people to print them out your PDF files then I recommend
staying with a standard page size. If really want a smaller page size
then read the appropriate section in the documentation.

http://www.xhtml2pdf.com/doc/pisa-en.html

Forgive me if I misunderstood you. The PDF you attached didn't include
any images and was only one page. I assume you were actually referring
to the table of text when you say "image".

It also occurs to me that you may have a different understanding of the
word "cropped" and actually want to expand the table instead of shrink
the page. If this is the case just add padding to the table cell.

In the future please show a sample of what you want as well as what you
are currently getting. It would eliminate a lot of confusion.

David

Dan Yamins

unread,
Sep 17, 2009, 12:30:01 AM9/17/09
to xhtm...@googlegroups.com
If you want people to print them out your PDF files then I recommend
staying with a standard page size.

What I want to do is embed the small "cropped" pdfs into a Latex document.   I don't want the embedding to take up a whole page, I just want it to be a small portion of the page, where the figure is embedded.    Much like any other pdf embedded in a latex document.  

I've attached two documents, one the result of xhtml2pdf and the other the "cropped" version that I want -- (or rather, my approximation of it "by hand" using pisa to slice off the bottom of the mediaBox).  

What I really want is something like when I export a graphical object from say, Illustrator or OmniGraffle, the bounding box of the image, without any extra white space, is used to set the size of the mediaBox of the PDF document  == instead of having to do this by hand.  
CompositeTable.pdf
ProcessedCompositeTable.pdf

David Bolton

unread,
Sep 17, 2009, 12:42:17 AM9/17/09
to xhtm...@googlegroups.com
Dan Yamins wrote:
>
>
> If you want people to print them out your PDF files then I recommend
> staying with a standard page size.
>
>
> What I want to do is embed the small "cropped" pdfs into a Latex
> document. I don't want the embedding to take up a whole page, I just
> want it to be a small portion of the page, where the figure is
> embedded. Much like any other pdf embedded in a latex document.

Dan,

Sorry I misunderstood. I have not really worked with Latex and forgot
that you mentioned embedding in the first email.

I do not know of a way to change the page size based on the content of
the page using pisa.

David

Reply all
Reply to author
Forward
0 new messages