 Hi everyone. Let's get started now. We'll be talking about creating and human amazing PDS using Rupa8. Thank you for coming. My name is Tahir. I work at Accelerant as a software engineer. We have distributed team delivering digital solutions. You can find me on Twitter at DevTahir. So let's first know what PDS is. I think most of you here might be well aware of what it is. But still, it helps. It was invented by I mean it was created by Adobe. Primarily to standardize the text formatting, images, vector graphics and it is independent of OS which it displays on. So that's one of the key things what PDS solves. It is hardware and application independent. Now let's see how Drupal comes into picture. So Drupal has powerful capabilities with regards to creating structured content. It also has a good and robust editorial workflow. So if you are creating lots of documents online and you have lots of people involved, you can make use of editorial workflow which is provided by Rupa8 and Rupa8 as you all know is enterprise-ready. What happens if we combine the powerful capabilities of Rupa8 and PDS? There are lots of exciting possibilities which we will explore in a brief during the session. So the next question would be how do we get started? The first part is find out why you require a PDF based solution for your use case. So during this stage you just need to answer a couple of questions. What is the use case? For example, you can have a brochure, a product specification, a book, a test paper, etc. Does your use case require reusability? Are you going to create one type of document again and again? Do you have lots of documents which are of one particular type? You just need to build that again and again to save time. You can select Rupa8 and the talk I'm about to give is about that. So we will take a very basic example. I think you already have a Drupal booklet which was given to you. You see we will take this as a case study. We just need to generate an event book and it can be replicated at more events coming forward. Is it reusable? Yes. So I want everyone here to look at the screen and try to understand just the layout of this page. It's page number 10 and page number 11 in your book. Try to find what you can reuse. What does this page look like? As we see on the top there is title in the header, on-site resources. In the photo we have the page number, we have the wifi password, and Drupalgon Amsterdam written here. So that's the header and the photo of the document. It will be remaining the same in the photo of the document. The next thing is it has a brief description on the top. Then it has a lot of cards which has a icon, a title and a description which is just repeated, reused again and again. To summarize what we can do is identify the field structure of the PDF you are about to create, style the PDF, layout of the PDF. What is the layout here? We have a header, we have a photo, we have a two column layout, and we have cards. Styling the PDF fields, we have fonts, font sizes for each and every element, colors, page nation. Page nation is an important part when you are working with PDFs. Character limits for PDF fields. For example on the header we have a big font. While designing the designer should take care of the character limits of each and every field. For example the title, the description, we can limit it to around 500 words or something like that. The image dimensions. Here it's just a 50 by 50 or 100 by 100 image. We have to make sure that what kind of images will be accepted while entering the content. So yeah, that's the brief about designing the PDF before we jump into Drupal things. Next one, setting up, duplicate backend. So as we create content, we set up a basic content type for this. It's called structured PDF. It has a page title, it has a page description and it has a resource card. Simple enough. Resource card is an entity reference field. We'll take one example. We will limit the maximum length to 50 characters for the page title. And you can have multiple limits on all of your fields. It's not really necessary but I would recommend you have limited amount of characters at specific fields so that your output will be more predictable. Next thing, there is this module called entity print written by Benji. It's a very well-architected and a good module which has lots of flexibility for our use case. You just install the module using Composer. Enable the module. Next thing, we need to configure the module. So if you go to admin config content slash entity print you will get this page where you can have these options. So there are multiple PDF generators which entity print supports. It is recommended to use DOM PDF because it actually mimics the HTML you write, the HTML and CSS you write as it is and it's big enough friendly and it has lots of customizability. So we will be using DOM PDF in this example. There are other PDF generators supported as well like MPDF WKHTML. You can find more about it in the entity print docs on Drupal.org. Then the next thing is you can select the paper size. Now paper size is not just fixed. We can actually extend the entity print module exactly to actually have the paper size which we require. So entity print is very extensible in that way. It's very flexible. You can define your own paper sizes there. And also you can support multiple engine PDF generator engines as well. So MPDF by default is not supported by entity print but if your use case requires more PHP oriented support and not more of HTML and CSS you can use MPDF. It provides lots of flexibility as well. It has its own limitations but that's what you can do. You can extend the module to use your own PDF generator. And these are the other options it can force you to download whenever you click view to PDF. View PDF. We'll see that in the coming slides. The next thing is you have configured your module now in your managed display for your content type. You'll have an option called view PDF. You just need to drag it from the disabled section to the enabled section and you'll get a view PDF link on your node view of that particular content type. So let's summarize what we did. We did set up the fields. We installed the entity print control module. We configured entity print. Then we displayed the view PDF link on the node. Optionally here what site builders and backend developers can do is configure your content type with workflow for the PDF content type so that it's more towards publishing and if you have custom workflows to create these content you can do that right now. Okay the next step, setting up the Drupal frontend so there is entity print. What it does is it takes your node template and it generates the PDF for you using the engine which you selected. So there is nothing very PDF specific you need to write. You just need to modify your node template. Here for example you can just add structured PDF HTML.trick file and you're all set. You just need to print the fields here. Now is the fun part adding custom CSS library to the entity print. By default entity print gives a basic support for most of the HTML elements but if you are working on a complicated or a complex PDF solution you would want your own styles and your own library so you just need to clone the entity print node content, the entity print dash dash node. This is the template in entity print module which you need to, you can override it very content specific right. So for node.structured underscore PDF you just copy paste the content of that file into this file. Make sure you have entity underscore print underscore CSS and the content where you will print it here otherwise it won't work. The next thing you need to override the library used by entity print so if you just want a CSS library to be included in your structured PDF content type you just have entity underscore print node and structured PDF and give the library name. Here we have the library name as structured PDF and if you want for all content type like if you have multiple content types which are generating PDFs for you you can have a basic style included for all of them using the all keyword This you need to do in your test.info .yml file. Next thing is you actually define the library in the libraries.yml file here you have two files one is for the layout and one is for the actual theme. Let's summarize what with it we created a custom node type quick template, we added custom CSS library to the entity print, we overwrote the library used by entity print. We defined custom CSS library in our theme library's file. Now we just need to take care of some PDF considerations while you are working. First one is pageination. If you have for example this page it's just page number 10 and 11 so you need to have customized page information for each and every page. You need to have available which informs which you can print on the node template you need to see how much images support your PDF generator gives you. DOM PDF has quite good support for PNG SVG files MPDF has very wonky support for images so you might want to take care of that. CSS support in various PDF generators that is important while you are selecting your PDFs generators. See look for the library which is having more of CSS 3 and CSS 2.0 support you can read more about DOM PDF on DOM.pdf.github.io and MPDF is basically more like a PHP based where you can control the styling using PHP. So make sure you check that out as well. Moving forward like what are the kinds of solutions we can build using this. I just want to spark some imagination from the crowd here for universities we can have brochures which are like very constant like for various departments the brochures look the same. You just have to change the content in that. Course catalogs, test examination papers. They all have like a basic template which you can develop using books. Books are a bit complicated but we have done books in one of the use case which we did for our clients. For enterprise we have product catalogs, specification sheets, technical documentations. Anyone from the crowd wants to add to this what can we create? Reports. Badges. Certificates. So the possibilities are endless. We did a couple of solutions for Fortune 30 company and they have like thousands and thousands of products which they want specifications for and it was a really head product in their tooling so I would like to thank everyone of you for being here. If you have any questions please you can catch me on Twitter at Dev Tahir and please give feedback for my session on the events side. Thank you. I would like to catch up with anyone of you who have any questions later. See you all. Thank you.