Dynamically Generate Editable PDF - ruby

Is there a way to create an editable PDF programmatically? By editable, I mean you can click in a text area and type in your name, that kind of thing.
I'm using Ruby and have found PrinceXML and Princely to be nice projects. I'm wondering if they could do that?

Prince doesn't mention forms in the documentation, and renders forms as static drawings, so I doubt it.
pdfTeX can do it with the hyperref package. Here's a tutorial.
Example:
\usepackage{hyperref}
\begin{Form}
\TextField[backgroundcolor={1 1 0},value=can do forms]{hyperref}
\end{Form}
It looks like this:
screenshot http://grab.by/23nP
(Of course, then you're using TeX instead of whatever reports library you like. I'm sure there's an alternative.)

Related

How to translate between user mouse coordinates and PDFDocument coordinates?

I'm working on an app for Macintosh. I want to have the user be able to click inside a PDF rendered onscreen and have an annotation appear where they clicked (or selected). Should/can I use PDFKit for this? I looked at the classes, but PDFSelection seems to deal with text, not coordinates. Specifically, I want to know which classes I should use to achieve this. I've read the PDFKit programming guide, but I'm still not quite clear as to the path forward.
Apple provides sample code, PDF Annotation Editor, its description is:
This sample application uses PDF Kit to examine, edit, and create PDF annotations. It has an inspector panel that shows various attributes of supported annotations. The inspector allows users to edit those values. Additionally, annotations can be created and the code demonstrates how to use PDF Kit to do this. Also, the sample code demonstrates subclassing of PDFAnnotationStamp in order to override the draw method and draw your own custom annotation content. Finally, the sample code demonstrates subclassing PDFView in order to overlay your own content over the PDF content being displayed.
This would appear to answer your questions, in particular look at mouseDown in PDFEditView.
HTH

Embed images using FlashDevelop - AS3

I'm not finding much documentation on embeding images in .as files. Really, I'd like to have some theory on it. So far from what I got reading here and there:
I placed an image in Assets folder inside src. Then right-clicked the image and clicked "Generate embed code", then this code line appears where the cursor was [Embed(source="fluffybunny.png")] what now? How do I assign it to a variable or something... I really didn't find it out there.
Instead of given object using .graphic atribbutes I want to use an image.
Also, does it have to be an .SWF?
There are quite a few resources on this (when you search for "as3 use embed tag"). Some of them are really helpful:
http://www.bit-101.com/blog/?p=853
http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf680e1-7ffe.html
The most basic thing is that you declare a variable of some type. And you use the [Embed] tag before the variable declaration. It's some kind of weird association. Something like:
[Embed(source="image.jpg")]
public var imageClass:Bitmap;
// later on you can instantiate it and use:
addChild(new imageClass()); // creates and adds new image
This is just a sample - there are a lot of types and ways to do it - give a shot the Adobe reference, there are tons of samples.

Adding Code Samples to A Slideshow Presentation

I'm making my first technical presentation, and I'd like to add some code samples (ruby in my case). What's the smart way to have nicely formatted with color code samples?
For example, when I code VIM looks like the attached image. I'd like to duplicate something similar in my presentation without manually changing the colors of characters.
MagicPoint can easily include images into slides, so if you've got screenshots of your code (as you do here), you can simply:
%image "index.png"
inside your slide's content.
If you're looking to avoid taking manual screenshots, you can probably convince Google Code Prettify or coderay to emit output in some format that can be used with MagicPoint's %filter command.
When I had to do that, I used PDF-Latex with the class "beamer" for the presentation and the package "listings" for code samples. It supports syntax highlighting including colors for Ruby.
After some initial learning, it worked like a charm.

Image/form to Pascal/Delphi code converter?

Does anyone knows about any editor allowing to visually design a form (by form I do not mean DFM or Delphi form, but a "paper form", like those pre-printed forms that you fill with some info) and that generates pascal commands to draw that form in a Printer (or Image) canvas?
What I want is an easy way to draw/design this form visually, composed just by lines and text, and a way to convert this to Pascal commands that when run, will draw that form in a Canvas (Image or Printer), respecting the original layout and scale, doesn't matter the Canvas DPI where it is being drawn.
Update: Maybe I wasn't clear enough about what I need and why I need it. I developed an Open Source component called TFreeBoleto (freeboleto.sf.net). It is used to generate and print bank billets (a common method for billing people in Brazil). Right now, the component uses a TBitmap image containing the "billet" mask, and TextOut methods for the dynamic areas (ie: billet number, customer name, etc). It is fine when looked in the screen, but some people complains that the quality of the printed image is not good. The component uses a BltTBitmapAsDib procedure to maximize the quality of printing, but some people still think it is not good enough. So, my idea was to avoid using a bitmap image as the form layout, and draw everything direct in the canvas (both form and printer). Check here for a sample of what a bank billet looks like.
Of course ReportBuilder and/or FastReport could solve the problem, but they are not free, so I cannot include it in the component. I need "native" solution that any standard Delphi install would be able to compile.
You might get what you want out of the Fast Reports Report Designer which is a commercial reporting system for Delphi. Remember that a report is just a page. That page can be shown on the screen or printed on the printer.
You also might find that something like TRichView helps you.
Whether using TRichView in particular or not, I would look into using HTML to do what you want. I would use HTML+CSS to do both a screen and printer layout, that can also be viewed on the web. For simple text layout plus text boxes I think even bare HTML and HTML tables might be sufficient. To visually design simple text pages, using a Delphi application, I would use TRichView.
In both cases, you would be creating documents, not code. To create code that creates a page, without using any document system, would be very difficult indeed, and I am not sure what you would really do with that code, since you would need a compiler or interpreter to convert that code into something that you could use. Please clarify what you mean by "creating code", and what syntax you would want that code to be using. If HTML is code in your definition of "code" then maybe HTML is the best kind of "code" for your problem.
I do my form-work with WPTools. It is also a commercial product. The core is a very good wordprocessor and form-designer. The engine can render text and forms to any canvas (screen, printer, also create pdf) and is highly flexible. Output is mainly rtf and html.
I also see no advantage in creating pascal code to redraw the form. What you need, i think, is a good WYSIWYG-editor which creates a document that fits your needs.
Check out ReportBuilder # http://www.digital-metaphors.com/
It is a commercial reporting tool for Delphi - around a long time, very high quality, with all native Delphi source code packaged with it. I am using it for an important commercial project right now and I recommend it highly (I'm not working for them.) I've used MANY Delphi reporting tools over the years and this one is the best IMO.
RBuilder also has extensive support for paper form emulation see:
http://www.digital-metaphors.com/products/report_design/form_emulation.html
I haven't worked with that feature, but you can download a full-featured demo and try it.
Yoy can use Adobe Acrobat (full version) to create forms.
Then you can use free Acrobat Reader to display and print forms or other COM object in your application.
I think it is best solution for you.
PS
All tools for reports that are included in Delphi are free for you to design form and are free to distribute if user only preview and print already designed reports.
The same is valid for Adobe Acrobat (you may distribute forms) but you have added that you need to print form and some text over form. Maybe it is easier if you use reports but it is possible to do the same using PDF.
Most report engines are not open source but are free to distribute. There is many components for creating PDF - paid (one time), free, as well as open source.
PPS
I have read your updete for second time. Since you are using TBitmap and you can to TextOut so: You can use TMetafile. There is many editors for metafiles and it is free to distribute metafiles.

Cocoa: Creating a Custom Text View

In a nutshell, I don't want raw text, or even rich text. I want to load an xml document, which has metadata for sections of text, and I want to display that metadata in a drawer when I click on a given text section. A hyperlink is a good example; obviously trivial to do in a web app, but while I'm not that experienced with mac dev, I can't seem to find an easy way to accomplish this with cocoa.
Any suggestions as to general strategy? There doesn't seem to be an HTML view built in to Interface builder or I'd mess with that.
I'm not entirely clear on what you're trying to do. It sounds like you want to load an XML document, display the text, and display various metadata when certain bits of text are selected.
If that's the case, you should read about the Cocoa Text System. The NSTextStorage class is a subclass of NSMutableAttributedString, and you can apply arbitrary attributes to any range of text. When the selection changes, you can get the attributes in the selected range and use that to update your drawer. (By the way, drawers are really on their way out. I'd suggest a different user interface. NSSplitView-based interfaces are much more in vogue these days.)
Of course, to build up the NSTextStorage, you'd need to parse the XML with NSXMLDocument or NSXMLParser, but you'd get much more control and it would look more "Cocoa-like".
You could use a WebView, which is the Safari renderer, but I think you'd have a hard time getting it to display text the way you want. Safari has never been great at rendering XML without XSLT.

Resources