printing

Programmatically Print a PDF File - Specifying Printer

泪湿孤枕 提交于 2021-02-07 15:57:21
问题 I have a requirement to print an existing PDF file from a Python script. I need to be able to specify the printer in the script. It's running on Windows XP. Any ideas what I could do? This method looks like it would work except that I cannot specify the printer: win32api.ShellExecute ( 0, "print", filename, None, ".", 0 ) 回答1: There's an underdocumented printto verb which takes the printer name as a parameter (enclosed in quotes if it contains spaces) . import tempfile import win32api import

QPainter.drawText() SIGSEGV Segmentation fault

爷,独闯天下 提交于 2021-02-07 14:28:34
问题 I'm trying to print a simple text message in a thermal printer through Qt5 printing methods. #include <QCoreApplication> #include <QDebug> #include <QtPrintSupport/QPrinterInfo> #include <QtPrintSupport/QPrinter> #include <QtGui/QPainter> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QPrinter printer(QPrinter::ScreenResolution); QPainter painter; painter.begin(&printer); painter.setFont(QFont("Tahoma",8)); painter.drawText(0,0,"Test"); painter.end(); return a.exec(); }

Printing a file and configure printer settings

匆匆过客 提交于 2021-02-07 12:53:19
问题 I'm trying to code a printer automation using Python on Windows, but can't get it done. I'm not really understanding the topic and i'm a little surprised - a "simple" way to get this done doesn't seem to exist..? There are so many APIs that allow to access common things in a nice and easy way, but printing seems to be something "special"..? Here is what i have and what i want to do: There is a PDF file. The PDF already exists, i do not want to create PDFs or any other filetype. I like to

Printing HTML tables without splitting a row across two pages

一个人想着一个人 提交于 2021-02-07 11:22:51
问题 I need to print some data in an HTML table from Internet Explorer (various versions) and Safari on OS X. Ignoring Safari for the moment. When printing a table that has more rows than can fit on a page, the last row on the page is often split with part of the row on the first page and the rest of the row on the next page. This looks ugly. Is there a way to avoid it? I've been searching around and so far I've found page-break-before: always , but I'm not sure if that's what I'm looking for,

Draw Graphics2D to another Graphics2D

…衆ロ難τιáo~ 提交于 2021-02-07 07:26:20
问题 It is possible to draw from one Graphics2D to another Graphics2D ? Let me explain. I have printing issues, when i display a JTextArea or JTextPanel in screen, internaly its used sun.java2d.SunGraphics2D , but when im printing its used sun.print.PeekGraphics and sun.awt.windows.WPathGraphics . The problem is with some kind of Fonts, like Arial. In some sizes lines are cut. I have tryed a lot of ways to render the text in printing, Graphics2D.drawString , SwingUtilities2.drawString , TextLayout

How to access fields of a JSON in GO

我与影子孤独终老i 提交于 2021-02-07 03:08:17
问题 Hi everyone I'm trying to see what the proper way of accessing fields of a json object from a http.get request in go. I first do an http.get call get the JSON and then print it (which works) but is there a way to access just a field? for example: response, err:= http.Get("URL") //Error checking is done between contents, err:=ioutil.Readall(response.Body) //Now at this point I have a json that looks like {"id": "someID", "name": "someName", "test": [{"Name":"Test1", "Result": "Success"}, {

Showing Print Preview in C#

混江龙づ霸主 提交于 2021-02-06 09:13:08
问题 Right now, I'm trying to build my form on a PrintDocument, but the only way for me to see where stuff is actually appearing on the page is to print a paper. It works, but I have a lot of stuff I need to add, and I'd rather not waste tons of paper. Right now I have a print dialogue come up, but theres no print preview button. Is there a way I can make one appear? Thanks! public partial class Form4 : System.Windows.Forms.Form { private System.ComponentModel.Container components; private System

Showing Print Preview in C#

梦想与她 提交于 2021-02-06 09:09:59
问题 Right now, I'm trying to build my form on a PrintDocument, but the only way for me to see where stuff is actually appearing on the page is to print a paper. It works, but I have a lot of stuff I need to add, and I'd rather not waste tons of paper. Right now I have a print dialogue come up, but theres no print preview button. Is there a way I can make one appear? Thanks! public partial class Form4 : System.Windows.Forms.Form { private System.ComponentModel.Container components; private System

How do I print a number n times in python? [duplicate]

大兔子大兔子 提交于 2021-02-05 12:29:20
问题 This question already has answers here : Converting integer to string in Python (14 answers) Repeat string to certain length (13 answers) Closed 1 year ago . How do I print a number n times in Python? I can print 'A' 5 times like this: print('A' * 5) AAAAA but not 10, like this: print(10 * 5) 50 I want the answer to be 10 10 10 10 10 How do I escape the mathematical operation in print() ? I am not asking how to print the string '10' n times, I am asking how to print the number 10 n times. 回答1

Python output formats

血红的双手。 提交于 2021-02-05 12:24:08
问题 Hi there I've had a search output formats and formats had no luck. I couldn't find right documentation for it and I really want to learn how this code works if somebody could enlighten me please? print ("Survived: %i (%.1f%%)"%(len(survived), float(len(survived))/len(train)*100.0)) print ("Not Survived: %i (%.1f%%)"%(len(not_survived), float(len(not_survived))/len(train)*100.0)) print ("Total: %i"%len(train)) My questions is inside the code % symbols %i %.1f%% (I believe one decimal) I just