pdf-generation

How to unit test a Python function that draws PDF graphics?

女生的网名这么多〃 提交于 2019-11-28 08:18:57
I'm writing a CAD application that outputs PDF files using the Cairo graphics library. A lot of the unit testing does not require actually generating the PDF files, such as computing the expected bounding boxes of the objects. However, I want to make sure that the generated PDF files "look" correct after I change the code. Is there an automated way to do this? How can I automate as much as possible? Do I need to visually inspect each generated PDF? How can I solve this problem without pulling my hair out? You could capture the PDF as a bitmap (or at least a losslessly-compressed) image, and

Is there any API in C# or .net to edit pdf documents? [closed]

*爱你&永不变心* 提交于 2019-11-28 07:36:51
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . Is there any API in C# or .net to edit pdf documents? Like I need to retrieve particular text and replace it with my own text. Thanks nRk 回答1: This is not possible (in a clean & reliable way), from iTextSharp tutorial: You can't 'parse' an existing PDF file using iText, you can only 'read' it page per page. What

Reportlab - how to introduce line break if the paragraph is too long for a line

孤街醉人 提交于 2019-11-28 07:26:28
问题 I have a list of text to be added to a reportlab frame style = getSampleStyleSheet()['Normal'] style.wordWrap = 'LTR' style.leading = 12 for legend in legends: elements.append(Paragraph(str(legend),style)) If the legend is too long, the text at the end is not visible at all. How to introduce line breaks in this situation. 回答1: This may or may not apply but I just learned that \n which I normally use to introduce new lines in Python strings gets ignored by the Paragraph object of ReportLab.

DOMPDF problem with Cyrillic characters

橙三吉。 提交于 2019-11-28 07:02:00
I am using the DOMPDF library to create an invoice in PDF. This document can be in French, Russian or English, but I am having trouble printing Russian characters. First, I tried to use UTF-8 encoding and placed the meta tag in the head of the HTML page to be converted: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> But that didn't work. Then I inserted this meta tag inside the BODY tag, and it helped solve the problem with French characters. But Russian characters still don't work. I have also tried to convert Russian characters into HTML entities, but that too does not

Centered, multiline text using iTextSharp ColumnText

人走茶凉 提交于 2019-11-28 06:59:59
问题 I am trying to center a block of multiline text using iTextSharp. I thought that using the ColumnText would do the trick, but I'm having some trouble getting both center alignment, as well as proper wrapping working at the same time. Here is some code which shows the 2 methods I'm trying: private void PrintLocationAddress(PdfContentByte Canvas, string Address) { //define the regions for our ColumnText objects Rectangle rect1 = new Rectangle(150f, 300, 350f, 450f); Rectangle rect2 = new

How to add text as a header or footer?

做~自己de王妃 提交于 2019-11-28 06:51:27
问题 I'm creating a pdf with iText 5 and want to add a footer. I did everything like the book "iText in action" in Chapter 14 says. There are no errors but the footer doesn't show up. Can somebody tell me what I'm doing wrong? My code: public class PdfBuilder { private Document document; public void newDocument(String file) { document = new Document(PageSize.A4); writer = PdfWriter.getInstance(document, new FileOutputStream(file)); MyFooter footerEvent = new MyFooter(); writer.setPageEvent

Delphi PDF generation [closed]

一曲冷凌霜 提交于 2019-11-28 04:46:48
We're using Fast Reports to create reports but we're not very happy with the quality of the PDFs it creates. I know we can plug in other PDF components instead of the one that comes with FastReports so my question is What good PDF components are there out there (Free or Commercial) for Delphi? Ideally it should not require any dlls. Edit: I bought Gnostice in the end as it had the FastReports integration, source available and a fairly good reputation. I did however find an issue (after I had bought it) with exporting multipage reports from FastReports to PDF where the component leaks memory

Print to PDF in a for loop

早过忘川 提交于 2019-11-28 04:33:38
I want to loop over a plot and put the result of the plot in a PDF . The following code is used to do this: What this does is loop 3 times and plot 3 different plots from the iris dataset. Then it should save it to the C:/ drive. The PDF files are created, but are corrupted. for(i in 1:3){ pdf(paste("c:/", i, ".pdf", sep="")) plot(cbind(iris[1], iris[i])) dev.off() } To drawn lattice plots on the device, one needs to print the object produced by a call to one of the lattice graphics functions. Normally, in interactive use, R auto prints objects if not assigned. In loops however, auto printing

How do I paint Swing Components to a PDF file with iText?

回眸只為那壹抹淺笑 提交于 2019-11-28 04:29:40
问题 I would like to print my Swing JComponent via iText to pdf. JComponent com = new JPanel(); com.add( new JLabel("hello") ); PdfWriter writer = PdfWriter.getInstance( document, new FileOutputStream( dFile ) ); document.open( ); PdfContentByte cb = writer.getDirectContent( ); PdfTemplate tp = cb.createTemplate( pageImageableWidth, pageImageableHeight ); Graphics2D g2d = tp.createGraphics( pageImageableWidth, pageImageableHeight, new DefaultFontMapper( ) ); g2d.translate( pf.getImageableX( ), pf

Creating complex pdf using java

时光毁灭记忆、已成空白 提交于 2019-11-28 04:09:37
问题 I have an Java/Java EE based application wherein I have a requirement to create PDF certificates for various services that will be provided to the users. I am looking for a way to create PDF (no need for digital certificates for now). What is the easiest and convenient way of doing that? I have tried XSL to pdf conversion HTML to PDF conversion using itext. crude java way (using PDFWriter, PdfPCell etc.) What is the best way out of these or is there any other way which is easier and