Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2026-03-25 17:11:18

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,530
Website GitHub

Quote preparation into a formatted template

I must be missing something. I’m trying to embed an Excel sheet into a Word document.

From Word: Insert > Object > Excel Worksheet opens up a blank sheet. I add a few column headings, type a few rows of data with some formulae, format it as a table so it looks pretty, add an auto generated Table Totals row and it is embedded perfectly fine in Word.

I can edit anything, right click the table, choose Add Table Row, type some data and it works fine. All changes to the data are reflected in Word, the totals auto update. Beautiful.

But. If I right click and choose Delete Table Row, the embedded data in Word leaves a blank row below the Totals row. If I delete another row from the middle of the table, I get two blank rows below the Totals row in my Word doc.

No amount of row deletion, updating fields, clearing formatting, VBA trickery, nada seems to remove it. It’s almost as if the OLE link between the two objects has an internal high water mark for the maximum used row number, like the auto increment value in MySQL. And it refuses to let go of that value.

The number of rows used in the data table is going to vary from day to day based on who the embedded information is going to be sent to. It’s for preparing quote purposes, so the line items will vary wildly when embedded in Word, which is simply used to top and tail the document with nice pictures, headers, and a slightly better layout than is possible in Excel natively.

The second conundrum is that the pictures I want to top and tail on pages 1 and 3 of the word doc are full-size and need to bleed off the page when printed to PDF. Can I do that by faffing with sections, margins, page setup and printer settings? No. Regardless of what I do, I get a white border when either Save to PDF (macOS, btw) or Print to PDF options are chosen.

I’ve Googled and even consumed AI suggestions on how to combat these two issues. The best it can come up with for the phantom rows is that it “might happen”! No solution as yet.

Has anybody any nuggets of wisdom on how to either get rid of the phantom rows, print to the edge of a PDF, or does anyone have any other solutions I might try? All I need is to insert variable rows of cost data with totals and a few varying images into a nice looking multi-page PDF. Change the header text with client name, quote number, etc. Export to PDF. Send to client. Profit.

Part of me wonders if this is better handled with a little Txp plugin fed through a page template with hard coded header/footer content. Like, I dunno, some tabular data in an article somehow that gets split at delimiters and formatted as a table and embedded in the template.

The fly in the ointment is it needs to be usable by someone who has zero patience and very little tolerance for something that isn’t cut, paste, press print, done.

Thoughts?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#2 2026-03-25 17:38:12

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,530
Website GitHub

Re: Quote preparation into a formatted template

Hmmm, am I dreaming or did someone write a csv/xls kind of plugin that can interpret comma separated data in an article body? Or could handle uploading a csv/spreadsheet and inserting its contents into an article? I can’t remember but I’m sure someone wrote one. Can’t find it.

The more I think about it, the more attractive it sounds to be able to:

  1. New Article in the Quotes section.
  2. Title is the quote title.
  3. Body holds the tabular data pasted in or uploaded/dragged/whatever.
  4. Article image is the accompanying photo for page 2 of the report alongside the table.
  5. Save it.
  6. View the quote on the website.
  7. Print output to PDF.

Sounds like it might work and be potentially less hassle than linking Word and Excel, fighting tools that aren’t designed for this kind of thing. Bonus: we get a history of quotes as articles that can be regenerated, or cloned + tweaked for rapid quote generation in future.

The sticking point is how to attach/paste the csv data into the article and interpret it to spit out a table that fits on the 2nd page. Hmmmm…

Or could each “row” of data be added to an article somehow? Even via a dashboard panel of some description? With a table shown, and “add row” facility? Seems a bit slower, potentially, and quite a bit more work, especially since this could do with being done quickly.

Btw, I’m aware that merging a data table into an InDesign / Affinity Publisher doc is the “correct” way to do this, but the client doesn’t have access to either of those, and I don’t relish trying to explain how to use it!

Last edited by Bloke (2026-03-25 17:44:15)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#3 2026-03-25 18:58:05

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,265
Website GitHub

Re: Quote preparation into a formatted template

A wild chain of thought there! Thanks for the interesting journey. Might etc_query do the job here?


TXP Builders – finely-crafted code, design and txp

Offline

#4 2026-03-25 19:55:43

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,327

Re: Quote preparation into a formatted template

Sorry that reading that much text and trying to understand what’s really needed overwhelms my stroke plagued brain. But I’m a collector of txp plugins and saw this line:

am I dreaming or did someone write a csv/xls kind of plugin that can interpret comma separated data in an article body? Or could handle uploading a csv/spreadsheet and inserting its contents into an article?

I’ve 3 plugins and 1 tip containing csv in their filename.

# Name: yab_csv2table v0.3 (compressed)
# Type: Client side plugin
# Generating HTML table from simple csv files (with an option to mailing your row selection in conjunction with zem contact reborn)
# Name: lum_csv v0.9 (compressed)
# Type: Admin/Public side plugin
# Expose parts of your database to the outside world
# Name: jmd_csv v0.2 (with "raw to HTML"-Patch (compressed))
# Type: Admin/Client side plugin
# Batch-import articles from a CSV

… and finally mrdale’s question and final treatment tip

EDIT2: The mrdale thread seems to have brought us the jmd plugin. OK.

Last edited by uli (2026-03-25 20:02:58)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#5 2026-03-25 20:34:50

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,530
Website GitHub

Re: Quote preparation into a formatted template

Aahhhh, yab_csv2table might be the one I’m thinking of. I’ll download it and see. Thank you for the links.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#6 2026-03-25 20:43:23

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,265
Website GitHub

Re: Quote preparation into a formatted template

Bloke wrote #342999:

The second conundrum is that the pictures I want to top and tail on pages 1 and 3 of the word doc are full-size and need to bleed off the page when printed to PDF. Can I do that by faffing with sections, margins, page setup and printer settings? No. Regardless of what I do, I get a white border when either Save to PDF (macOS, btw) or Print to PDF options are chosen.

Not sure if this will work entirely for bleed situations but my trick for adding letterheads to word templates is to prepare the page background as a PDF (with bleed if you want), then insert it as an image to a Word doc’s header or footer. It comes in wrong to begin with but right-click and edit the image size and position settings so that:

  • wrap is set to “behind the text”
  • set the size of the image back to full size, e.g. 21.6 cm x 30.3 cm for 3 mm bleed
  • Make it absolutely positioned to -0.3cm from the page edge

It makes it a bit of a faff to edit the page headers and footers unless you lock the graphic, but usually you don’t touch that later (to return to the main document you view, you may find you need to switch to the header/footer tab on the ribbon to close the header via the button there because the usall method of double-clicking on the page gets you the background image).

You can then happily edit your document and the background prints out. It looks faded when working in word but prints out fine. You could conceivably also embed separate graphics in the header and the footer.

On the mac, you can use a PDF and it seems to work well but I’ve heard others say Word won’t take a PDF on windows. One windows user reported that a PDF version didn’t print well but a version with a PNG embedded in the document did. The advantage of the PDF is that your file size is smaller.

Here’s a zip with some test documents and background images illustrating the principle.


TXP Builders – finely-crafted code, design and txp

Offline

#7 2026-03-25 20:46:53

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,327

Re: Quote preparation into a formatted template

Just saw I answered some other guy’s question for plugins over a decade back, where I mentioned aks_table. The download link there is dead but I’ve at least v0.2 saved to disk should you deem it more apt.

Last edited by uli (2026-03-25 20:47:57)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#8 2026-03-25 20:50:23

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,265
Website GitHub

Re: Quote preparation into a formatted template

uli, cool that you have all those txp nuggets squirrelled away in your archives!!


TXP Builders – finely-crafted code, design and txp

Offline

#9 2026-03-25 20:55:24

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,327

Re: Quote preparation into a formatted template

My brain is all nuts now, but I still have them on HD, these nuts ;)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#10 Yesterday 00:24:21

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,530
Website GitHub

Re: Quote preparation into a formatted template

Oooh, aks_table sounds even more useful cos it uses copy and paste. I may have that lurking somewhere but I can’t find it right now. So would you please be able to post it here? Thank you.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#11 Yesterday 00:29:44

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,327

Re: Quote preparation into a formatted template

# Name: aks_table v0.2 (compressed)
# Type: Admin/Client side plugin
# Insert a table in TxP article is very simple!
# Author: makss
# URL: http://textpattern.org.ua/
# Recommended load order: 5

# .....................................................................
# This is a plugin for Textpattern - http://textpattern.com/
# To install: textpattern > admin > plugins
# Paste the following text into the 'Install plugin' box:
# .....................................................................

