Search Unity

Runtime PDF Gereration

Discussion in 'Made With Unity' started by ringhino, Feb 15, 2011.

  1. ringhino

    ringhino

    Joined:
    Aug 31, 2010
    Posts:
    39
    Hello everyone.
    Some time ago I found myself having to send data via email to the stage of a game. the difficulty was to build a layout graphically pretty, so I started researching how to create code from a pdf document.
    On the web I found a C # library which I used sharp Pdf changing some parts to create these APIs.
    the only thing that was not possible to do since I use mac was to create dynamically un0immagine, I have circumvented this problem by replacing all free System.Drawing with those of Unity.

    I hope that it will be useful.

    http://www.francescogallorini.com/2011/02/unity-sharp-pdf/
     
    davidPrime likes this.
  2. Pixelstudio_nl

    Pixelstudio_nl

    Joined:
    Jun 22, 2009
    Posts:
    179
    I also use iTextSharp! very nice way to generate pdf's from C#
     
  3. ringhino

    ringhino

    Joined:
    Aug 31, 2010
    Posts:
    39
    thanks for the indication

    Ring
     
  4. Ippokratis

    Ippokratis

    Joined:
    Oct 13, 2008
    Posts:
    1,521
    Hi. Thanks a lot for this resource. When I tried to use your package at first I got
    but it was remedied when I placed the provided pictures (picture1 and picture2) in the Project folder.

    Perhaps you could suggest some package that parses pdf data, for rendering pdf's ?
     
  5. rahuxx

    rahuxx

    Joined:
    May 8, 2009
    Posts:
    537
    It is not working for me.
    How to do this?
    Please guide
     
  6. lavz24

    lavz24

    Joined:
    Mar 14, 2013
    Posts:
    45
    I cant unzip the project
     
  7. eastken

    eastken

    Joined:
    Jun 11, 2015
    Posts:
    2
  8. aesparza

    aesparza

    Joined:
    Apr 4, 2016
    Posts:
    29
    Hi!
    I am using SharpPDF to runtime PDF generation. I'm using it on Windows. I found two problems:

    • I need to put an scaled image on a page. I'm using addImage.
    It doesn't scale the image but it cuts the image starting from upper-left corner with the size I would like to scale it to.
    How can I solve this? In MAC doesn't happen that.
    • I have a problem adding images to a PDF file with WINDOWS. The PDF doesnt show the images well (they are grated) when I open it with ADOBE READER. But, if I open it with another pdf reader, the images are well. How can I solve this problem? On the contrary, if I use SharpPDF in MAC, this problem doesnt exist, I need to use it on Windows.
    I have post both questions in the page of the lib inside SourceForge but I didn't get any answer.

    Could anybody help me with this please?
     
    Max-Dep likes this.
  9. unitycodergp

    unitycodergp

    Joined:
    Feb 1, 2017
    Posts:
    47
    Hi,
    I have the same problem that aesparza :(

    anyone got a solution plz ?
    Thx a lot.
     
  10. Democide

    Democide

    Joined:
    Jan 29, 2013
    Posts:
    315
    Hehe. And another one with that issue.
     
  11. Democide

    Democide

    Joined:
    Jan 29, 2013
    Posts:
    315
    And I got it fixed. The issue is that sharpPDF interprets the stream wrong. Grating (slanted or missing lines) is because the code doesn't know when to start a new image line properly. Say the image is 192 pixels wide but the code thinks it's 190 pixels wide. Fiddling with your image sizes or with the code will help you solve that!
     
  12. Mad_26

    Mad_26

    Joined:
    Apr 25, 2019
    Posts:
    15
    Hello ringhino,
    I am using the sharp pdf the one which u had recommended and i am facing difficulties like:
    1. How to dynamically increase the column height according to the text size at runtime.
    2. How do i insert an image without using the co-routine function.
    3. How to dynamically write the data on the new page if current page is filled and data is still pending. For example, there are 50 rows in my table at runtime and one first page 30rows occupy the space, then how do i dynamically write the remaining 20 rows on second page.
    4. Instead of storing the file in root folder, in assets folder , how can i store the pdf at different location by selecting the folder from the system.

    If you or anyone can help me out with these questions with would be a great help for me... Thank you.
     
  13. fraeri

    fraeri

    Joined:
    Nov 8, 2018
    Posts:
    64
    Hello together,
    very old thread but still a topic no one seems to solve now. I wanted to create and export a pdf from my Unity Build on iOS. Is there a good solution for that?

    Thanks & Regards
     
  14. fraeri

    fraeri

    Joined:
    Nov 8, 2018
    Posts:
    64

    @MadhurSalvi: can you show me how you integrated sharp pdf into Unity?
     
  15. Mad_26

    Mad_26

    Joined:
    Apr 25, 2019
    Posts:
    15
    Hello, I havent tried for the IOS yet but it is working on standalone
     
  16. JUNGLEE372018

    JUNGLEE372018

    Joined:
    Oct 4, 2018
    Posts:
    2
    Hi,
    I am trying to do the same on windows. but i am not able to get the output. when i run the scene it is showing the null reference exception.

    NullReferenceException: Object reference not set to an instance of an object
    sharpPDF.pdfPage+<newAddImage>c__Iterator0.MoveNext () (at Assets/plugins/sharpPDF Plugins/pdfPage.cs:144)
    UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)

    did anybody got the user manual or some guide for implementation.
     
  17. MARKLEE12

    MARKLEE12

    Joined:
    Sep 29, 2019
    Posts:
    1
    To generate PDF file in C# try ZET-Pdf for better results. It is really helpful in generating PDF files.
     
  18. cibaben5

    cibaben5

    Joined:
    Mar 12, 2020
    Posts:
    6
    hi please can i delete border table ?
     
  19. Max-Dep

    Max-Dep

    Joined:
    Jul 15, 2012
    Posts:
    2
    I have exactly the same problem.
    it's driving me crazy. Did you find a solution?