Faster PDF generating

Hi Community , 

I have a need , we use bots to create PDF for generating Invoice or receipt. Problem is Bots are slow and it creates a file in G drive  and again we are fetching it through URL methods etc. Is there any other method which is faster than regular bots methods to generate PDF / to print a document ?

1 34 864
34 REPLIES 34

Hey man,

you can use Google looker studio instead

Could you please share some articles for reference? Does looker studio supports PDF printing ? 

@Suvrutt_Gurjar , @AleksiAlkio , @jyothis_m @MultiTech @SkrOYC 

Guys, I seek your help for this thread. 

You could try Google Apps Script but I suspect it probably would not result in any time savings. Also, going this route means you have to script the replace text with the value from your data so it is a bit involved.

Appscript is comparatively slower process. 

I need some other methods  which work and get results in 1 or 2 seconds. 

There is no alternatives available to fasten the process of the bot and no other workaround to be honest . 

I think Koichi has guided vey well. Since I was also typing my response, I may add as follows

In my opinion. there are several cloud ( or web) based systems involved in the PDF creation process. 

A) Google Drive where the PDF template is saved.

B) The AppSheet itself or backend Google sheet ( or the database you are using) from where the data to populate in the template needs to be brought

C) The PDF generation engine that AppSheet uses

D) Saving the generated PDF back to Google drive.

As such I believe there will be some latency in accessing all these cloud/web based resources. If one wishes to use web based systems which of course has many other advantages, there will be some latency in as compared to say a desktop application. 

 

Latency matters here, for an POS app where customer line is too long. Nearly it take 10 seconds to get the Bill or invoice to get generated in regular bot method of creating PDF. 

Soon appsheet development team should come up workaround. 

I was wondering what your use case is. I am not sure that Appsheet or any other similar development tool is particularly well suited for a POS type application. I am wondering if a column of LongText with HTML or Markup would work for this that would display on a separate 'page' and then just print the page? But I would imagine this still leaves a delay in manually printing something.


@jaichith wrote:

for an POS app


It sounds like you're saying the person running the POS can't move forward without the generated file.

Can you describe the situation a bit more?  Perhaps there's another route to a solution.

Agreed.

  • If your goal is 1-2 seconds of processing time... I'm not sure you're going to find that anywhere other than by creating a custom cloud function on GCP or something.

________________________________________________________

Perhaps it's a matter of re-engineering the workflow, to account for the fact that it will take X seconds for the file - and bake that into the flow of things?

  • I usually find that there's a way for me to sneak things in that the user isn't aware of sometimes that can help, or by creating a smoother flow that accounts for things (with maybe a "Processing" label that appears temporarily when things are cooking) can go a long way.

When I originally created the Answer Portal and people began interacting with Appster through the app, there was some initial push back about how long it took to get the response.

  • Everyone was used to what they were getting from ChatGPT, where the results begin streaming in almost instantly, and so waiting 30-60 seconds for the complete generation was a sore spot.

I re-engineered the UX to include a loading GIF (which changes each time, through a list of gifs and a pseudo-random number) so that there was something visually to differentiate that things were "Processing" and something was happening.

1cd69b2e-e916-467c-976e-9f604b1468a1

When Matt is there appsheet team will be in relaxed position since somehow  Matt will find some alternatives or workaround.😂

Your suggestions was interesting which enables users to be interactive and not to get bored. 

We will try to Incorporate your idea. 

Here is my request that make an tutorial video for generating receipt through BTRAW as advised by @Kabuliño .

https://www.googlecloudcommunity.com/gc/AppSheet-Q-A/Impresora-T%C3%A9rmica-Ticket/td-p/480006


@jaichith wrote:

I need some other methods  which work and get results in 1 or 2 seconds. 


For this kind of fast response, you may need to develop a desktop native application which anyway is not the norm these days.

Yes I agree. There could be option so that templates are stored or synced with the devices locally and PDFs or XLS files could be opened for POS kind of apps. 

I think you can use a method using RaweBT to send it to print directly, it takes less than a second to print tickets.

https://www.googlecloudcommunity.com/gc/AppSheet-Q-A/Impresora-T%C3%A9rmica-Ticket/td-p/480006

unless for some reason you want to generate the PDF

Interesting buddy, .... 

By using this method have you ever tried with laser printer which is connected in the LAN ? 

We used to take printouts in A5 and A4 sheets for invoices, delivery challan etc which has multiple items. 

Is "Btraw" open source app and common for all BT thermal printer ? Can I use HP laser printer with it ?