H4sIAAAAAAAAA61WbW/bNhD+HAP5DzfNq6RZsCynTRpZUtcFKVZgXQskKAYkaUCLtMVVlgiS
apwl+e87UpITt0vRDf1gk3e8e+6Fp0cicTSJb1T8NHYqsmLOTMWHsUM+qktN5qWV91FudFFL
IzyLnRWeKrNHz+7kspHcaKZoW2gt4jDUbK0F0ZrJalzL5bghobE4iJ1PTCpeV0bai53JeGqx
otihTOWSC90dPsVYryvFpAYCNhvgFZyu3wGRmudGVIBg16D4SpTsB+sUO3lNWQu5h/h84f2i
14JXmMmC5AzSFFxCV7xy/ZvdwY5kS67w7DInZTkn+UfP3VR/qcgn5gZo3wY0W/xF/mx3cLc7
2B0smio36cK2izdkn1ilAxgisjBhADCPpVCeayF9uL0FK4pmXnJVuL5NBo2Gl+/enpyeuaZ/
HPHmNb12L9I08m+gP/u11QnM/VIyUWJZnht6H27PzuV5dTHyE6w43uQUcuUGzjCCbbUTbOP5
M7j79xzYOmdS6M/TON6ov1smG8g2GTB/j3QavCGOl8Im64JXy9R120ZjzpLk2itf4qlHpCTX
HriFC5Bm9vrcvCRKuWlmBU77HbEbP7Cwvrnj7t6GhSm6SKPZHSsVu8HtZGazG3YTnrZhsHIY
+S/OtV1C7gZu+KFdhrgYSPTp+nQ2uejdklDTLMEfWiZabrZWHaLic9fooWuB9sW9a9G5Fg9c
rXPJK6ZSthYlPiCec15h223rWvBFLbGlHFKYzADXBPK6qbTX+vlGNxr5YHvco50N+ReXn8zl
+OcXmS3bDe7t2ihf8zyDi9HwUT9zEffKm0dx+jsJNt0aFhdbeGAvcDNfmFLd6PSvmlee4wR9
veZAMt3ICmh9SpaesQrA6SYWhnaMUGH2nFpO6BhIX4uWgWIn6kizlpTJTvesMytYKaxq+vR5
7CRFlJ1YImvJTvVs5x1pWY6OArDrez8J0XIw2ElElhAoJFukXyHdBT7AKtw8NWO91k5G66uq
rAkFrPVjEpIMQvgGLFE2S149QHOyol4xQZbMgCShsHkV0+ykWa2IvMZUp12q/4nJ4YSVLNfG
yjBCGcDr4wDe1H/zsiQBvOKSvarXAbwVTBIgFTriDBCqCsZ02ygYwRF4eS2ufTSgve49eIIg
K/t9BseUY1boPIaXlD6gF02WCp78+HwaRTPQBdF2fzBTgC+KcV8r3oHSsq6W2R+1ZnESdhK0
vQLVCFFj3XVV9tW1HRiDJ+srJUhl08vr0u77gE3VeTLqjx80FgdRPehqYl522ZNSz7YI9clS
z8bjcV7jW6/SuDMW4RcmSWjde/i27rkd1RQnF6441UXqHE5+cgBvwWSYG6p1Jq0sCKVWjiZO
NtjZMQSEy44hIZwcyeeNZspyUa+mbEGaUm/pFDFt+cxs8ynQ6g162MLfR6FZYTmyl2zz9mfd
RW0dRVvSgkulzfCz+xu2xRc4REy2to+E5PRbY37lyPvT/+30ze/h0ckJ3ANuhetNLc1855Bb
mF1UXEwLMDAyOIRZ94+j9v+Y4XjdXashBkTpvvdW1NLf3hQ//Q7oYo9Mny/IdD453N9n5NnB
4XS+f7Cgk8P5HlLn3T/HCt3BnwoAAA==

In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#12 Yesterday 08:34:59

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,327

Re: Quote preparation into a formatted template

v0.3 is still available from this page, thanks to Pete/kuopassa.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#13 Yesterday 22:45:58

etc
Developer
Registered: 2010-11-11
Posts: 5,700
Website GitHub

Re: Quote preparation into a formatted template

jakob wrote #343002:

Might etc_query do the job here?

Well, etc_query is a public-side plugin, so it will not work on the admin side. A possible ‘solution’ could be to put this into your article body (or some form/shortcode):

