Re: Review request for PDF::API2 Tutorial
by graff (Chancellor) on Aug 17, 2004 at 06:22 UTC
|
I realize this is probably something beyond your control, but the version dependency of the tutorial comes across as a rather a serious deficit -- this quote from the fourth paragraph makes it sound like you are providing instructions with a very short life-span:
This document refers to version 0.03.77 of PDF::API2. If you have an older version, I recommend that you upgrade. It may still work, but I'm not guaranteeing it. If you've downloaded version 0.40 or greater you should be aware that it is only a developer release and that the API has changed considerably. This tutorial is guaranteed not to work with version 0.40+.
(emphasis in the original)
Apart from that, I'd feel better about the example code if it included "use strict" and "use warnings". I wanted to check that out for myself, but when I followed the link labeled "You can download the source code here: pdf_api2_tutorial_1.pl.txt", I got a page that said "We can't find your document... We've just upgraded our website and have moved things around..." (seems like your source code may have been "moved" into oblivion).
Minor nit-picks: You open a file named "$0.pdf" -- that's probably not a good idea, because $0 can (often will) include the path along with the script name (i.e. where the script itself is located in the file system, which might not be the CWD, and/or might not be write-accessible to the user). Also, I couldn't tell where, or whether, you were checking for failure to open or write the output file. Does the module handle that for you, and if so, what is the best/easiest/safest way for the module user to handle its behavior on failure? (Your sample code should show how to do that.)
It's obvious that the part at the end is "under construction", which makes the "conclusion" of the tutorial a bit of a puzzle, but for the part that is fleshed out, I think it looks very clear and nicely organized -- I actually know next to nothing about creating pdf content from scratch, and your tutorial (what there is of it) leads me to believe that I could learn in very short time how to use this module to good advantage (provided I start with the particular release that you are writing about ;). To me, that's the mark of true success in a tutorial, and you are definitely on the right track in terms of approach.
Regarding the content of the example text for the pdf page... um, why in Latin? | [reply] |
|
| [reply] |
Re: Review request for PDF::API2 Tutorial
by ctilmes (Vicar) on Aug 17, 2004 at 11:34 UTC
|
I would take your text_block() subroutine, and either
submit it to the PDF::API2 author for inclusion in that module, or submit it to CPAN as "PDF::API2::TextBlock" or some such.
That would give it wider exposure, put it under real version control, provide a central place for storing/updating it, etc. (all the advantages of CPAN.)
It would also simplify your tutorial, since you can
concentrate on the use of the subroutine rather than its internals.
| [reply] |
|
| [reply] |
Re: Review request for PDF::API2 Tutorial
by clscott (Friar) on Aug 17, 2004 at 14:00 UTC
|
I've been wanting a tutorial like this for generating PDFs.
This is fanastic, and easy to understand thank you
I really like the part where you explain the co-ordinate systems and then show the code ( that's very legible!) for using alternate units.
However I'm not sure why you have two sets of units in one equation on line or switch back and forth between pt and mm:
-h => 110/mm - 7/pt
++
| [reply] |
|
Not fair! You're reading ahead!!!
I'll get to that bit soon. I was rather proud of the /mm convention for converting units on the fly. Looks better than mm2pt().
I have the two units in one line in order to accurately measure a position. I'd have to take a look but it looks like I have a text box that needed shortening by one line. I might change that when I get down to it. The text block is 100mm tall, but each line is 7pt apart.
Thanks for the feedback!
Rick
If this is a root node: Before responding, please ensure your clue bit is set.
If this is a reply: This is a discussion group, not a helpdesk ... If the discussion happens to answer a question you've asked, that's incidental.
| [reply] [d/l] [select] |
Re: Review request for PDF::API2 Tutorial
by Aragorn (Curate) on Aug 17, 2004 at 14:08 UTC
|
Very nice!
One thing that annoyed me a bit is the small size of the picture that explains the (Media|Bleed|Crop|Art)Box concepts.
Arjen | [reply] |
Re: Review request for PDF::API2 Tutorial
by revdiablo (Prior) on Aug 17, 2004 at 17:25 UTC
|
Hi! This is a nice tutorial. It's simple, and easy to follow. I have a somewhat off-topic question, though. Do you have any experience parsing PDFs? I've looked at PDF::Parse, and frankly, it seems incomplete. I was wondering if you have any advice for using this, or another module. Maybe you could write another tutorial! :-) (Ok, I'm probably asking too much. But hey, it's worth a shot.)
| [reply] |
|
Parsing PDFs ... what are you parsing them for? Are you attempting to extract the text and pictures?
More information please.
If this is a root node: Before responding, please ensure your clue bit is set.
If this is a reply: This is a discussion group, not a helpdesk ... If the discussion happens to answer a question you've asked, that's incidental.
| [reply] |
|
First, I want to say thanks for the reply! I know the question is off topic, and one could make the case that I should start a new top-level node, but I thought you might have some advice off the top of your head.
what are you parsing them for?
I was trying to extract the text, and regenerate a new PDF with page numbers. It's been a while since I tried this, and I went with a different solution, but it's been bothering me ever since. PDF::Parse seems like it will get me the pages, but after that, I can't see how to get any data from them.
| [reply] |
|
|
Re: Review request for PDF::API2 Tutorial
by RatArsed (Monk) on Apr 20, 2005 at 21:05 UTC
|
Just been following the tutorial with v0.40 -- as a working example I was seeing how hard it would be to build a Cissiculum Vitae (Resumé) out of a DB straight to PDF.
I certainly think it's worth CPANing the text_block functionality. Other comments I'd make would be to fix the link up for the full source, and maybe even have a linky to the final result. Of course, you could go a step further and have the example code write the tutorial as a PDF file :)
If you do CPAN the text_block -- make it take a font handle and a font size -- then you can have a default line-height of (say) 1.2em.
| [reply] |
|
| [reply] |
|
| [reply] |
Re: Review request for PDF::API2 Tutorial
by Jaap (Curate) on Aug 18, 2004 at 12:22 UTC
|
Very nice, BigLug! Thank you for the time you spent on it. Now i finally onderstand all the boxes in pdf. You really do explain it very well, in an easy-to-understand way. | [reply] |
Re: Review request for PDF::API2 Tutorial
by k2 (Scribe) on Oct 13, 2004 at 11:10 UTC
|
Nice work!
I think I have tried to write a tutorial for the PDF::API2 about 3-4 times now, but haven't managed to finish the work, and when compared to the work you have done I think we should all be greatful for that. ;-)
Nice with the professional explanation of media/crop/bleed/art-boxes.
/K2 | [reply] |
Re: Review request for PDF::API2 Tutorial
by zachzippo (Novice) on Sep 15, 2004 at 20:14 UTC
|
Looked good, but was unable to retreive the sourcecode, something at your site was preventing it. | [reply] |
Re: Review request for PDF::API2 Tutorial
by GhodMode (Pilgrim) on Jan 13, 2006 at 14:08 UTC
|
In the text_block subroutine, doesn't the following line give the width of the digits used to identify the hanging indent rather than the actual size of the hanging indent? ...
my $hang_width = $text_object->advancewidth($arg{'-hang'});
... from pod2text Content.pm ...
$width = $txt->advancewidth $string [, %textstate]
Returns the width of the string based on all currently set
text-attributes or on those overridden by %textstate.
So, if I call the subroutine with -hang => 30, intending to have a 30 PS point hanging indent, it'll actually set it to the width of the string "30".
Did I find an error, or did I just misunderstand something?
Thanks,
-- Ghodmode | [reply] [d/l] [select] |