You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Marcelo Godois Tavares <MG...@hexatek.com> on 2009/04/28 18:43:42 UTC

PDF to Image doesn't show correctly the document

Hi All

 

I tried to convert the following document to image, but I got the
attached result. 

It parsed just the text. I also tried different formats like JPG.  I ran
it using the PDFToImage class passing the document path as parameter.

 

I've read that sometimes the document is not created respecting the PDF
standard. But, is there a possibility to ignore it?! In fact, it's very
important to me, so, could I use PDF Box despite of those "errors"?

 

Thank you,

Marcelo


Setting Font Size and Type ...

Posted by Venkatesh Prasad <ve...@trv.envestnet.com>.
Following is the code I have developed to set a value to a Form Field in a PDF document. What I was not able to do is to set the Font Size and Type before writing the value in the PDF document. Can someone help with an example?
 
 public static void main(String args[])
 {
  String PDFFileName = "Project2.PDF";
  String fieldName = "Text1";
        try {
         PDDocument document = PDDocument.load(PDFFileName);
         List list = document.getDocumentCatalog().getAcroForm().getFields();
         PDField pdfield;
   try {
    if (document.isEncrypted()) {
                 document.decrypt("");
    }
   } catch (Exception e) {
    e.printStackTrace();
    throw new IOException("Failed to decrypt document #");
   }
   for (int i = 0; i < list.size(); i++) {
    pdfield = (PDField) list.get(i);
    String fldName = pdfield.getPartialName();
    if (fldName.equals(fieldName)) {
     PDDocumentCatalog docCatalog = document.getDocumentCatalog();
     PDAcroForm acroForm = docCatalog.getAcroForm();
     PDField field = acroForm.getField(fldName);
     if (field != null) {
      // I want to Set the Font Type and Size of the text "04/29/2009"
      field.setValue("04/29/2009");
     } else {
      // Debug
      System.err.println("No field found with name:" + fldName);
     }
    }
   }
         document.save("test1.PDF");
   document.close();
  } catch (Exception e) {
   System.out.println("Error"+e);
  }
}
 
Thanks & Regards
 
Venkatesh Prasad.B.K.
 

Question from a first time usr of PDFBox ...

Posted by Venkatesh Prasad <ve...@trv.envestnet.com>.
Hi,
 
I have just started to look at PDFBox for one of our requirements which is to fill a PDF with values from the FORM fields or values from Database. I have a few fundemental questions:
 
1. How can I create the template PDF which will contain the text of the application form and the fields where I then need to fill in (First Name, Last Name, Middle Name, Address etc). Is there another utility I have to use?
 
2. I understand that once I create the template PDF, I can then iterate through the fields in the PDF and use the .SetField.value' to fill them in. 
 
Thanks & Regards
 
Venkatesh Prasad.B.K.
 

Re: PDF to Image doesn't show correctly the document

Posted by Daniel Wilson <wi...@gmail.com>.
Issue looks properly logged as far as I can tell.

I'll comment more on it there for history's sake.

Daniel

On Tue, Apr 28, 2009 at 2:42 PM, Marcelo Godois Tavares <
MGodoisTavares@hexatek.com> wrote:

> Thank you Daniel
>
> I created the following issue. Please, take a look whether it's ok
> therefore it's my first issue. :)
>
> https://issues.apache.org/jira/browse/PDFBOX-457
>
> I wait the news.
>
> -----Message d'origine-----
> De : Daniel Wilson [mailto:williamstonconsulting@gmail.com]
> Envoyé : 28 avril, 2009 12:49
> À : pdfbox-users@incubator.apache.org
> Objet : Re: PDF to Image doesn't show correctly the document
>
> The attachments didn't make it.
>
> Can you create an issue & attach the documents?
>
> I'm working heavily on the PDFToImage area ... so will be glad to have a
> look at this.
>
> Daniel Wilson
>
> On Tue, Apr 28, 2009 at 12:43 PM, Marcelo Godois Tavares <
> MGodoisTavares@hexatek.com> wrote:
>
> >  Hi All
> >
> >
> >
> > I tried to convert the following document to image, but I got the
> attached
> > result.
> >
> > It parsed just the text. I also tried different formats like JPG.  I ran
> it
> > using the PDFToImage class passing the document path as parameter.
> >
> >
> >
> > I've read that sometimes the document is not created respecting the PDF
> > standard. But, is there a possibility to ignore it?! In fact, it's very
> > important to me, so, could I use PDF Box despite of those "errors"?
> >
> >
> >
> > Thank you,
> >
> > Marcelo
> >
>

RE: PDF to Image doesn't show correctly the document

Posted by Marcelo Godois Tavares <MG...@hexatek.com>.
Thank you Daniel

I created the following issue. Please, take a look whether it's ok therefore it's my first issue. :) 

https://issues.apache.org/jira/browse/PDFBOX-457

I wait the news.

-----Message d'origine-----
De : Daniel Wilson [mailto:williamstonconsulting@gmail.com] 
Envoyé : 28 avril, 2009 12:49
À : pdfbox-users@incubator.apache.org
Objet : Re: PDF to Image doesn't show correctly the document

The attachments didn't make it.

Can you create an issue & attach the documents?

I'm working heavily on the PDFToImage area ... so will be glad to have a
look at this.

Daniel Wilson

On Tue, Apr 28, 2009 at 12:43 PM, Marcelo Godois Tavares <
MGodoisTavares@hexatek.com> wrote:

>  Hi All
>
>
>
> I tried to convert the following document to image, but I got the attached
> result.
>
> It parsed just the text. I also tried different formats like JPG.  I ran it
> using the PDFToImage class passing the document path as parameter.
>
>
>
> I've read that sometimes the document is not created respecting the PDF
> standard. But, is there a possibility to ignore it?! In fact, it's very
> important to me, so, could I use PDF Box despite of those "errors"?
>
>
>
> Thank you,
>
> Marcelo
>

Re: PDF to Image doesn't show correctly the document

Posted by Daniel Wilson <wi...@gmail.com>.
The attachments didn't make it.

Can you create an issue & attach the documents?

I'm working heavily on the PDFToImage area ... so will be glad to have a
look at this.

Daniel Wilson

On Tue, Apr 28, 2009 at 12:43 PM, Marcelo Godois Tavares <
MGodoisTavares@hexatek.com> wrote:

>  Hi All
>
>
>
> I tried to convert the following document to image, but I got the attached
> result.
>
> It parsed just the text. I also tried different formats like JPG.  I ran it
> using the PDFToImage class passing the document path as parameter.
>
>
>
> I’ve read that sometimes the document is not created respecting the PDF
> standard. But, is there a possibility to ignore it?! In fact, it’s very
> important to me, so, could I use PDF Box despite of those “errors”?
>
>
>
> Thank you,
>
> Marcelo
>