pdf-generation

Saved Text Field value is not displayed properly in PDF generated using PDFBOX

瘦欲@ 提交于 2019-12-01 11:28:30
import java.io.IOException; import javax.swing.text.BadLocationException; import org.apache.pdfbox.cos.COSArray; import org.apache.pdfbox.cos.COSDictionary; import org.apache.pdfbox.cos.COSFloat; import org.apache.pdfbox.cos.COSName; import org.apache.pdfbox.cos.COSString; import org.apache.pdfbox.exceptions.COSVisitorException; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDPage; import org.apache.pdfbox.pdmodel.interactive.action.PDAnnotationAdditionalActions; import org.apache.pdfbox.pdmodel.interactive.action.type.PDActionJavaScript; import org.apache

itextsharp add text over a circle image in a table cell

孤人 提交于 2019-12-01 11:25:51
I need to have a table with multiple columns where I have different coloured circles in different cells with a number in the middle of the circle. Similar to the mockup below but with everything centralized and equal. I have tried the following: PdfContentByte canvas = writer.DirectContent; PdfTemplate template = canvas.CreateTemplate(40, 40); template.SetLineWidth(1f); template.Circle(15f, 15f, 15); template.Stroke(); iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(template); img.Alignment = iTextSharp.text.Image.UNDERLYING | iTextSharp.text.Image.ALIGN_CENTER; Phrase imgPhrase

Problems setting rights (SetEncryption) within pdf

久未见 提交于 2019-12-01 11:17:21
we run into problems using the product. It seems does some functions in iText 5.4.3 doesn’t working well? Please, can someone give us a hint how to solve that? We modify src.pdf to dest.pdf as follows: Function CreateFlattedPdf(ByRef originalPdf As Byte()) As Byte() Dim retValue As Byte() = Nothing Dim originalPdfReader As PdfReader = New PdfReader(originalPdf) Dim pdfKopie As MemoryStream = New MemoryStream() Dim pdfKopieStamper As PdfStamper = New PdfStamper(originalPdfReader, pdfKopie) pdfKopieStamper.SetEncryption(False, userPassword, ownerPassword, _ PdfWriter.ALLOW_ASSEMBLY _ Or

How to create a rounded corner table using iText\\iTextSharp? [duplicate]

こ雲淡風輕ζ 提交于 2019-12-01 11:13:52
This question already has an answer here: How do I round the corners of an iTextSharp table border? 1 answer I have to create a table having rounded corners, something like it: Can I do it with iTextSharp? This is done using cell events. See the Calendar example from my book ( Java / C# ). Make sure that you don't add any "automated" borders to the cell, but draw the borders yourself in a cell event: table.DefaultCell.Border = PdfPCell.NO_BORDER; table.DefaultCell.CellEvent = new RoundedBorder(); The RoundedBorder class would then look like this: class RoundedBorder : IPdfPCellEvent { public

Convert XPS to PDF in WPF C# application

依然范特西╮ 提交于 2019-12-01 10:47:37
I need to convert an XPS file I create with my application to a PDF file, what is the best way to do so? I prefer this to be done from inside C# using a managed assembly. Open source is preferred upon third party solutions You can use the XpsDocument class to read the XPS files, then use a PDF library (such as Report.Net or #PDF) to export it. I used #PDF back in .NET 1.1, but not sure if it can be easily converted to .NET 2.0. #PDF: http://sharppdf.sourceforge.net/ Report.NET: http://report.sourceforge.net/ An open source managed assembly might be hard to find, but you can look at

Calculate correct width of a text

孤街醉人 提交于 2019-12-01 10:43:38
I need to read a plan exported by AutoCAD to PDF and place some markers with text on it with PDFBox. Everything works fine, except the calculation of the width of the text, which is written next to the markers. I skimmed through the whole PDF specification and read in detail the parts, which deal with the graphic and the text, but to no avail. As far as I understand, the glyph coordinate space is set up in a 1/1000 of the user coordinate space. Hence the width need to be scale up by 1000, but it's still a fraction of the real width. This is what I am doing to position the text: float textWidth

Splitting a large Pdf file with PDFBox gets large result files

試著忘記壹切 提交于 2019-12-01 10:39:51
I am processing some large pdf files, (up to 100MB and about 2000 pages), with pdfbox. Some of the pages contain a QR code, I want to split those files into smaller ones with the pages from one QR code to the next. I got this, but the result file sizes are the same as the source file. I mean, if I cut a 100MB pdf file into a ten files I am getting ten files 100MB each. This is the code: PDDocument documentoPdf = PDDocument.loadNonSeq(new File("myFile.pdf"), new RandomAccessFile(new File("./tmp/temp"), "rw")); int numPages = documentoPdf.getNumberOfPages(); List pages = documentoPdf

Create PDF in Swift

 ̄綄美尐妖づ 提交于 2019-12-01 10:39:19
I am following Apple's Docs to create a PDF file using Xcode6-Beta6 in Swift var currentText:CFAttributedStringRef = CFAttributedStringCreate(nil, textView.text as NSString, nil) if (currentText) { // <-- This is the line XCode is not happy // More code here } Compiler throws Type 'CFAttributedStringRef' does not conform to protocol 'BooleanType' error If I use if(currentText != nil) I get 'CFAttributedStringRef' is not convertible to 'UInt8' From Apple's Docs for CFAttributedStringCreate Return Value An attributed string that contains the characters from str and the attributes specified by

Create an Image or PdfTemplate from a PDF file

让人想犯罪 __ 提交于 2019-12-01 09:45:36
问题 While using the itextsharp library for pdf generation, I came across this method:- iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(itextsharp.text.pdf.PdfTemplate); Where, we can get Image instance from a PdfTemplate. But, I don't know how to create a PdfTemplate and there is no constructor taking a pdf file name or stream. Why I want this is: I want to create an Image from a PDF file and then isert this image into another pdf file. Anybody knows how to create PdfTemplate object

iTextSharp generate PDF and show it on the browser directly

主宰稳场 提交于 2019-12-01 09:27:43
How to open the PDF file after created using iTextSharp on ASP.Net? I don't want to save it on the server, but directly when the new PDF is generated, it shows on the browser . Is it possible to do that? Here is the example for what I mean: Click here . But on this example, the file directly downloaded. How can I do that? Dim doc1 = New Document() 'use a variable to let my code fit across the page... Dim path As String = Server.MapPath("PDFs") PdfWriter.GetInstance(doc1, New FileStream(path & "/Doc1.pdf", FileMode.Create)) doc1.Open() doc1.Add(New Paragraph("My first PDF")) doc1.Close() The