Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Convert PDF to HTML

Explorer ,
Jun 15, 2009 Jun 15, 2009

Does anyone know if there is a way in ColdFusion to convert the contents of a PDF into HTML to use where needed in my CF app? I am auto generating a huge PDF file using CFDOCUMENT. I need a way to take the contents of an existing PDF, which is basically just a table with some data in it and insert it in a specific spot in the master PDF. I do not want to do a "merge" of multiple PDF's, I know how to do that. I actually need to take the contents of one PDF and insert it in a specific spot in the PDF I am creating. I don't know if this is even possible.

4.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jun 16, 2009 Jun 16, 2009

hi,

    1) Firstly you read the master PDF into variable

     2) Paste variable(in step 1 variable) content to the desired location in the CFDOCUMENT  while creating the huge pdf file.

Hope this will help you

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 17, 2009 Jun 17, 2009

So I did a CFFILE and read the PDF into a variable, but when I CFOUTPUT it into the main PDF, it's just gibberish on the screen. I'm assuming there must be some kind of conversion I need to do?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 17, 2009 Jun 17, 2009

I think you can use CF8 and DDX to build your new PDF. Something like

this (not tested):

...
<PDF result="result.pdf">
	<PDF source="initial.pdf" pages="1-10"></PDF>
	<PDF source="inserted.pdf"></PDF>
	<PDF source="initial.pdf" pages="11-last"></PDF>
</PDF>
...

Mack

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 18, 2009 Jun 18, 2009

I've actually tried that, but what that does is put the source PDF's one right after another. So yes I could dynamically create one PDF and then "merge" that PDF with other already created PDF's in to one big PDF. What I need to do though is actually "paste" the contents of one PDF into the PDF that I am creating with CFDOCUMENT. Think cfinclude. So as I am creating a dynamic PDF with cfdocument adding text and headers etc, I need to go grab the contents of a PDF which in this case is just a table of data and insert it into a page of my PDF and then immediately after the table continue adding content on the same PDF page. I don't want the included content to be its own page. I can use cfpdf and do "merge" to accomplish that. I am slowly starting to realize that this isn't possible, but if anyone else has any ideas let me know

THANKS

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jun 18, 2009 Jun 18, 2009

ehaemmerle wrote:

I need to go grab the contents of a PDF which in this case is just a table of data and insert it into a page of my PDF and then immediately after the table continue adding content on the same PDF page. I don't want the included content to be its own page. I can use cfpdf and do "merge" to accomplish that. I am slowly starting to realize that this isn't possible, but if anyone else has any ideas let me know

THANKS

While there are tools for converting pdf to html (with varying levels of success),  it sounds like more complexity than is needed.  You might try a simpler approach.  Convert the second pdf to an image, then insert the _image_ of the page instead.  You may need to crop it, but it might do the trick.

BTW, how is the second pdf created? Since you posted this question, I am assuming you are not creating it yourself with cfdocument 😉

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 18, 2009 Jun 18, 2009

HMMM that just might work. How would I go about converting a PDF to an image though in CF? And yes you are correct, these PDF's have already been generated and I have no control over them. I kind of have to include them as is.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jun 18, 2009 Jun 18, 2009
LATEST

The simplest way is to use <cfpdf action="thumbnail" ...> and scale it to 100%, or whatever size you need.

http://www.coldfusionjedi.com/index.cfm/2007/7/30/ColdFusion-8-Working-with-PDFs-Part-8

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources