Converting content page into PDF and save it into DAM | Community
Skip to main content
New Participant
Sep 2, 2018 2:31 PM UTC
Solved

Converting content page into PDF and save it into DAM

I need to convert the content page in a pdf format and save the pdf in dam.

I am able to create pdf file in dam from the below url with a string data but unable to read data from the content page.

Adobe Experience Manager Help | Creating a custom Adobe Experience Manager PDF service

Can anyone suggest me how can i proceed. I am using AEM-6.4

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
arunpatidar
arunpatidarAccepted solution
New Participant
Sep 3, 2018 10:21 PM UTC

Hi,

You can read complete HTML from inputStream and convert into string then create PDF.

Still CSS images are not gonna work with this.

like below:

URL url = new URL("https://www.example.com/");

  URLConnection conn = url.openConnection();

  // open the stream and put it into BufferedReader

  BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));

          StringBuilder out = new StringBuilder();

          String line;

          while ((line = reader.readLine()) != null) {

              out.append(line);

          }

          reader.close();

  boolean success = HtmlToPdf.create()

      .object(HtmlToPdfObject.forHtml(out.toString()))

      .convert(pdfFilePath);

Arun Patidar

3 replies

arunpatidar
arunpatidarAccepted solution
New Participant
Sep 3, 2018 10:21 PM UTC

Hi,

You can read complete HTML from inputStream and convert into string then create PDF.

Still CSS images are not gonna work with this.

like below:

URL url = new URL("https://www.example.com/");

  URLConnection conn = url.openConnection();

  // open the stream and put it into BufferedReader

  BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));

          StringBuilder out = new StringBuilder();

          String line;

          while ((line = reader.readLine()) != null) {

              out.append(line);

          }

          reader.close();

  boolean success = HtmlToPdf.create()

      .object(HtmlToPdfObject.forHtml(out.toString()))

      .convert(pdfFilePath);

Translate
Arun Patidar
New Participant
Sep 3, 2018 7:03 PM UTC

Hi Arun,

We have used "https://github.com/wooio/htmltopdf-java". but its giving exception , we have tried with itext also but its not reading the images , can you please tell me  how can i read the image because my html file contains images also.

Translate
arunpatidar
New Participant
Sep 3, 2018 5:38 AM UTC