• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Adobe Acrobat gives error to open programmatically generated pdf attachment.

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using iText1.3.jar and writing following code in my servlet . It opens a download dialog box and later in Adobe Acrobat when i try to open this file it gives error that - file is an attachment and corrupt and cant be open.


response.setHeader("Content-Disposition","attachment;filename=c:\\Report.pdf;");
response.setHeader("Content-Type","application/pdf");
Document doc = new Document();
PdfWriter docWriter = PdfWriter.getInstance(doc, response.getOutputStream());
doc.open();
doc.add(new Paragraph("Report 1"));

What is being left to let open this file in Adobe Acrobat ? Please Help!!
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's probably not the problem, but leave out the "c:\\" from the filename; you can't specify a directory anyway.

You could also try a current version of iText; 1.3 has been obsolete for years.
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You might want to show us the remainder of your code.
 
sanskriti agarwal
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its again generating same error

"Adobe could not open 'Report.pdf' because either it is not a supported file type or because the file has been damaged (for example it was sent as an email attachment and wasnt correctly decoded)"

I also use 'inline' in place of 'attachment' but same the file is creating but could not be opened.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

You might want to show us the remainder of your code.

 
sanskriti agarwal
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The whole code is as follows (in Servlet) :-

try
{
response.setHeader("Content-Disposition","attachment;filename=c:\\Report.pdf;");
response.setHeader("Content-Type","application/pdf");
Document doc = new Document();
PdfWriter docWriter = PdfWriter.getInstance(doc, response.getOutputStream());
doc.open();
doc.add(new Paragraph("Report 1"));
document.close();
}
catch (Exception e2)
{
System.out.println(e2.getMessage());
}
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic