pdfbox

Writing Arabic with PDFBOX with correct characters presentation form without being separated

陌路散爱 提交于 2019-11-26 22:18:14
问题 I'm trying to generate a PDF that contains Arabic text using PDFBox Apache but the text is generated as separated characters because Apache parses given Arabic string to a sequence of general 'official' Unicode characters that is equivalent to the isolated form of Arabic characters. Here is an example: Target text to Write in PDF "Should be expected output in PDF File" -> جملة بالعربي What I get in PDF File -> I tried some methods but it's no use here are some of them: 1. Converting String to

how to make my watermark text in any pdf file as non-selectable?

时光怂恿深爱的人放手 提交于 2019-11-26 21:25:15
问题 I have done watermark text in pdf file using itextpdf, but when I copy the actual text of the pdf file it allows us to copy the watermark text too. Is there anyway that we can restrict our watermark text as Non-selectable? Image watermark_image = Image.getInstance(imageFile.getAbsolutePath()); while (i < num_of_pages) { i++; //To pass our watermark over text add_waterMark = pdfStamper.getOverContent(i); //To pass our watermark under text //add_waterMark = pdfStamper.getUnderContent(i); //

In PDFBox, how to change the origin (0,0) point of a PDRectangle object?

走远了吗. 提交于 2019-11-26 20:59:47
问题 The Situation: In PDFBox, PDRectangle objects' default origin (0,0) seems to be the lower-left corner of a page. For example, the following code gives you a square at the lower-left corner of a page, and each side is 100 units long. PDRectangle rectangle = new PDRectangle(0, 0, 100, 100); The Question: Is it possible to change the origin to the UPPER-LEFT corner, so that, for example, the code above will give you the same square at the UPPER-LEFT corner of the page instead? The reason I ask:

Using PDFBox to write UTF-8 encoded strings to a PDF [duplicate]

大兔子大兔子 提交于 2019-11-26 20:48:39
This question already has an answer here: Apache PDFBox: Can I set font other than those present in PDType1Font 1 answer I am having trouble writing unicode characters out to a PDF using PDFBox. Here is some sample code that generates garbage characters instead of outputting "š". What can I add to get support for UTF-8 strings? PDDocument document = new PDDocument(); PDPage page = new PDPage(); document.addPage(page); PDPageContentStream contentStream = new PDPageContentStream(document, page); PDType1Font font = PDType1Font.HELVETICA; contentStream.setFont(font, 12); contentStream.beginText();

how to add unicode in truetype0font on pdfbox 2.0.0?

亡梦爱人 提交于 2019-11-26 20:28:02
I've been using the PDFBOX version 2.0.0 in a Java project to convert pdfs to text. several of my pdfs are missing the ToUnicode method, so they come out in Gibberish while I export them. 2016-09-14 10:44:55 WARN org.apache.pdfbox.pdmodel.font.PDSimpleFont(1):322 - No Unicode mapping for 694 (30) in font MPBAAA+F1 in the WARN above, instead of the real character, a gibberish unicode (30) was presented. I was able to overcome it by editing the additional.txt file in pdfbox, since from trial & error I understood that the code of the character (694 in this case) represents a certain Hebrew letter

PdfBox encode symbol currency euro

假如想象 提交于 2019-11-26 19:09:15
I created a PDF document with the Apache PDFBox library. My problem is to encode the euro currency symbol when drawing a string on the page, because the base font Helvetica does not provide this character. How I can convert the output "þÿ ¬" to the symbol "€"?. Unfortunately PDFBox's String encoding is far from perfect yet (version 1.8.x). Unfortunately it uses the same routines when encoding strings in generic PDF objects as when encoding strings in content streams which is fundamentally wrong. Thus, instead of using PDPageContentStream.drawString (which uses that wrong encodings), you have

How to down scale content of a pdf?

≡放荡痞女 提交于 2019-11-26 18:42:13
问题 i have a pdf which I need to down scale. The pdf is in A4 portrait mode, what I need is to shrink the content of the pdf to 5 % and put this into a new PDF also in size A4 and portrait mode. Its not an option to convert the pdf to images, scale them and put it back to a pdf. I am looking for a way to solve this in java. Is there a way to solve this with pdfbox or itext? 回答1: If you use iText 7, then this is an option: public void manipulatePdf(String src, String dest) throws IOException {

compress pdf with large images via java

家住魔仙堡 提交于 2019-11-26 18:22:39
问题 Looking for a way to compress images in a pdf and to output a pdf for archiving. I cannot compress the images before creation as it would compromise the quality of the print. The size of each pdf is around 8MB with the bulk of this being made up of 2 images. Images are in png format and are brought into pdf during generation(3rd party generator used) Is there a way to compress these in java without using a 3rd party tool. I have tried with pdfbox, itext and a 3rd party exe(neevia), the 3rd

How to insert an PDPage within another PDPage with pdfbox

╄→гoц情女王★ 提交于 2019-11-26 17:52:00
I use different tools like processing to create vector plots. These plots are written as single or multi-page pdfs. I would like to include these plots in a single report-like pdf using pdfbox. My current workflow includes these pdfs as images with the following pseudo code PDDocument inFile = PDDocument.load(file); PDPage firstPage = (PDPage) inFile.getDocumentCatalog().getAllPages().get(0); BufferedImage image = firstPage.convertToImage(BufferedImage.TYPE_INT_RGB, 300); PDXObjectImage ximage = new PDPixelMap(document, image); PDPageContentStream contentStream = new PDPageContentStream

How to merge two PDF files into one in Java?

落爺英雄遲暮 提交于 2019-11-26 17:24:14
I want to merge many PDF files into one using PDFBox and this is what I've done: PDDocument document = new PDDocument(); for (String pdfFile: pdfFiles) { PDDocument part = PDDocument.load(pdfFile); List<PDPage> list = part.getDocumentCatalog().getAllPages(); for (PDPage page: list) { document.addPage(page); } part.close(); } document.save("merged.pdf"); document.close(); Where pdfFiles is an ArrayList<String> containing all the PDF files. When I'm running the above, I'm always getting: org.apache.pdfbox.exceptions.COSVisitorException: Bad file descriptor Am I doing something wrong? Is there