<txp:etc_query url="path/to.csv" markup="csv" query="*" argsep="," escape="textile">
|{$join(|,$)}|</txp:etc_query>

where path/to.csv is the url of your csv file, which can be attached to the article via a cf or got from url.

If you need to save data in article bodies, a combination of etc_query/etc_post must be able to do it, but things get less straightforward.

Offline

#14 Yesterday 23:57:10

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 12,530
Website GitHub

Re: Quote preparation into a formatted template

This is all fab stuff, thank you so much. The story so far:

I’ve ditched Word/Excel in favour of a modified version of aks_table with additional support for <thead> and <tfoot>. I also read up on Designing For Print With CSS. Mind blown, and it’s been around 10 years! BUT, not fully supported in browsers, it seems, and I’m not paying for some third party system like Prince to render it.

However, some rules are supported and if I target them with “@media print” in a screen/print stylesheet, it seems to be controllable when I hit CMD-P.

Sort of.

I’m struggling to get the cover image full size. Markup:

<txp:article limit="1">
    <div class="logos">
        <txp:image thumbnail width="580" name="CompanyLogo.png" class="logo primary" />
        <txp:image thumbnail width="120" name="SecondaryLogo.png" class="logo secondary" />
    </div>
    <txp:image thumbnail width="700" name="FrontCoverPic.png" class="fullsize frontcover" />
    <article class="article">
        <h1 itemprop="headline" class="quote_ref"><txp:title /></h1>
        <div class="artwrap">
            <if::article_image>
                <txp:article_image thumbnail class="bodyImage" wraptag="div" />
            </if::article_image>
            <div class="bodyText">
                <txp:body />
            </div>
        </div>
    </article>
    <txp:image thumbnail width="700" name="BackCoverPic.png" class="fullsize backcover" />
</txp:article>

Some juducial CSS rules:

@media print, screen {
body {
  width: 100%;
  margin: 0;
  position:relative;
  width:100%;
}
.logos {
  display:flex;
  padding:2em;
  justify-content: space-between;
}
.quote_ref {
  position:absolute;
  top:250px;
  font-size: clamp(1.3rem, 2.5vw, 4rem);
  right:0;
  background-color:white;
  padding:1em 1em 1em 2em;
  border-radius: 2em 0 0 2em;
}
img.fullsize {
  width:100%;
  height:auto
  overflow:hidden;
}

@page {
   size:a4;
}  
.frontcover,
.backcover {
  margin: 0;
  padding: 0;
}
}

Without a ‘container’ for the image (essentially: the A4 page is the container) I’m not sure how to tell it to display as much as it can with 0 margin, so it ‘bleeds’ to the full page when printed. It works on screen but as soon as I hit CMD-P and the preview dialogue appears, the logos and title appear on page 1, the ‘background’ image is shunted to fill page 2, the body content appears on the next page, the back cover starts on page 4 but spills over onto page 5 by about 20px becasue it’s taller than the ‘page’.

I’ve experimented with different <txp:image thumbnail width="someval" /> values to try and make the images take up less space in the hope they’ll fit completely on pages 1 and 3 but it doesn’t seem to make any difference.

Are there any tricks I can employ to make the <txp:image> ‘fullsize’ images fit the page and truncate if necessary when printed to PDF, so they behave like ‘background’ images?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#15 Today 06:19:47

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,265
Website GitHub

Re: Quote preparation into a formatted template

From what I remember, exact print output with css is hard. Some assorted and untried ideas:

  • Use position: absolute; for the fixed position images to take them out of the document flow.
  • Set @page margins to zero, then bump in the content with padding or margins, or position them absolutely like you have with quote-ref. AFAIR the margin defaults to an inch or what your printer has a minimum print margins.
  • Alternatively keep your margins and try leveraging the print page margin boxes (article on Medium) to place your images.
  • Long shot: Possibly add a wrapper inside body to act as your position:relative; reference.
  • Long shot: Try using background-image for the bleed images. You may need to set your printer dialog / browser dialog to print background images for these to appear, though (see also this, also on Smashing Magazine).

Otherwise, I think you can afford to use print units and be more specific with print stylesheets. You don’t have a dynamically changing viewport, so things like clamp are probably unnecessary for print.

Finally, I’ve read somewhere about pagedjs as an open-source library for more exact print output. There’s a full-page plugin for that, which suggests it is possible, though that example shows interim full pages in book layouts. It also discusses the page margin boxes.


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB