Rails - Editing PDF template - ruby-on-rails

I need a user to be able edit a pdf template in rails such that a user can customise logo, email signatures, price etc.
I thought prawn looked like a good option but I read that it should now only be used to generate a pdf from scratch.
Any help, suggestions, pointers to tutorials would be really helpful.
Thank you.

The pdf-forms gem can fill out existing pdf files. This has worked well for me for inserting text into a template PDF.
pdftk supports adding images to an existing pdf via multistamp, which is effectively merging two pdfs together (on top of each other). To add an image to an existing pdf, you could use something like prawn to create a pdf with your image, then use pdftk with multistamp to merge that with your filled out pdf:
pdftk filled_out.pdf multistamp logo.pdf output out.pdf
pdf-forms is a thin wrapper on top of pdftk, so it should allow you to pass the multistamp params required. If not, you can add that functionality or shell out to pdftk directly.
Adobe Acrobat Pro is useful for defining your template fields visually in an existing pdf.

I am not sure but try your luck with Wicked pdf.

Related

Export to Pdf via rails

I need to generate report to pdf file, save on the server, than send the file to the client by email.
I am looking to a gem for exporting pdf file
And I want to know if the file keep all the pdf options (like links and the option to select text copy text etc')
Thanks
You can use wicked_pdf gem to generate PDF from HTML. You can configure the options whatever you want in their advanced usage.
Wicked PDF is what you need. It will export to PDF and keep all links, text and images as a real PDF would, because it generates a real, full fledge PDF.

Creating pdf with rails

I need to generate a pdf file and upload it to the AWS upon some action from my controller. I've never done this before with rails, neither created a pdf and then upload it to the aws.
So here is what I'm thinking, how to proceed.
When a action in my controller occurs and it invokes a method a, it will invoke the Job B which is a delayed job who will call the controller method c which has the respond_to and format pdf. And the job will save the .pdf file to the AWS.
The pdf that I'm using needs to be stored on the aws so it can be emailed to a user later. Not sure if this is relevant, just wanted to give more details.
I'm using prawn gem to generate the pdf
Is there a better way to do this, has anyone done something like this before?
http://rubygems.org/gems/wicked_pdf
"Wicked PDF uses the shell utility wkhtmltopdf to serve a PDF file to a user from HTML. In other words, rather than dealing with a PDF generation DSL of some sort, you simply write an HTML view as you would normally, and let Wicked take care of the hard stuff."
I've done something similar using pdfkit. Essentially you just define your PDF layout in HTML/CSS, and when a user adds the .pdf suffic to a path, it attempts to generate the PDF. It's nice because you don't have to actually store generated PDF files, but they'll always be available if someone needs them.

Adding metadata to PDF generated using Wicked PDF

I'm using Wicked PDF to generate a PDF from HTML. I've seen this SO question on adding metadata to a PDF, and it suggests using XMP metadata. How can I use Wicked PDF to add XMP metadata to a generated PDF?
If you are creating the original document using Prawn as you say, then just use the info attribute to set the meta-data you need. See the manual and search for :info. I'm not sure what you mean when you say Wicked PDF adds a title. PDF documents don't have titles (although sections and subsections can in the outline). See this discussion, for example.
If you can't add metadata directly with WickedPDF, you might try using another library to add the metadata after the PDF is generated (a two step process).
I found an SO answer that suggests PDFtk might be able to do that: https://stackoverflow.com/a/18536830/473691.

PDF generation in XCode

I am a newbie in iPhone development. I am planning to do a PDF application for iPhone. The functionality is:
User will type their input in a text field (which is going to be the content of the PDF file).
I have to modify the PDF file through code while saving (paragraphs, tables, bullets etc).
User can save it in their own name.
User can send the PDF file as attachment of MFMailComposer.
So I have searched and got many links. However I didn't find any leading details to create and modify a PDF file in iPhone/iPad.
Can anyone please provide me a good reference to do this. Are there any alternatives to do this?
I've used this reference: https://developer.apple.com/library/ios/#documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_pdf/dq_pdf.html
It contains theoretical explanations and source code examples
Please use the below link to download sample apps for PDF Reader/Viewer in iOS
PDF Reader/Viewer in iOS
Also please look at detail about pdf creation, manipulation etc in below links
developer.apple: PDF Document Creation, Viewing, and Transforming
Fast-and-lean-pdf-viewer-for-iphone
If you were doing a Phonegap app I'd say got for jsPDF, which would enable you to create (basic) PDF files in Javascript. I don't do Obj-C, but a quick look on SO provides good links.

Pdf modification on iOS

I am looking to be able to open a pdf file (done) and then be able to use the touch screen to sign the pdf and then save it with the modification. From what i have read this is no easy task, and i have no idea where to begin. Any of you know any tutorials or frameworks that will help me with this ?
Also if possible being able to modify fields of a pdf file, on the desktop the pdf can have fields you can click on then type in to fill out the form, without the need to ever print. If this is possible as well that would be perfect.
Thanks.
Maybe libHaru (http://libharu.org/wiki/Main_Page) does what you want, it's worth a try.
Does your starting point have to be a PDF? steipete's suggestion of using a system to create the PDF would work if your app workflow could create the PDF (sans signature) and display it, the user "signs" it in your app, and you create the PDF again this time with the signature embedded. It depends on whether this flow is an option for your app. Often it seems easier if you treat PDF as a final document and produce the PDF in it's final form each time (final meaning that you're not going to try modifying it).

Resources