How fast you make bills ? I mean in seconds 

Kindly advice.

 

 


@jaichith wrote:

By using this method have you ever tried with laser printer which is connected in the LAN ? 


 

No


@jaichith wrote:

Is "Btraw" open source app and common for all BT thermal printer ?


I think so


@jaichith wrote:

Can I use HP laser printer with it ?


I don't think so, would you only be using the app in desktop mode?


@jaichith wrote:

How fast you make bills ?



If you mean print from the moment I create the ticket, instantly 1s



I could have another possible solution depending on the complexity of your invoices.
Could you show me an example?

 

 

 

 

17084975304932569291234458631937.jpg

Sample 


@jaichith wrote:

17084975304932569291234458631937.jpg


 

 

Did you create those with appsheet?
How many items do you calculate as a decent maximum?

Print outs taken from Thermal printers are not long lasting. So we prepare regular A4 and A5 sheets

Perhaps you might offer a "paperless checkout" - where people can request to receive their invoice through email instead?

  • This way you can just keep moving forward after they type in their email, and anyone that needs paper will be more understanding of the wait.

You might even save the emails in a Clients table or something, for easy reference later. (This might open the door for a loyalty program as well.)

Our customers will not check emails instead they regularly use whatsapp or telegra etc. So in this case as @Kabuliño said base64 could be used for creating images (BUT ONLY IN DESKTOP MODE)  and what to do if I want to get output as PDF , images in mobile ? dear @MultiTech Matt if you have any such work around let me know please.  

I believe that the AppSheet team should focus on fixing these issues before diving into creating apps with AI. In the business world, it's important to prioritize solving everyday problems before adding fancy new features.

My short answer would be:

  1. If AppSheet is the only platform you expect using, try sending the file as an email to your printer if it's supported so that your printer starts printing the pdf as soon as it's generated and emailed.
  2. Use another platform. Just as an example, AppSmith lets you generate PDFs on the go without messing with a server, you just need to use the right tool to generate the base64 PDF and it will be displayed in the app almost instantly, like how we play with SVGs inside AppSheet


@SkrOYC wrote:

Use another platform. Just as an example, AppSmith lets you generate PDFs on the go without messing with a server, you just need to use the right tool to generate the base64 PDF and it will be displayed in the app almost instantly, like how we play with SVGs inside AppSheet


 

It's about time AppSheet starts thinking about these things, starting with integrating Google Docs. Other platforms are way ahead in the game, we need to catch up!

@SkrOYC ,

Hi there,

Somehow I am getting some idea. Mailing the file and getting it printed might be little longer process ... I think so. 

Is it possible to make the pdf content to base64 and open it by using the third party apps installed in device? Like Raw BT  method suggested by @Kabuliño in this thread 

Kindly advice. 

 

The way I found that could be helpful (if you only use the app in desktop mode) is to generate an SVG with the invoice, then you can right click open the image in a new tab and finally send it to print with ctrl+p or click right. The main problem would be when the information exceeds 1 page but I think it can also be solved with some creativity.

Our use case is in both mobile and desktop. 

You mean here is converting the invoice content to SVG and it should be set to appropriate sheet size like A4 or A5. 

So naturally output will be as image. ? 

When you are about to print you have the option to choose the size of the sheet, you can even save it as a PDF if you wish.

Ok I will attempt to finish soon and update you back. I have to learn about how to get child records and grand child record inside a table which is in invoice content.

I have an example that shows that it is possible to implement SVG as an alternative to generate invoices.

To save time and space I am not going to explain how it works nor am I going to change the name of the variables. I will explain as doubts or questions arise.
The recipe:
Add this 3 VC to Child Table (Ventas):

[Bit_SVG] / Type:Text 

