Turning a flat file into a PDF



  • At work we use a tool called Reform (from Fabsoft) which allows us to turn a flat file into a formatted PDF. It work fine for 99% of what we need it for. However, recently we have had two requests from customers that are beyond its capabilities.

    Specifically, we need the ability to dynamically size elements (a grid) based on the number of data points in the file. Our current solution is very much static in this regard.

    Does anyone here have experience with turning flat files into PDFs?


  • Considered Harmful

    @Dragoon said in Turning a flat file into a PDF:

    Does anyone here have experience with turning flat files into PDFs?

    Many times but iirc all of them have been coded solutions using a library - of which one is almost certainly available for your choice of language. Be warned, the white ink does nothing...


  • Notification Spam Recipient

    @Dragoon said in Turning a flat file into a PDF:

    Does anyone here have experience with turning flat files into PDFs?

    I suppose one could try automating Excel if it was Good Enough, but I'm questioning why we're turning a flat file into PDFs in the first place. Is it really consumed by human hands?



  • @Tsaukpaetra said in Turning a flat file into a PDF:

    but I'm questioning why we're turning a flat file into PDFs in the first place.

    Well, at the end of the day what we are doing (in this case) is creating a packing list that is going to be sent to a customer. As this is for a 3rd party sale (direct to customer) they want their logo/details on the form as well as a custom format for the document. So it doesn't technically have to be a pdf, but that is one of the easiest ways to make a document like that. In the end it is printed out and placed with the shipment, so the customer doesn't actually get a PDF.

    This is the third time that we have run into a customer wanting a more dynamic solution than we can do with our existing system. The previous two we have used Excel and custom code to create them as needed. That would also work in this situation, but I am looking for alternatives as that solution is not ideal for a multitude of reasons.

    I suppose my real question is turning a set of data into a structured document, supporting dynamic spacing of items and containg structures (grids, boxes, etc...).


  • ♿ (Parody)

    @Dragoon there's lots of software that will take html and turn it into a pdf. It sounds like your case is pretty simple.


  • Notification Spam Recipient

    @Dragoon said in Turning a flat file into a PDF:

    I suppose my real question is turning a set of data into a structured document, supporting dynamic spacing of items and containg structures (grids, boxes, etc...).

    Nobody has made any product that can produce HTML for you? I would have thought there would be no end in sight of all the crapware that should be available...


  • BINNED

    @Tsaukpaetra said in Turning a flat file into a PDF:

    @Dragoon said in Turning a flat file into a PDF:

    I suppose my real question is turning a set of data into a structured document, supporting dynamic spacing of items and containg structures (grids, boxes, etc...).

    Nobody has made any product that can produce HTML for you? I would have thought there would be no end in sight of all the crapware that should be available...

    You can produce your own simple html from pretty much any language.
    Then just need a virtual printer or html -> pdf converter.



  • @Tsaukpaetra said in Turning a flat file into a PDF:

    Nobody has made any product that can produce HTML for you?

    Our ERP isn't exactly common (it dates back to the early 70's). It is still supported so there are some products that work natively with it, but there isn't a big market of them.

    So, if I want an HTML file, I am writing the HTML file. This is the reason that our current solution uses a flat file.



  • @boomzilla

    Yeah, and writing the raw HTML and converting is has been discussed, I should spend some time with it and see what we can get out of it.


  • Notification Spam Recipient

    @Dragoon said in Turning a flat file into a PDF:

    So, if I want an HTML file, I am writing the HTML file.

    Ah... Well best of luck?



  • @Dragoon Yes. I was in the same boat with my inventory/accounting program. However I don't think you'd like the solution. I'll have to find the code when I get home to verify the details but I know I was drawing on a GDI device context.


  • Considered Harmful

    @Dragoon said in Turning a flat file into a PDF:

    turning a set of data into a structured document, supporting dynamic spacing of items and containg structures (grids, boxes, etc...).

    Producer-consumer, iterate set as Producer, to a consumer with a bit of state to know where to put things. If you've got you a heterogenous object graph vs a set, then probably more than one consumer method is indicated on w/e instance is the Consumer. The stateful consumer can wrap w/e DOM or builder.



  • @Dragoon said in Turning a flat file into a PDF:

    @Tsaukpaetra said in Turning a flat file into a PDF:

    but I'm questioning why we're turning a flat file into PDFs in the first place.

    Well, at the end of the day what we are doing (in this case) is creating a packing list that is going to be sent to a customer. As this is for a 3rd party sale (direct to customer) they want their logo/details on the form as well as a custom format for the document. So it doesn't technically have to be a pdf, but that is one of the easiest ways to make a document like that. In the end it is printed out and placed with the shipment, so the customer doesn't actually get a PDF.

    This is the third time that we have run into a customer wanting a more dynamic solution than we can do with our existing system. The previous two we have used Excel and custom code to create them as needed. That would also work in this situation, but I am looking for alternatives as that solution is not ideal for a multitude of reasons.

    I suppose my real question is turning a set of data into a structured document, supporting dynamic spacing of items and containg structures (grids, boxes, etc...).

    Our legacy ColdFusion app made dynamic pdfs. It was html and css. It was less forgiving that a browser but most of that code is almost a decade old, I'm sure modern html and css would work without much issue.

    The dev version had a watermark on the pdf.



  • @Zenith @Dragoon Good news and bad news. Good news is I think I found the code. Bad news is it's alot of GDI code in my style. So unless you're willing to untangle all of that to basically save a BMP into a PDF, it's not particularly useful.



  • @Zenith

    Thanks for looking, but I think I will just go with the system that I hacked together. It isn't as dynamic as I would like it to be, but it is functional and really as long as all the information is on there, I doubt the end customer cares.



  • @Dragoon I used the iText library ages ago in Java for PDF creation/editing, and it seemed alright, though PDF as a format is much more complicated than one might expect at first. I'm just going to link to the Wikipedia entry on it, though, as it seems like one of those open-source projects that's had various relicensing/forking/etc. events so I don't know what branch/project to recommend nowadays. I think that it's basically the standard for manipulating PDF documents in Java or .NET, but you might need to find an old book on it to really understand how to best use it.



  • You forgot to put more xml into it: https://xmlgraphics.apache.org/fop/
    Actually had good results with that, years ago. And it serves the purpose of turning a structured file into PDF.


  • Considered Harmful

    @robo2 said in Turning a flat file into a PDF:

    You forgot to put more xml into it: https://xmlgraphics.apache.org/fop/
    Actually had good results with that, years ago. And it serves the purpose of turning a structured file into PDF.

    Iirc it was pretty easy to use FOP to rip images from a PDF to stick through Tesseract OCR, they both use a similar slightly annoying image model. I've probably used iText somewhere, maybe with FoxPro...



  • @Dragoon said in Turning a flat file into a PDF:

    turn a flat file into a formatted PDF
    […]
    we need the ability to dynamically size elements (a grid) based on the number of data points in the file

    What does the “flat file” look like? Something that just looks OK-ish if you dump it on a text terminal?

    In that case, would it be close enough to some of the lightweight makrups that pandoc could understand it, or that you could massage it into something it would understand (markdown, reStructuredText, textile, markups of various wikis) with a handful of pattern replacements?

    If yes, then you could use it to generate PDF either going through TeX or HTML. You can give it suitable headers/footers/style definitions in one of those formats and then it supports a bunch of different tools to convert that to PDF, so you can test a few to see which works best for you.

    You need to provide some document template anyway, don't you? So it's more about the step of combining a template with the flat file content than the PDF generation itself, isn't it?



  • Last time I needed to do something like this, I plopped the text into an SVG file, rendered that into a bitmap in Qt, and printed to PDF via Windows PDF printer. (Qt made the printing part really easy.)


  • Banned

    @acrow and if I ever had to use your software I'd hate you forever. The most basic functionality I want from an ELECTRONIC document - even more important than proper layout and formatting - is the ability to SELECT and COPY the text inside. If the PDFs your software generates cannot do that, you have failed as a developer and as a human being.



  • @Gąska It's not the user who suffers here. But rather his customers.

    But yes, I admit that it was a sub-optimal solution.

    A step up from the paper forms that the shop used before though; now they don't need to take a photo of the receipt for their own archives...


  • And then the murders began.

    @Gąska If the PDF was intended for humans to read, you’d be right. In this thread’s case, where it’s being sent directly to a printer, what’s the harm?


  • Notification Spam Recipient

    @Unperverted-Vixen said in Turning a flat file into a PDF:

    @Gąska If the PDF was intended for humans to read, you’d be right. In this thread’s case, where it’s being sent directly to a printer, what’s the harm?

    PrInCiPlEs!


  • Considered Harmful

    @Tsaukpaetra said in Turning a flat file into a PDF:

    @Unperverted-Vixen said in Turning a flat file into a PDF:

    @Gąska If the PDF was intended for humans to read, you’d be right. In this thread’s case, where it’s being sent directly to a printer, what’s the harm?

    PrInCiPlEs!

    Wasn't convinced. Try it again, but with feeling.


  • Banned

    @Tsaukpaetra said in Turning a flat file into a PDF:

    @Unperverted-Vixen said in Turning a flat file into a PDF:

    @Gąska If the PDF was intended for humans to read, you’d be right. In this thread’s case, where it’s being sent directly to a printer, what’s the harm?

    PrInCiPlEs!


Log in to reply