Cairo Multi Page PDF Generation

37 views
Skip to first unread message

Anurag Ohri

unread,
Jun 15, 2018, 8:21:17 AM6/15/18
to diagrams-discuss
Hi all,

I'm using Diagrams and the Cairo backend to generate some PDF documents. Everything seems to be working flawlessly, except the entire PDF document is one page. Is there any way to generate a PDF that contains multiple pages?

Thanks,
Anurag

Ryan Yates

unread,
Jun 15, 2018, 8:37:07 AM6/15/18
to anurag...@gmail.com, diagrams-discuss
Hi Anurag,

I don't think there is support in diagrams-cairo for that, but I don't think it would not be hard to add.  There is support in diagrams-postscript, though it is not fully featured in that it will only produce a file where all the pages are the same size.  I usually use tools like pdfunite or pdftk to do this after generating separate pdf files.

Ryan

--
You received this message because you are subscribed to the Google Groups "diagrams-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to diagrams-discu...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Anurag Ohri

unread,
Jul 9, 2018, 3:06:04 AM7/9/18
to diagrams-discuss

Hi,

I found a Stack Overflow post, that described splitting a PDF into multiple pages. I tried this and it worked.

I myself decide which diagrams go in one page, and after I've created a list of such pages(which I create by joining their contents somehow, each page is a diagram), I render each page using renderDia function in the Cairo Monad.

The renderDia function returns a pair, the second part of which is of type Render (). Now I have a list of Render () values, which I intersperse with the showPage function from Graphics.Rendering.Cairo.

Finally, I use the withPDFSurface and renderWith functions to render the list after passing it through sequence_.

Thanks,
Anurag
Reply all
Reply to author
Forward
0 new messages