You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Tilman Hausherr (JIRA)" <ji...@apache.org> on 2016/01/27 08:43:39 UTC
[jira] [Comment Edited] (PDFBOX-3216) Problems containing certain
fonts
[ https://issues.apache.org/jira/browse/PDFBOX-3216?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15118813#comment-15118813 ]
Tilman Hausherr edited comment on PDFBOX-3216 at 1/27/16 7:43 AM:
------------------------------------------------------------------
My solution is similar to (2), which I didn't think about but remember now, I believe this is by mkl (he's great!). What I thought about is this:
- insert a q (save graphics) and 90% scale before the stream(s)
- insert existing content stream
- append a Q (restore graphics)
- append the barcode
I'll work on that later. You mention you got blank pages sometimes, maybe these are the "corner cases" he mentioned. Hopefully these won't apply to my solution attempt.
https://stackoverflow.com/questions/26256546/how-to-insert-an-pdpage-within-another-pdpage-with-pdfbox
was (Author: tilman):
My solution is similar to (2), which I didn't think about but remember now, I believe this is by mkl (he's great!). What I thought about is this:
- insert a q (save graphics) and 90% scale before the stream(s)
- insert existing content stream
- append a Q (restore graphics)
- append the barcode
I'll work on that later. You mention you got blank pages sometimes, maybe these are the "corner cases" he mentioned. Hopefully these won't apply to my solution attempt.
https://stackoverflow.com/questions/26256546/how-to-insert-an-pdpage-within-another-pdpage-with-pdfbox
> Problems containing certain fonts
> ---------------------------------
>
> Key: PDFBOX-3216
> URL: https://issues.apache.org/jira/browse/PDFBOX-3216
> Project: PDFBox
> Issue Type: Bug
> Components: Writing
> Affects Versions: 1.8.10
> Environment: Windows 7, JAVA 1.7
> Reporter: Sumit Jha
> Priority: Minor
>
> We are trying to take a PDF file as input to a process, shrink the pages to 90% of their original size, add a barcode at the top of each page, and then create a new PDF file with the altered content.
> We tried using the PDFBOX version 1.8.10. Sample code is below:
> {code}
> package test;
> import java.awt.image.BufferedImage;
> import java.io.File;
> import java.io.FileInputStream;
> import java.util.List;
> import javax.imageio.ImageIO;
> import org.apache.pdfbox.pdmodel.PDDocument;
> import org.apache.pdfbox.pdmodel.PDPage;
> import org.apache.pdfbox.pdmodel.common.PDRectangle;
> import org.apache.pdfbox.pdmodel.edit.PDPageContentStream;
> import org.apache.pdfbox.pdmodel.graphics.xobject.PDJpeg;
> import org.apache.pdfbox.pdmodel.graphics.xobject.PDXObjectImage;
> public class TestPDFBox2 {
> public TestPDFBox2() {
> // TODO Auto-generated constructor stub
> }
> /**
> * @param args
> */
> public static void main(String[] args) {
> // TODO Auto-generated method stub
>
> try{
>
> File input = new File("C:\\workspaceRAD85_PDFBox_POC\\607018.pdf");
>
> PDDocument pd = PDDocument.load(input);
> List pdAllPages = pd.getDocumentCatalog().getAllPages();
>
> PDPage page1 = (PDPage)pdAllPages.get(0);
> BufferedImage image1 = page1.convertToImage();
> ImageIO.write(image1, "jpg", new File("C:\\workspaceRAD85_PDFBox_POC\\image_607018_11.jpg"));
>
> PDPage page2 = (PDPage)pdAllPages.get(1);
> BufferedImage image2 = page2.convertToImage();
> ImageIO.write(image2, "jpg", new File("C:\\workspaceRAD85_PDFBox_POC\\image_607018_21.jpg"));
>
> pd.close();
>
> PDDocument pdNew = new PDDocument();
>
> PDPage pageNew = new PDPage();
> pdNew.addPage(pageNew);
>
> PDXObjectImage image = null;
> image = new PDJpeg(pdNew, new FileInputStream("C:\\workspaceRAD85_PDFBox_POC\\image_607018_11.jpg"));
>
> PDPageContentStream content = new PDPageContentStream(pdNew, pageNew);
> //content.drawImage(image, 0, 0);
> content.drawXObject(image, 0, 0, 600, 700);
> content.close();
>
> PDPage pageNew2 = new PDPage();
> pdNew.addPage(pageNew2);
>
> PDXObjectImage image0 = null;
> image0 = new PDJpeg(pdNew, new FileInputStream("C:\\workspaceRAD85_PDFBox_POC\\image_607018_21.jpg"));
>
> PDPageContentStream content0 = new PDPageContentStream(pdNew, pageNew2);
> //content.drawImage(image, 0, 0);
> content0.drawXObject(image0, 0, 0, 600, 700);
> content0.close();
>
> pdNew.save("C:\\workspaceRAD85_PDFBox_POC\\Image_To_PDF_607018_1.pdf");
> pdNew.close();
>
>
>
> /*PDRectangle rect = page1.getMediaBox();
> float upperRightY = rect.getUpperRightY();
> rect.setUpperRightY(upperRightY*(0.70f));
> page1.setMediaBox(rect);
>
> pd.save("C:\\workspaceRAD85_PDFBox_POC\\shrink.pdf");*/
>
>
>
>
> }catch (Exception e) {
>
> }
> }
> }
> {code}
> We are seeing that there are few problems while converting few PDFs:
> 1. In some source PDFs bullet point listed is changed to some different icon in converted PDF.
> 2. In some PDFs when there is a bullet point in the source document the text on the line following the bullet point is destroyed/missing characters.
> We’ve read some posts that we should try using the PDFBOX version 2.1.10, but that is not an approved version at our company and it is not released too.
> I should also note that the source PDF documents we are trying to add the Bar Codes to are quite varied- they can come in any size, using any font, with images, and be oriented portrait or landscape. The goal is to get these printed on 8.5 by 11 inch paper with a barcode on them at top.
> Do you have any suggestions on how to proceed?
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org