I was succesful converting an SVG File into PDF using Apache Batik.
The following code is used to generate PDF:
import org.apache.fop.svg.PDFTranscoder;
import org.apache.batik.transcoder.TranscoderInput;
import org.apache.batik.transcoder.TranscoderOutput;
...
File svgFile = new File("./target/test.svg");
...
PDFTranscoder transcoder = new PDFTranscoder();
try (FileInputStream fileInputStream = new FileInputStream(svgFile); FileOutputStream fileOutputStream = new FileOutputStream(new File("./target/test-batik.pdf"))) {
TranscoderInput transcoderInput = new TranscoderInput(fileInputStream);
TranscoderOutput transcoderOutput = new TranscoderOutput(fileOutputStream);
transcoder.transcode(transcoderInput, transcoderOutput);
}
Now I want to influence the page size of the resulting PDF so I get a page size for A4. How could I do that?
I have tried some key hints but with no effect.
I've recently had this same problem. This might not exactly solve your issue, but I was at least able to produce a PDF with the correct aspect ratio for a page (U.S. letter size in this case) with the following Groovy (almost Java) code:
Hope this helps.