Formula: 
CONCATENATE(
"<!--Descripción-->
<text x='30' y=""",[Y_SVG],""" font-family='Arial' font-size='12'>",LEFT([ID_Producto_Servicio].[Nombre],47),"</text>
<!--Cantidad-->
<text x='350' y=""",[Y_SVG],""" font-family='Arial' font-size='12'>",[Cantidad],"</text>
<!--Precio-->
<text x='430' y=""",[Y_SVG],""" font-family='Arial' font-size='12'>",[Precio],"</text>
<!--Descuento-->
<text x='500' y=""",[Y_SVG],""" font-family='Arial' font-size='12'>",[Descuentos],"</text>
<!--IVA-->
<text x='580' y=""",[Y_SVG],""" font-family='Arial' font-size='12'>16%</text>
<!--Total-->
<text x='650' y=""",[Y_SVG],""" font-family='Arial' font-size='12'>",[Subtotal],"</text>
<!--Linea-->
<line x1='10' y1=""",[Y_SVG]+5,""" x2='740' y2=""",[Y_SVG]+5,""" style='stroke:rgba(128, 128, 128, 0.5);stroke-width:1;stroke:grey;stroke-dasharray: 5,5' />")

[Número_Carrito_SVG] / Type:Number 

Formula: 
IFS(
INDEX([ID_Ticket].[Related Ventas],1)=[_THISROW],1,
INDEX([ID_Ticket].[Related Ventas],2)=[_THISROW],2,
INDEX([ID_Ticket].[Related Ventas],3)=[_THISROW],3,
...
...
INDEX([ID_Ticket].[Related Ventas],100)=[_THISROW],100
)

[Y_SVG] / Type:Number 

Formula: 
SWITCH([Número_Carrito_SVG],
1,180,
2,200,
3,220,
4,240,
...
...
100,2160,
,0)

 

Add this VC to Parent Table (Ticket):

[Ticket_SVG] / Type:Image

CONCATENATE("data&colon;image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='750' height=""",INDEX([Related Ventas][Y_SVG],COUNT([Related Ventas]))+75,""">
<!-- Fondo de la factura -->
<rect width='100%' height='100%' fill='white'/>

<!-- Encabezado de la factura -->
<rect x='10' y='10' width='730' height='50' fill='rgb(32, 178, 170, 0.65)'/>
<text x='375' y='40' font-family='Arial' font-size='20' text-anchor='middle'>Factura</text>

<!-- Cuerpo de la factura -->
<text x='20' y='80' font-family='Arial' font-size='14'>",[ID_Propietario].[Nombre_Apellido],"</text>
<text x='20' y='100' font-family='Arial' font-size='14'>Fecha:",[Fecha],"</text>

<!-- Titulos Tabla de items -->
<line x1='10' y1='120' x2='740' y2='120' stroke='black'/>
<text x='100' y='140' font-family='Arial' font-size='12'>Descripción</text>
<text x='350' y='140' font-family='Arial' font-size='12'>Cantidad</text>
<text x='430' y='140' font-family='Arial' font-size='12'>Precio</text>
<text x='500' y='140' font-family='Arial' font-size='12'>Descuento</text>
<text x='580' y='140' font-family='Arial' font-size='12'>IVA</text>
<text x='650' y='140' font-family='Arial' font-size='12'>Total</text>
<line x1='10' y1='160' x2='740' y2='160' stroke='black'/>

<!-- Tabla de items -->
",SUBSTITUTE([Related Ventas][Bit_SVG],",","
"),"

<!-- Total -->
<line x1='10' y1=""",INDEX([Related Ventas][Y_SVG],COUNT([Related Ventas]))+10,""" x2='740' y2=""",INDEX([Related Ventas][Y_SVG],COUNT([Related Ventas]))+10,""" stroke='black'/>
<text x='600' y=""",INDEX([Related Ventas][Y_SVG],COUNT([Related Ventas]))+30,""" font-family='Arial' font-size='14' font-weight='bold'>Total</text>
<text x='650' y=""",INDEX([Related Ventas][Y_SVG],COUNT([Related Ventas]))+30,""" font-family='Arial' font-size='14' font-weight='bold'>",[Total_Virtual],"</text>

<!-- Pie de página de la factura -->
<rect x='10' y=""",INDEX([Related Ventas][Y_SVG],COUNT([Related Ventas]))+40,""" width='730' height='40' fill='rgb(32, 178, 170, 0.65)'/>
<text x='360' y=""",INDEX([Related Ventas][Y_SVG],COUNT([Related Ventas]))+60,""" font-family='Arial' font-size='16' text-anchor='middle'>Gracias por su preferencia</text>
</svg>")

 The texts in red are to facilitate the identification of elements that you probably have to change to adapt to your case.

The result:

Kabulio_0-1708707843803.png


@SkrOYC wrote:

you just need to use the right tool to generate the base64 PDF and it will be displayed in the app almost instantly, like how we play with SVGs inside AppSheet


This is cool stuff

I'm working on some work-arounds, tho for me doesn't have to be pdf, any printable document form will do. Anyone want to collaborate? I posted this the other day with no response.

https://www.googlecloudcommunity.com/gc/AppSheet-Q-A/Generate-Document-Without-Syncing-quot-Print-In...

Join the club !!!

Top Labels in this Space