Transforming HTML to PDF

Having trouble installing Oxygen PDF Chemistry? Got a bug to report? Post it all here.
InspectorSpacetime
Posts: 38
Joined: Thu Jul 29, 2021 12:02 pm

Transforming HTML to PDF

Post by InspectorSpacetime »

Hello,

Is it possible to use Oxygen to transform HTML to PDF (with CSS)? I would presume so, since this is essentially what the PDF Chemistry does in it's last phase. If so, what is the correct process to do this?

There is no transformation scenario labelled "HTML to PDF" or such, but I saw that in some of your YouTube tutorials you used the "XML to PDF transformation with CSS" for HTML files as well. Is it as simple as that?

The reason I'm asking is that Chemistry supports the CSS paged media module very well. Besides Oxygen and DITA, I'm sometimes using Markdown to create some HTML stuff, and I'm looking for a way to format them into PDF with headers, footers and everything CSS paged media does. It's a shame that browsers don't really support the CSS paged media module. Formatting HTML to PDF would be really easy by just using the browser's print function!
julien_lacour
Posts: 498
Joined: Wed Oct 16, 2019 3:47 pm

Re: Transforming HTML to PDF

Post by julien_lacour »

Hello,

Of course you can use Oxygen PDF Chemistry in order to transform HTML document into PDF.
You have to open the transformation dialog and use the "XML to PDF transformation with CSS" option. It is as simple as that :D

Regards,
Julien
patjporter
Posts: 53
Joined: Sat May 22, 2021 6:04 pm

Re: Transforming HTML to PDF

Post by patjporter »

Hello,

I have an similar question. I am trying to use HTML to create a cover page for a document. I many of these types of pages for many documents. The documents are compilations of PDF documents and the cover page acts as an index. These pages get updated somewhat frequently, so HTML seemed like a good way to structure the documents….to date they have been done with PowerPoint, creating, sizing and moving boxes, adding text and then adding hyperlinks to the text.

It is much quicker to just update an HTML file.

When the file is updated, what I want to do is “print” it as a PDF document sized to 8.5” tall by 5.5” wide, and if it won’t fit on one page have it overflow to the next page.

I also need the text to be an active hyperlink when “printed” to PDF. I have tried to use HTML to PDF with CSS but the page did not size correctly nor did the hyperlinks come through.

Was hoping you might have some suggestions / guidance!

Thank you,
Pat
julien_lacour
Posts: 498
Joined: Wed Oct 16, 2019 3:47 pm

Re: Transforming HTML to PDF

Post by julien_lacour »

Hello Pat,

After creating your custom CSS style-sheet, you can debug you CSS to see a preview of your PDF document.
Then you can use the CSS @page rule to define your page sizes, margins, etc.
Finally, you can create external links by using the link property.

If you still have issues with your PDF output, you can email us your HTML sample (randomized if it contains sensitive information) and the CSS customization at support@oxygenxml.com.

Regards,
Julien
patjporter
Posts: 53
Joined: Sat May 22, 2021 6:04 pm

Re: Transforming HTML to PDF

Post by patjporter »

Hi Julien,
Your tips were very helpful, thank you!

Two follow up questions...and thank you for your patience!

1. When I "Save As PDF" using the "Print" function of my browser, I set the page output to 5.5 x 8.5, which is what the HTML @page is set to, but I get a white 1/4' or so border (see attached). Do you have any suggestions to get the page to save as PDF without any kind of border? In the print settings I have the margins set to 0" all the way around, so I am not sure why I am getting this.

2. This may be outside your area of expertise but I thought I would ask. My intent is to use this HTML based PDF cover page as a hyperlinked index to a composite document that consists of several PDFs that are combined using the Adobe Acrobat "Organize" feature. Sometimes we have to add new documents to the composite document. The buttons on the cover page are intended to link to the first page of each document inside the composite document. We typically use Adobe Acrobat to create hyperlinks to those internal pages. Would you happen to know if there is a way to do this with HTML "href", i.e. create the destination inside the composite document once, and then create new ones when we add new documents inside the composite document and code them inside this top level index page in HTML? This way we only have to code it once, and then just add new href links when we add a new document inside the composite PDF. Hopefully that makes sense and you understand what I am asking!

Thank you!
Pat
Screen Shot 2022-01-09 at 11.41.42 AM.png
Screen Shot 2022-01-09 at 11.41.42 AM.png (181.25 KiB) Viewed 3790 times
julien_lacour
Posts: 498
Joined: Wed Oct 16, 2019 3:47 pm

Re: Transforming HTML to PDF

Post by julien_lacour »

Hello Pat,

If you are using the "Save As PDF" action from your browser, you will not use Oxygen PDF Chemistry but the built-in functionality of your browser (which may not have full support for @page media).
If you plan to use Chemistry, you can download it here and use it as a separate process (by command line), or within Oxygen (if you already have it).
You should get rid of the margins in the output generated by our processor.

Regarding the link creation in the cover page, you can try to create internal links before organizing the PDFs with Acrobat Reader, but the only possibility for these links to work is for Acrobat to provide the anchors to each target PDF. Without these anchors, none of the links will work.

Regards,
Julien
Post Reply