This project has moved and is read-only. For the latest updates, please go here.

Template option

Apr 10, 2015 at 7:18 PM
Hi,

First off, this is a fantastic app - kudos!

I am interested in knowing more about the /template option. I am looking to transform a number of doc files into PDF's but I need to apply a template to those docs during the process. My assumption was the /template option might allow me to do this. Can you provide more detail around this switch?

Thanks in advance,
Colin.
Apr 12, 2015 at 4:15 PM
Hi Colin

The template option lets you specify a template (.dot, .dotx or .dotm) file during the conversion process. Template files in Word store things like default styles used in a document, rather than any specific content. See http://word.mvps.org/faqs/customization/CreateATemplatePart1Content.htm#_What_is_a for a bit more information.

The /template option allows you to use a specific file as a template when converting files. When used, the template will be attached to the file being converted, and the styles updated prior to creating the PDF. This option is useful for cases where the normal template on the PC used for conversion is different from the one used to create the document being converted. Note that the template won't affect the layout of the document, just the styling applied to the content of the document being converted.

If what you want to do is take a plain Word file, change its format and layout to a standard design based on a template and then create a PDF from the new file, you would need to do it in two stages. Stage 1 would be to create a new document based on the template, then insert the content page into it. This new file could then be saved and passed to officetopdf.exe.

Hope that helps
Regards
Vittal
Apr 12, 2015 at 4:34 PM
Colin

FYI, we have a test version of Officetopdf.exe which allows you to create a document from a template, insert text into the new document from the file to convert, and then create the PDF from this constructed document. e.g.

officetopdf.exe /merge /template c:\docs\mytemplate.dotx c:\files\somedoc.docx c:\output\somedoc.pdf

The line above will create a new document from mytemplate.dotx, insert the text from somedoc.docx and then save the whole lot out as somedoc.pdf.

Let me know if you'd be interested in trying it out.

Regards
Vittal
Apr 21, 2015 at 4:18 AM
Hi Vittal,

Yes I would be interested in testing this out. I think what you have done is pretty much what I am attempting to do. In the meantime I delved into the OpenXML SDK and performed the merge of the Template and the Document but I would still be very interested in looking at this from what OfficeToPDF is doing,

Thanks
Colin.
Apr 21, 2015 at 10:35 AM
Hi Colin

I've put a build that provides the /merge option here:
https://www.dropbox.com/s/hw6fj6qmz5034n7/OfficeToPDF.exe?dl=0

This will create a new file based on the template (given by /template), insert the file to convert and then save as PDF. In addition, it adds support for .txt, .htm and .html files, making it easier to format these sorts of documents with some standard formatting from the template.

Let me know how you get on.

Regards
Vittal
Marked as answer by cognidox on 6/15/2015 at 4:33 AM