Hi, at your code at stackoverflow i noticed, you are trying to get the mediabox without setting it before. I'm not very experieced in PdfBox, but maybe it would help to use a different constructor for PDPage:
PDPage page = new PDPage(PDRectangle.A4); Best regards, Siegfried - Siegfried Gstöttner [email protected] ++43 (0)662 8044 77392 Universitätsbibliothek Salzburg, Bibliothekstechnologie Hofstallgasse 2-4 AT - 5020 Salzburg AUSTRIA -----Ursprüngliche Nachricht----- Von: Greg Hanowski [mailto:[email protected]] Gesendet: Dienstag, 09. April 2019 19:22 An: [email protected] Betreff: Re: CORS error when running PDFBox from a web app Hi, Sorry for the formatting issues. It didn't look like that mess when I clicked Send. I am aware of the many resources available on CORS issues. The problem is there is too many. I was hoping someone could explain why the error happens on the PDFBox BaseTable.draw() command, which would help narrow the scope of the problem. For an easy-to-read posting of this problem, see https://stackoverflow.com/questions/55595975/why-getting-cors-error-in-boxable-pdfbox-table-draw Greg On 4/9/2019 11:08 AM, Andreas Lehmkuehler wrote: > Hi, > > your mail is hard to read due to some obvious formatting issues. > However it isn't necessary at all. > > It is a security issue. Simply search for "No > 'Access-Control-Allow-Origin' header is present on the requested > resource". There are a lot of hints how to solve that issue depending > on your environment. > > The described issue has nothing to do with PDFBox. > > Andreas > > > Am 09.04.19 um 17:57 schrieb Greg Hanowski: >> |table.draw(); |which is running on the server and has nothing to do >> with the browser at that time. Here is the full code for perspective >> |publicStringcreateDimCtrlPlanPdf(EnDatabasedb,intuserId,Stringdata){StringretVal >> >> ="[]";try{// Set marginsfloatmargin =10;// Initialize >> DocumentPDDocumentdoc =newPDDocument();PDPagepage >> =newPDPage();doc.addPage(page);floatyStartNewPage >> =page.getMediaBox().getHeight()-(2*margin);// Initialize >> tablefloattableWidth >> =page.getMediaBox().getWidth()-(2*margin);booleandrawContent >> =false;floatyStart =yStartNewPage;floatbottomMargin >> =70;BaseTabletable >> =newBaseTable(yStart,yStartNewPage,bottomMargin,tableWidth,margin,doc,page,true,drawContent);// >> >> Create Header rowbe.quodlibet.boxable.Row<PDPage>headerRow >> =table.createRow(15f);be.quodlibet.boxable.Cell<PDPage>cell >> =headerRow.createCell(100,"Dimensional Control >> Plan");table.addHeaderRow(headerRow);// Create 6-column 2nd header >> rowrow =table.createRow(15f);cell =row.createCell(10,"Lower >> limit");cell =row.createCell(10,"Upper limit");cell >> =row.createCell(15,"Rep.");cell =row.createCell(15,"Target");cell >> =row.createCell(15,"Average limit");cell =row.createCell(15,"Standard >> deviation max");cell =row.createCell(20,"the >> drawing");table.draw();//CORS error occurs here when running on a >> server which has been called by a web page// Close Stream and save >> pdfFilefile =newFile("DimCtrlPlan.pdf");System.out.println("Sample >> file saved at : >> "+file.getAbsolutePath());//Files.createParentDirs(file);doc.save(file);doc.close();}catch(IOExceptionex){Logger.getLogger(EnCad.class.getName()).log(Level.SEVERE,null,ex);}catch(COSVisitorExceptionex){Logger.getLogger(EnCad.class.getName()).log(Level.SEVERE,null,ex);}returnretVal;} >> >> Any suggestions? ||| >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

