Trouble with landscape pdf attachment

Hi

I try to make a PDF attachment in landscape. I make my template in google document in landscape but the PDF is landscape with portrait template.

Solved Solved
1 35 4,109
1 ACCEPTED SOLUTION

Try to use Word instead of Google Docs. Its a solve my problem

View solution in original post

35 REPLIES 35

Hello @Simon_Langelier_Cont, have you configured your workflow to use the landscape as well?

3X_b_b_bb532562457b70c3dcb8bd8520490263b8ee4033.png

Do I miss Something?

Could you please share a screenshot of your table in your google doc template?

I’m having this same issue. Trying to use a landscape template, but the result keeps cutting off the text as if it’s portrait.

My template:

My Output:

My Settings:

I have tried A4 size as well, same result. I thought that custom setting the size of the page might change that … nope. The google doc template is set to landscape.

I got the same problem.

Same problem only landscape orientation

Try to use Word instead of Google Docs. Its a solve my problem

@Simon_Langelier_Cont I’m hoping for people who are already setup with google docs (like myself) and have others also counting on templates being created in google docs, is there another solution? I have tried other apparent solutions that seems to solve other peoples problems but I still cannot get the pdf file to be in landscape. The page is clearly in landscape but the content is pushed off to the side to fit portrait width. I am not sending the pdf as an attachment it is just a file creation task. Is there anyone out there that has a solution to this seemingly weird oversight of appsheet development.

Mismo problema

Experiencing the same issue.

@Shawn_Crocker @Cando_Mayorga @Justin_Thurston
You could open a new topic asking for help.
One of the oldest replies seems like the config wasn’t right.
Make sure to use the right margins on both, the doc and appsheet, the right page size on both, the right orientation on both and finally I advice anyone to always wrap on a table, it doesn’t matter if it’s one cell. You can control that table’s width and height, fix it to a certain value, etc

I have this issue with a table in Google Docs as well.  Whats weird is it's fine in portrait.  You change it to landscape and now it slices off about 30% off the right hand side.  Here's a simple example, created from scratch as A4 Landscape in google docs with a simple table:

Screenshot from 2022-03-23 15-16-22.png

Ran it as a template from a bot (Bot set to A4 Portrait):

Screenshot from 2022-03-23 15-16-40.png

Margins are slightly off, but its covering the full width. 

 

Change Bot to A4 Landscape and we have:

Screenshot from 2022-03-23 15-16-52.png

So because the issue occurs when we change the settings of the Bot, I'd have to point the Appsheet Devs there first.  Changing the margins in the bot does nothing.  Also what is "pt" in terms of the margin settings?  Likewise changing the column widths in the Google Docs table seems to do nothing either 😕  Finally even tried Landscape/Letter in the bot settings - Same

If I was to hazard a guess I'd say that it looks like the Bot is constraining the width as though the paper was still portait.

 

 

Another quick test i've done. I went in an manually doubled the size of the last column in the Google Docs table. When I ran the Bot, the table in the PDF attachment was an identical width to before. Except now the last column was double the size and other others had all been shrunk.

I know that this may not be the solution for the majority of people but since all the templates are converted to HTML before the data is saved on them, I'm using HTML/CSS exclusively.

"Pt" is one of the common measurements we use on HTML/CSS, while I know that inches and centimeters are more common on WYSIWYG editors.

If you need help to make this while the AppSheet team manages to fix the problem with those editors you can send me a DM and I can happily make a .html file for you that will do the job as template.

Also you could check my post about this here  Part 1 - Almost pixel perfect pdf reports from aut... - Google Cloud Community

Also, on the table's config, change the width to 100% of the window

Thanks for the info.  I will look into html templating.  At least I feel more certain the landscape issue it cause not entirely due to my idiocy.

Steve
Platinum 4
Platinum 4

Escalated.

I took a look at this today to try and understand what was going on. As @SkrOYC  alluded to in one of the other threads here, the way AppSheet creates PDFs is by rendering HTML. Specifically we use a variant of the Chromium browser to render it.

The way this works with a template like Google Docs is we are able to export the Doc as HTML, replace the values, and then render it. What's going on here is that when we export the Doc from HTML it does not contain any information about the page orientation.

I kept my test simple, just a single table on the page in portrait and exported it as HTML (you can do this yourself as well in Docs by going to File -> Download -> Web Page). I then changed the page to landscape and exported it again. There was no real difference in the HTML when I did this. Some CSS classes were re-named, but ultimately both contained a <body> with a class constraining the max-width to the same value.

So since Docs doesn't export the portrait and landscape pages any differently that information is lost, resulting in the smaller width content that's seen when exporting a landscape page.

 

In general, as some other community members have mentioned, DocX templates tend to include more information, and so result in a better final product. Ultimately though there will always be some loss of fidelity doing this. So for any power users out there looking to achieve much better PDF output I'd suggest reading through @SkrOYC's excellent post on using HTML templates to create your PDF .

 

As a final note, a good way to "preview" what AppSheets PDF output will look like is to just "print" the HTML (ctrl+p by default in most browsers). So if using an HTML template directly, open it in the Chrome browser and press (Ctrl+P) to print. This should be very close to the final PDF render. If using a Google Doc template then you can download it as html (File -> Download -> Web Page), and again open the HTML in the Chrome Browser and press (Ctrl+P) to open the print view.

Thanks for the report @Greg_Denton . That's not really great news though.

Landscape templates from GDoc used to work just fine. I just found an example in my inbox from late 2019. So what changed?

The margins used to work better as well. As mentioned in my other post, setting 0 margins on both template and the Task's "Custom Margins" still results in a very large output margin. Again, I can find an example in my inbox from mid-2021 that shows a PDF with much smaller margins. So again, what has changed?

It's hard to say for sure why a landscape template from GDoc worked better in 2019. It could be the difference between old and new renderer (HTML2PDF Rocket -> Chromium based renderer), but that seems unlikely as ultimately the problem with the landscape is in the HTML. It's also possible that Docs has changed how they export to HTML over that period, but my suspicion is that's probably something that's rarely if ever updated.
There are probably hacky ways you could get good looking landscape output from a GDoc template. Mainly I'm wondering if you could design your GDoc in portrait orientation, but with page size set to Tabloid (11" wide so should match the width of a "Letter" page size in landscape mode), and then in your Task in AppSheet still set the page size to Letter + landscape. I haven't tested it, but that might work.

 

The margins issue you describe in your other post is a bit strange. I cant seem to reproduce that one myself. I just created a new GDoc, set the margins there to 0, and set the custom margins of my Task to 0 and the resulting PDF came out very close to what I'd expect. There was still a very tiny amount of space on the sides, but nothing close to what you showed in your screenshot on the other post.
Can you double check that everything matches? The page margins in template is set to 0, the Task has custom margins enabled and set to 0, and lastly that the page size of the GDoc template matches the page size of the PDF attachment. If the page size of the PDF attachment was noticeably larger than that of the GDoc template that might explain the additional space you're seeing on the sides.

When I design an html template I don't care if it's portrait or landscape since it's basically just one CSS attribute, but I tend to make all of my table measures on % to make sure it takes into account whatever page size it's.

I suspect that this may help when designing a GDoc/MSWord template. If there is no option about a whole column's width, trying to change the width on individual cells of the first row could do the trick.

For example, on MSWord, the default way table width is handled in my case is by cm.
If I make a table on portrait and change it to landscape after my table is made it won't change size.
But you can manually asign a width on percentage and it will change accordingly.

I think that Greg's solution regarding Tabloid is the easiest one if you don't want to mess with % since the size of the items will be basically the same

I responded to Greg via my support ticket, but I'll just put these 2 points here as well.

  • Using Tabloid page size in a GDoc template is a brilliant workaround for landscape PDFs! On first pass this seems to fix the issue completely.
  • Today's test on a brand new template and task show the margins working as expected, unlike the other day.

Happy to hear it sounds like you're able to get some good results!


@Greg_Denton wrote:

In general, as some other community members have mentioned, DocX templates tend to include more information, and so result in a better final product. Ultimately though there will always be some loss of fidelity doing this. So for any power users out there looking to achieve much better PDF output I'd suggest reading through @SkrOYC's excellent post on using HTML templates to create your PDF .


That's very kind from you @Greg_Denton, thanks.

It may be kind of sad for some but I think this is part of the things we left out in pro of a pure no-code platform, those little details that need a little bit more than just no-code.

I'm doing my best to document details on my second part of the post you mentioned, it's almost done and I'll explain enough info to make an html template from scratch

Hello everyone!

Just wanted to give un update hoping it helps.

The trouble I had with the tabloïd page size is that the generated pdf always had an extra empty page, which is understandable. 

So first, I exported my GDoc template to HTML file on my PC, then uploaded the exported HTML and used it as a template, it worked perfectly. The only inconvenience will be to repeat this export, upload, and update to the app's definition upon every change to the template.

Then today I tested with setting all task's custom margins to 0 and this seems to solve the issue. The GDoc template is showing correctly and the table is filling the whole width of the page in landscape. 

Great!!

Thank you @Joseph_Seddik .

This method(GDoc to HTML) solved my landscape problem.

Additionally I just removed 'max-width' from exported HTML.

@kazweda Welcome my friend!

Nice idea regarding the 'max-width', didn't think of that 🙂

Apparently my comment wasn't clear, sorry. Please note that currently I'm not using the GDoc to HTML method anymore. I found out that by setting all custom margins in the task to 0, the problem is solved and the landscape layout is displayed correctly in the template. 

Oh, sorry. That's my misreading and I understood about custom margins with GDoc.
Then I tried using landscape-GDoc with all custom margins to 0s, but it did not work for me. (Still having portrait margins)

Anyway, thanks again @Joseph_Seddik for your helpful messages.

The custom margins in the Task, not in the GDoc. 

Capture d’écran 2022-06-01 à 15.16.37.png

I also suggest to learn a little bit about HTML/CSS
Is not too hard and can improve reports a lot.

PS: You can use .html files as templates, make sure to inline css or use a style tag inside on the head element

You are totally right my friend! I've developed an unexplainable natural avoidance so I'd do complete js but not a step into html/css, and I ended up lacking there, sigh 😕  Thanks for the encouragement!!

Hello, I did some testing into this issue when i ran across it myself and found that what works for me is to setup appsheet page settings (orientation, page size, margins), save appsheet, then edit the google doc. In the google doc adjusting the page setup to landscape and something other than letter (tabloid), save the changes, and then change the page setup back to letter.  At least it seemed specific to not working with the default value, which is usually letter.

Comparison:

Orrin_Wick_0-1655231142639.png

Orrin_Wick_1-1655231159267.png

Thank you!

Top Labels in this Space