Generating a PDF report dynamically

In my rails application, I am looking to generate a PDF report
dynamically.
The layout would be static and given to me by a designer who has made it
on
Adobe Illustrator. I need to use the layout and just update the values,
create the PDF out of it and let the user download it.

Could you please suggest the best way to accomplish this?

Thanks,
Ganesh

Ganesh Ranganathan wrote in post #1141105:

In my rails application, I am looking to generate a PDF report
dynamically.
The layout would be static and given to me by a designer who has made it
on
Adobe Illustrator. I need to use the layout and just update the values,
create the PDF out of it and let the user download it.

Could you please suggest the best way to accomplish this?

Thanks,
Ganesh

You can use any of these excellent tools to generate PDFs from HTML

https://www.ruby-toolbox.com/categories/pdf_generation

I’m pretty certain though that there is nothing out there that will
parse an adobe illustrator file for you.

On Thu, Mar 27, 2014 at 1:04 AM, masta Blasta [email protected]
wrote:

I’m pretty certain though that there is nothing out there that will
parse an adobe illustrator file for you.

Thanks masta. Is there any intermediate file format that both Prawn and
Illustrator/Indesign can talk with. The person designing the report only
knows these two tools which

On Thu, Mar 27, 2014 at 1:51 AM, masta Blasta [email protected]
wrote:

Got it!! Thanks for the explanation. Would the same process that you
explained work in this way?

  1. Create a layout in Indesign (not illustrator)
  2. Export the layout to Html/CSS. This is a built in feature
  3. Embed the HTML in the template.pdf.erb
  4. Supply the values dynamically in the template
  5. Generate the PDF

On Mar 26, 2014, at 4:33 PM, Ganesh Ranganathan wrote:

configurations. It’s not a simple process because of the wkhtmltopdf

You beat me to it. This is what I was going to recommend. You may find
that you have a lot of cleanup needed to make the InDesign HTML (and
CSS) less awful. But this should get you started.

Walter

On Thu, Mar 27, 2014 at 2:12 AM, Walter Lee D.
[email protected]wrote:

You beat me to it. This is what I was going to recommend. You may find
that you have a lot of cleanup needed to make the InDesign HTML (and CSS)
less awful. But this should get you started.

I’m going to first try it on a simple one page report to check the
feasibility. Then move on to the full featured report. Hopefully the
cleanup of the markup won’t be too tedious

Ganesh Ranganathan wrote in post #1141109:

On Thu, Mar 27, 2014 at 1:04 AM, masta Blasta [email protected]
wrote:

I’m pretty certain though that there is nothing out there that will
parse an adobe illustrator file for you.

Thanks masta. Is there any intermediate file format that both Prawn and
Illustrator/Indesign can talk with. The person designing the report only
knows these two tools which

No. It just can’t work that way.

Prawn uses its own syntax (DSL) to create a PDF. It is ruby code that
has to be written from scratch.

Something like wicked_pdf, turns an HTML document into PDF. That means
you need your document to be an ERB template that you can then use the
plugin on to get a PDF.

There is no way to automate the process in the way that you want - Read
.ai, parse .ai, find my fields, plug in these values into those fields,
spit out a PDF. That is such a hugely monumental process, that I don’t
even think any proprietary Adobe software does it.

Rails can do a lot of things, but not that.

You need to MANUALLY turn your illustrator file into a template.pdf.erb
file (which is the same as a .html.erb file). You will need styles,
proper HTML, the whole works.
Then you make a controller action to accept the pdf mime type
respond_to do |format|
format.pdf {}

then follow the instructions on the wicked_pdf gem for all the other
configurations. It’s not a simple process because of the wkhtmltopdf
binary.

I’d try saving the Adobe Illustrator to XML (or to PDF and then have
Adobe Acrobat save it to XML) and finally let flying-saucer have a chew
at it and see if it will make a descent PDF out of it.

If so,

then you could take the XML, rework it in your rails app, spit out the
XML back into the ‘queue’ and, voil :slight_smile:

But does the designer not master Adobe Dreamweaver or some HTML Designer
tool? Then have him design the form in that tool and have him spit out
HTML 4.1, skip the Adobe Illustrator -> PDF -> Acrobat -> XML part of
the ‘game’ and go straight to

HTML -> flying-saucer -> PDF

works for me :slight_smile:

Den 26/03/2014 kl. 20.42 skrev Ganesh Ranganathan
[email protected]:

On Thu, Mar 27, 2014 at 11:16 AM, Walther D.
removed_em[email protected]wrote:

But does the designer not master Adobe Dreamweaver or some HTML Designer
tool? Then have him design the form in that tool and have him spit out HTML
4.1, skip the Adobe Illustrator -> PDF -> Acrobat -> XML part of the ‘game’
and go straight to

Thanks, that’s a much more simpler way because I think Dreamweaver would
generate cleaner markup than Indesign. Will check with the designer.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs