strong text
this is the code I am using to convert a rendered html page to pdf.
html_string = render_to_string("monthly_report/generated_pdf.html",
{'form': form, 'month': monthStr.strftime("%B %Y")})
html = HTML(string=html_string)
main_doc = html.render()
pdf = main_doc.write_pdf()
return HttpResponse(pdf, content_type='application/pdf')
The row having data spanning over more than one page is being truncated and data is getting lost.
What I want is the remaining data should be printed on the next page.
How it can be achieved ???
Please help, I am stuck over it from yesterday.
This problem is caused by bug #36, WeasyPrint is not able to split table cells yet.
Related
In a project report I want to enter some Dataframes.
Normally I generate the report with MarkDown but some tables are too wide to display nicely.
So I tried to export as in HTML with the code bellow:
# 1. Set up multiple variables to store the titles, text within the report
page_title_text='My report'
title_text = 'Scrollable table'
text = 'Hello, welcome to your Scrollable table test!'
prices_text = 'Twitter Data'
# 2. Combine them together using a long f-string
html = f'''
<html>
<head>
<title>{page_title_text}</title>
</head>
<body>
<h1>{title_text}</h1>
<p>{text}</p>
<h2>{prices_text}</h2>
{wrd_archive.head(5).to_html()}
</body>
</div>
</html>
'''
# 3. Write the html string as an HTML file
with open('html_report.html', 'w') as f:
f.write(html)
The output looks like the screenshot below and I am searching since hours for a solution how to make this table scrollable on the vertical axis and (that would be nice) scrollable vertical with a fixed height and fixed headers.
I do not know why I am lost today but I don't find the correct solution.
Can someone please help ;)
Screenshot
Making a simple app script that puts images and Text into a Google Doc separated by 2 Columns, for whatever reason, no matter the way I try it the images are always above the text (Inline) in the Doc, even though they should be layered (Inline),
//Replace QR Code
let qrText = editLocalBody.findText("{{qrCode}}");
let setImagePlace = qrText.getElement().asText().replaceText("{{qrCode}}", "");
let qrCodeImage = setImagePlace.getParent().asParagraph().insertInlineImage(0, qrCodeBlob);
From what I've seen this should insert an image wherever the text was previously located, but when it runs this it's always in the wrong spot, somehow above the text it was suppost to be in!
//Edit - To Show The Progression Of What Is Suppose To Happen And What Actually Happens:
I'm making QR Code badges for a propriety system that runs integrated tightly with Google, so I'm using appscript to get an entry from a google form containing an amount of badges (With relevent data) and autofill a Google Doc Accordingly.
// Loop Start
I fill my template with a text line that has key words in it I can select and replace later, with a keyword it can use to insert another this (This Part Works)
I first edit (findText("{{qrCode}}");) the QR Code, replacing (.replaceText) the keyword for it to nothing ("")
I then get the parent of the piece of code I ran above, which is a block of text (I think all the text in the Doc, I think this is where the issue lies, it puts it above the text because it's just one 'paragraph' or not multiple 'bodies' of text, if I could separate this I think it would work!) As a paragraph, and insert An Inline Image at Child Index (0, of the image ,qrCodeBlob)
I've debugged this script quite a bit, so I know It's that final line that inserting images fails, it sees all the text as 'one'.
// I want this (In Descending Order, each it's own full line):
Image
Text
Image
Text
//What It Gives Me (In Descending Order, each it's own full line):
Image
Image
Text
Text
let qrCodeImage = setImagePlace.getParent().asParagraph().insertInlineImage(0, qrCodeBlob);
I'm trying to automatize a word - file generation via python docx. I created a template with the first page and its specific footers and headers; now I only need to implement this footer, starting from upon the second page:
Name Page # / Total Pages Date
all I want to know is how to configure this footer for all pages starting from the second, without influencing the headers or footers of the first page of the template. My problem is: Can I create word fields via python docx (e.g. the Pages and NumPages fields for the midpart; that's the only problem)..?
If not, can I somehow only insert the "Name" and the "Date" part into the footers from upon page 2 of the template without affecting the mid-part which I would then prepare in the template as well... ?
Attempted code on a template already containing the Pag/NumPag fields in the middle of the footer deleted the middle part (Result was a file where "Hello" was written in the lower left corner in the footer, and the Pag/NumPag of the template (Hello.docx) disappeared:
from docx import Document
from docx.enum.text import WD_ALIGN_PARAGRAPH
doc = Document("Hello.docx")
footer = doc.sections[0].footer
parag = footer.paragraphs[0]
parag.text = "Hello"
parag.alignment = WD_ALIGN_PARAGRAPH.LEFT
parag.style = doc.styles["Footer"]
doc.save("Hello2.docx")
there's a webpage with many pages. And I'd like to know the total pages for each search.
Like the pictures shown below. Since the last page is page 41 and it becomes un_clickable. So I want to extract that value 41 from those 2 span tags.
Any help?
I tried with xpath. But would prefer a CSS solution
Thanks
page_temp = Nokogiri::HTML(browser.html)
page_temp.xpath('tr[#td = "colspan="32""]').each do |node|
puts node.text
Click here to view the snapshot
Since you are using Ruby here's a simple code you can use
page_temp = Nokogiri::HTML(browser.html)
all_pages = page_temp.search("td[colspan='32'] tr td")
puts all_pages.map{|p| p.text} # list all page numbers
puts all_pages.last.text # list the last page number
I'm struggling with a problem in SSRS. I have created a customer invoice that is looking good in report viewer however, it needs to be set to print in a certain way.
There are 4 main elements to this report.
Header, this needs to repeat on every other page if the invoice details + footer do not fit on the first page.
Invoice details, this needs to repeat on every other page if the invoice details and footer do not fit on the first page.
Footer, this needs to repeat on every other page if the invoice details and footer do not fit on the first page.
Back of page (payment details, like a bank statement), this needs to repeat on every other page without the header, invoice details or footer.
Is this even possible? If not, the end user has accepted that the first 3 parts of the invoice to repeat as necessary and just the last page to be the payment details.
Thanks in advance
Getting the Report Header and Footer to repeat on every page should be pretty straight forward.
Now if you have some additional information outside of the report content you wish to repeat on every page you could do the following:
As you are probably already aware, when using a Tablix it's possible to repeat table header rows on each page . This can be used to our advantage by adding Tablix with a single column and making it span the size of the page, in both the header and data rows you add rectangles so it acts like the report body. In the header row you can add any data/text you wish to repeat on the next pages.
Now as you want the back-side of the pages to have text on them, you probably don't want this to repeat on every page. Because the back of the pages is always the same static data, you could simply generate your report the way it's set up right now and insert the static page between the pages of the report.
To achive the last part you could use some code like this:
String inputFilePath1 = #""; //back of page
String inputFilePath2 = #""; //report
String outPutFilePath = #""; //final report
PDFDocument doc1 = new PDFDocument(inputFilePath1);
PDFDocument doc2 = new PDFDocument(inputFilePath2);
// Get a page from the first document. -> back of page
PDFPage page = (PDFPage)doc1.GetPage(0);
for(int i = 1; i <= doc2.PageCount; i++)
{
if (i % 2 == 1)
{
// Insert the page to the second document at specified position.
doc2.InsertPage(page, i);
}
}
// Output the new document.
doc2.Save(outPutFilePath)