New SimpleDoc(new PDFPrintable(document, Scaling. SimpleDoc sd = new SimpleDoc(new PDFPrintable(document, Scaling.ACTUAL_SIZE, false), flavor, null) StreamPrintService sps = factories.getPrintService(fos) Does it look familiar to you? :-) PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet() I've anycodings_postscript simplified it a bit and included it anycodings_postscript below. Create a PDF file and write text into it using PDFBox 2.0 In this PDFBox Tutorial, we shall see how to create a PDF file and write text into it using. See this other SO question, Printing to anycodings_postscript PostScript with PDFBox produces a anycodings_postscript massive file, why?, for a code snippet anycodings_postscript that shows PDFPrintable in use. I think anycodings_postscript PDFPrintable will do that for you. You are right, in PDFBox the version anycodings_postscript 1.18.12 Package anycodings_postscript has a anycodings_postscript PDPageable class, but the corresponding anycodings_postscript version 2.0.3 Package anycodings_postscript does not.īut what you want to to do is convert to anycodings_postscript a PostScript language document. How do anycodings_pdf I convert a PDF file to a PostScript file anycodings_pdf using PDFBox 2.0? The PDPageable object doesn't seem to be in anycodings_pdf the PDFBox 2.0 code and I didn't see it anycodings_pdf specified in the migration document. ![]() New SimpleDoc(new PDPageable(document), flavor, null), aset) PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet() Īset.add(new PageRanges(1, document.getNumberOfPages())) įileOutputStream fos = new FileOutputStream(filePathAndName) įactories.getPrintService(fos).createPrintJob().print( PDDocument document = pdfGenerator.getDocument() Throw new PrinterException("No PostScript factories available") StreamPrintServiceFactory.lookupStreamPrintServiceFactories(flavor,ĭocFlavor.BYTE_()) SimpleDoc doc = new SimpleDoc(new PDFPrintable(pdfPrint, Scaling.I was able to create a PDF with PDFBox anycodings_pdf (version 1.8.9) and then convert it to a anycodings_pdf PostScript file with the following code: DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE Create simple doc using PDFPrint as Printable and print it PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet() PDDocument pdfPrint = PDDocument.load(new File("1.pdf")) įileOutputStream fos = new FileOutputStream("1.ps") StreamPrintServiceFactory.lookupStreamPrintServiceFactories(flavor, psMimeType) ![]() Below code produces incorrect ps file of mixed orientation pdf files.ĭocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE PDPageable uses Orientation.AUTO but this object can not be used in printing. Unfortunately, .OrientationRequested does not have any AUTO value like PDFPageable has, so how to convert such pdf files to ps using PDFPrintable class. When we send this ps file to postscript printer, all pages are printed either Portrait or Landscape basis what OrientationRequested attribute value we set while printing. ![]() There is one problem with this approach which I observed, when pdf file is having mixed orientation meaning like some pages are Portrait and some are Landscape, then this code does not produce the correct PS file. I have followed the same code snippet, this link advised to use PDFPrintable instead of PDPageable. How to convert a PDF to a postscript file using pdfbox 2.0 I have refered below link which has similar query in past. I am using pdfbox library for this conversion. I have a requirement to convert pdf to ps. A PDF file is often a combination of In later PDF revisions, a PDF document can also support links (inside document or web page), forms, PostScript.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |