pdf-generation

Hybris MediaModel how to get Bytes

蓝咒 提交于 2019-12-02 13:49:52
问题 Is there any way in Hybris to obtain all the bytes from a MediaModel ? When I want to instantiate a PdfReader , I need to pass either the Path of the File OR the ByteArrayInputStream. How can I transform the MediaModel into a Byte Array? 回答1: You can use MediaService @Resource private MediaService mediaService; //... final MediaModel mediaModel= mediaService.getMedia("mediaName"); final InputStream inputStream = mediaService.getStreamFromMedia(mediaModel); Then you can pass InputStream or

Why doesn'n create pdf-documents in java servlet? [duplicate]

别来无恙 提交于 2019-12-02 13:36:55
This question already has an answer here: How can I serve a PDF to a browser without storing a file on the server side? 4 answers I use iText/Pdfbox to create a PDF document. Everything works when I create the PDF using a standalone Java class like this: public static void main(String[] args){ ... ... ... } The document is created correctly. But I need create a PDF document from a Servlet. I paste the code into the get or post method, run that servlet on the server, but the PDF document isn't created! This code works as a standalone application: This code doesn't work: Bruno Lowagie Please

How to calculate the height of an element?

╄→尐↘猪︶ㄣ 提交于 2019-12-02 13:30:55
I am generating pdf files by XML data. I calculate the height of a paragraph element as : float paraWidth = 0.0f; for (Object o : el.getChunks()) { paraWidth += ((Chunk) o).getWidthPoint(); } float paraHeight = paraWidth/PageSize.A4.getWidth(); But this method does not works correctly. Can you give me an idea? Your question is strange. According to the header of your question, you want to know the height of a string, but your code shows that you are asking for the width of a String. Please take a look at the FoobarFilmFestival example. If bf is a BaseFont instance, then you can use: float

ASP.NET 4: HttpResponse open in NEW Browser?

六月ゝ 毕业季﹏ 提交于 2019-12-02 12:59:45
I am using a PDF generater that utlizes HttpResponse. Is there a way (perhaps passing a header tag) to open the PDF in a NEW windows instead of the same one? I don't want the user to be directed away from the website... Here's the code I'm using: System.Web.HttpResponse response = System.Web.HttpContext.Current.Response; response.Clear(); response.AddHeader("Content-Type", "application/pdf"); response.AddHeader("Content-Disposition", "inline; filename=" + downloadName + "; size=" + downloadBytes.Length.ToString()); response.Flush(); response.BinaryWrite(downloadBytes); response.Flush();

good way to generate PDF offline on Android device… tried DOCX4J

放肆的年华 提交于 2019-12-02 12:34:46
问题 is there a good way to generate a PDF document on a Android device? I have a DOCX file as a Base. I know that it is possible: here a very good app https://play.google.com/store/apps/details?id=cn.wps.moffice_eng they render it offline. some ideas? I already tried DOCX4J, and it is generating a DOCX file properly, how ever using the WordprocessingMLPackage wordMLPackage to prepare the PDF it says: E/AndroidRuntime﹕ FATAL EXCEPTION: main java.lang.ExceptionInInitializerError at org.plutext

How to restart page number from 1 in different group of BIRT report

一个人想着一个人 提交于 2019-12-02 12:02:54
Backgroud: Use Java + BIRT to generate report. Generate report in viewer and allow user to choose to export it to different format (pdf, xls, word...). All program are in "Layout", no program in "Master Page". Have 1 "Data Set". The fields in "Layout" refer to this DS. There is Group in "Layout", gropu by one field. In "Group Header", I create one cell to use as page number. "Page : MyPageNumber". "MyPageNumber" is a field I define which would +1 in Group Header. Problem: When I use 1st method to generate report, "MyPageNumber" could not show correctly. Because group header only load one time

Cannot get CSS to work in iTextSharp (5.4.3) when making pdf

喜欢而已 提交于 2019-12-02 10:59:05
问题 I have a problem trying to apply a css file to my pdf using the iTextSharp (5.4.3) generation library. basically the css is not being applied at all. I have the following method in my vb.net file Protected Sub btnPreview_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPreview.Click Dim bytes As Byte() bytes = System.Text.Encoding.UTF8.GetBytes(letterRadEdit.Content) Dim tagProcessor As tool.xml.html.DefaultTagProcessorFactory() Using input As New MemoryStream(bytes,

How to handle the case in wich an iText\iTextSharp table is splitted in two pages?

丶灬走出姿态 提交于 2019-12-02 10:43:10
问题 I have the following problem using iTextSharp. I am putting some tables into my document. The problem is that if a table content not fit on a page and go into another page I have that it overwrite the second page header, so I have the following situation: As you can see I am inserting a table at the end of a page and this is splitted in two pages and the second page header is overwrite by the table content. I want to avoid this situation but I don't know how have I to do. I am thinking that

How to add a table as a header?

こ雲淡風輕ζ 提交于 2019-12-02 10:40:01
I am working with iTextSharp trying to add an header and a footer to my generated PDF but, if I try to add an header that have width of 100% of my page I have some problem. So I have do the following things: 1) I have create a class named PdfHeaderFooter that extends the iTextSharp PdfPageEventHelper class 2) Into PdfHeaderFooter I have implemented the OnStartPage() method that generate the header: // write on start of each page public override void OnStartPage(PdfWriter writer, Document document) { base.OnStartPage(writer, document); PdfPTable tabHead = new PdfPTable(new float[] { 1F });

Creating table with 2 rows in pdf footer using itext

别等时光非礼了梦想. 提交于 2019-12-02 10:32:38
Hi I want to add footer with 2 rows. 1st row will have document name with background color. 2nd row will have copy rights notes. I tried to create using ColumnText. but I am not able to set the background color for the row(only text getting background color). Is there any ay to achieve this. i spend my whole night to find a solution but not able to do. You could have saved yourself a sleepless night by reading the documentation. You'd have discovered that you can set the background of a cell using the setBackgroundColor() method and that you can add a table at an absolute position using the