Setting the version of a PDF file using Crystal Reports and/or C#.

W

Wayne Deleersnyder

I've been looking on the web trying to find a solution to converting a
PDF Form from v.1.6(Acrobat 7) to PDF v1.4(Acrobat 5). It's one of
those weird situations where one of the applications I'm using requires
v.1.4. v.1.6 will mess up the application itself. PDFversion.exe (a
conversion utility) doesn't support the 1.6 format and Acrobat 7
doesn't want to do backwards conversion on a PDF Form (at least from
what I can see).

So... I figure I have 2 options: 1.) recreate the form using Acrobat
5, or 2.)use some of my knowledge of C# and crystal reports to create a
little database and generate form output using the Crystal Reports
engine built into Visual Studio 2005. The form way is probably
quicker... but I like programming, so option 2 sounds like more fun :)

My problem is that the PDFs that I'm creating via C#+Crystal Reports,
are version 1.3 (I can't win, lol). However, I did find some nifty
Java code that allows the version of a PDF to be controlled
programmatically. Does anyone know if theres a command/switch/etc...
that would allow me to define the version of the PDF I'm outputting
when I do:


someRPT.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat,"SomeFile.pdf");



For the Java code I found the following stuff:

// setting a PDF to version 1.3, 1.4, 1.5, or 1.6
import java.io.FileOutputStream;

import com.lowagie.text.Document;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;

public class PdfVersion1_3 {
public static void main(String[] args) {
Document document = new Document();
try {
PdfWriter writer = PdfWriter.getInstance(document, new
FileOutputStream("PDFversion1_3.pdf"));
writer.setPdfVersion(PdfWriter.VERSION_1_3);
//writer.setPdfVersion(PdfWriter.VERSION_1_4);
//writer.setPdfVersion(PdfWriter.VERSION_1_5);
//writer.setPdfVersion(PdfWriter.VERSION_1_6);
document.open();
document.add(new Paragraph("This is a PDF-1.3 document"));
} catch (Exception ioe) {
System.err.println(ioe.getMessage());
}
document.close();
}
}




// setting a PDF to version 1.2
import java.io.FileOutputStream;

import com.lowagie.text.Document;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;

public class PdfVersion1_2 {
public static void main(String[] args) {
Document document = new Document();
try {
PdfWriter writer = PdfWriter.getInstance(document, new
FileOutputStream("PDFversion1_2.pdf"));
writer.setPdfVersion(PdfWriter.VERSION_1_2);
document.open();
document.add(new Paragraph("This is a PDF-1.2 document"));
} catch (Exception ioe) {
System.err.println(ioe.getMessage());
}
document.close();
}
}

This all leads me to believe that there must be a way. Even if I don't
end up going the programming route, it's still good to know though.

Thanks in advance for any responses.
Wayne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top