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.

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

Ganesh Ranganathan wrote in post #1141109:

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.

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

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.

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

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

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

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:

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