Question

Trying to format CSV files to nice tables in Word or PDF... Newbie needing assistance!

  • 24 February 2022
  • 7 replies
  • 29 views

I'm trying to output CSV files to Word or PDF. Formatting issues... not sure which transformers to use and what settings to use... Thank you in advance!!!

 

image 


7 replies

Badge +2

Hi @shawn.brandt​ ,

 

The MSWordStyler will likely come in handy here before connecting to the writer/FeatureWriter. When it comes to PDF, there is also an FME Hub Transformer called the TableAdder which can be used to generate the text/outline features in a table format. This can be used in tandem with the PDFStyler and PDFPageFormatter to style the font/color/etc. and position it on the page.

 

Depending on what you are putting into the table, the MSWordStyler might be easier to work with as the word document will wrap the text for you (more flexible). With PDF, you have to do all of the formatting (i.e. text wrapping) before creating the text feature with the TableAdder.

image 3OK... I believe I have the MSWordStyler... and I think I am using it properly....

 

image 4I understand the "stretch" or using "inches/CM" and how to put in a number value...

 

 

I believe I am using the MSWordTableAdder....

image 7Should I be using TableAdder or MSWordTableAdder???

 

My next question comes with the FeatureWriter...

 

image 6If I'm wanting to have the font size to be 10... I'm not understanding how to modify that, or other parts of the table. When I write the table to MSWord... it only opens up a "letter" (8.5x11) in "portrait" with "normal margins"... I was needing a "tabloid" (11x17) in "landscape" with "narrow margins".

 

 

Badge +2

Hi @shawn.brandt​ ,

 

The MSWordStyler will likely come in handy here before connecting to the writer/FeatureWriter. When it comes to PDF, there is also an FME Hub Transformer called the TableAdder which can be used to generate the text/outline features in a table format. This can be used in tandem with the PDFStyler and PDFPageFormatter to style the font/color/etc. and position it on the page.

 

Depending on what you are putting into the table, the MSWordStyler might be easier to work with as the word document will wrap the text for you (more flexible). With PDF, you have to do all of the formatting (i.e. text wrapping) before creating the text feature with the TableAdder.

Here is a very rough example of a PDF table output vs a word table output with the attached workspace: imageYou can make much nicer-looking PDF's (like this demo) than what I attached above but just to give you an idea.

Badge +2

image 3OK... I believe I have the MSWordStyler... and I think I am using it properly....

 

image 4I understand the "stretch" or using "inches/CM" and how to put in a number value...

 

 

I believe I am using the MSWordTableAdder....

image 7Should I be using TableAdder or MSWordTableAdder???

 

My next question comes with the FeatureWriter...

 

image 6If I'm wanting to have the font size to be 10... I'm not understanding how to modify that, or other parts of the table. When I write the table to MSWord... it only opens up a "letter" (8.5x11) in "portrait" with "normal margins"... I was needing a "tabloid" (11x17) in "landscape" with "narrow margins".

 

 

Hi @shawn.brandt​ ,

Correct you should be using the MSWordStyler if you are writing to a Word file. If you are writing to a PDF, then you'll need to use the TableAdder!

 

For font size, this can be set in the MSWordStyler:

imageFor Column Width (admittedly I haven't used this yet so I am pasting some documentation in hopes it clarifies it as it depends on the units you setting in the transformer. This is percentage as an example): "Any positive number is valid here, or the word Stretch. Columns with the width Stretch will all share any leftover space after columns with specified sizes are given their space.

If Percentage of Page Width was chosen for Width Units, then 100 means the entire page width, while 1 means only one percent.

Format attribute set: msword_table_col_width"

 

Lastly for the margins/page format. This is a great question and it should be handled by using a template file in the FeatureWriter parameters (this screenshot shows a writer but it's the same in the FeatureWriter). You'll first need to save a template file in MS word with the margins you want and set that as your base Microsoft Word File.

 

image

INCREDIBLE... I knew this was just below the surface for me....

 

image 

Am I missing something??? I don't see the same font options as you showed in your screen shot.

Badge +2

INCREDIBLE... I knew this was just below the surface for me....

 

image 

Am I missing something??? I don't see the same font options as you showed in your screen shot.

Ah! Might be a difference of versions. I'm using 2021.2 fwiw but you should still be able to set it by exposing the msword_font_size format attribute and setting the value there. Or if you wanted to try it out in 2021.2 feel free to download it and see it in action ;P

 

You can expose it in an AttributeExposer and set the font size value in an AttributeManger (or equivalent). The new parameter in the MSWordStyler does just that but makes it a bit more streamlined.

Ah! Might be a difference of versions. I'm using 2021.2 fwiw but you should still be able to set it by exposing the msword_font_size format attribute and setting the value there. Or if you wanted to try it out in 2021.2 feel free to download it and see it in action ;P

 

You can expose it in an AttributeExposer and set the font size value in an AttributeManger (or equivalent). The new parameter in the MSWordStyler does just that but makes it a bit more streamlined.

Hey Chris, Hope things are going well. I have been able to upgrade to version 2021.2 I am still having some issues with the headers… Is this something I could ask you directly about? Thanks for all of your assistance, [Signature] Shawn C. Brandt Oklahoma Department of Environmental Quality Water Quality Division Public Water Section – Next Gen Reporting & QAQC o 405.702.8192 f 405.702.8101 Shawn.Brandt@deq.ok.gov

Reply